|
oldguy2 Wizard
Joined: 17 Jun 2006 Posts: 1201
|
Posted: Mon Jan 12, 2009 7:01 pm
Lua substitute? |
Okay how do you do use substitute in LUA?
I tried the following:
zs.substitute("")
zs.cmd.substitute("")
Neither one works. |
|
|
|
oldguy2 Wizard
Joined: 17 Jun 2006 Posts: 1201
|
Posted: Tue Jan 13, 2009 3:16 am |
Anyone know how to do this? Right now I am having to do...
zs.cmd.gag()
zs.print("<strong><color yellow>Replacement Line Here</color></strong>")
Isn't this going to slow me down with the gagging? |
|
|
|
Fang Xianfu GURU
Joined: 26 Jan 2004 Posts: 5155 Location: United Kingdom
|
Posted: Tue Jan 13, 2009 3:22 am |
Just mentioned this in the other thread, zs.sub() and zs.substitute() both work fine here.
If this string of posts of yours is telling me anything, it's that I REALLY need to finish that Lua tutorial. I'll get round to it one day :( |
|
|
|
oldguy2 Wizard
Joined: 17 Jun 2006 Posts: 1201
|
Posted: Tue Jan 13, 2009 8:16 am |
It refuses to work with either of those.
For example...
zs.sub("<color red>Some line here</color>")
does not work
zs.substitute("<color red>Some line here</color>")
doesn't work either.
I'm on 2.37. |
|
|
|
oldguy2 Wizard
Joined: 17 Jun 2006 Posts: 1201
|
Posted: Tue Jan 13, 2009 8:29 am |
What the hell...
Well I don't know but I had something weird go on. I had attempted variations of sub earlier and it created another trigger with my substitution and the value of #sub {0}. I deleted that and now it works. |
|
|
|
Gael Beginner
Joined: 18 Sep 2006 Posts: 29
|
Posted: Sat Jan 17, 2009 12:45 am |
The #SUB (or zs.sub() in Lua) requires two arguments... the pattern to match, and what you're substituting it for. You've only been using one: Here's an example of how it might work:
Code: |
zs.sub("godlike","Zugg-like")
zs.show("I have godlike power!")
|
If you run the script then you should see: "I have Zugg-like power!" |
|
|
|
shalimar GURU
Joined: 04 Aug 2002 Posts: 4691 Location: Pensacola, FL, USA
|
Posted: Sat Jan 17, 2009 12:47 am |
its not smart enough to realize the trigger pattern is what is to be subbed?
|
|
_________________ Discord: Shalimarwildcat |
|
|
|
oldguy2 Wizard
Joined: 17 Jun 2006 Posts: 1201
|
Posted: Sat Jan 17, 2009 2:57 am |
Gael,
You can substitute the entire trigger pattern directly. That is for substituting certain words...like string.gsub.
The problem is it stops working once in awhile...just like the syntax highlighting...and now zs.param(). |
|
|
|
Fang Xianfu GURU
Joined: 26 Jan 2004 Posts: 5155 Location: United Kingdom
|
Posted: Sat Jan 17, 2009 6:22 am |
If you take a look at the documentation for the #sub command, Gael, you'll see that it has an optional second argument. What this does is create a trigger in the format:
#trig {$firstarg} {#sub {$secondarg}}
You can also use zs.sub() in the same way that #sub is used in that trigger. |
|
|
|
Gael Beginner
Joined: 18 Sep 2006 Posts: 29
|
Posted: Sat Jan 17, 2009 8:41 am |
My bad. It's all new to me. :)
|
|
|
|
|
|