Register to post in forums, or Log in to your existing account
 

Play RetroMUD
Post new topic  Reply to topic     Home » Forums » CMUD General Discussion
oldguy2
Wizard


Joined: 17 Jun 2006
Posts: 1201

PostPosted: 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.
Reply with quote
oldguy2
Wizard


Joined: 17 Jun 2006
Posts: 1201

PostPosted: 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?
Reply with quote
Fang Xianfu
GURU


Joined: 26 Jan 2004
Posts: 5155
Location: United Kingdom

PostPosted: 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 :(
_________________
Rorso's syntax colouriser.

- Happy bunny is happy! (1/25)
Reply with quote
oldguy2
Wizard


Joined: 17 Jun 2006
Posts: 1201

PostPosted: 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.
Reply with quote
oldguy2
Wizard


Joined: 17 Jun 2006
Posts: 1201

PostPosted: 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. Laughing
Reply with quote
Gael
Beginner


Joined: 18 Sep 2006
Posts: 29

PostPosted: 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!"
Reply with quote
shalimar
GURU


Joined: 04 Aug 2002
Posts: 4671
Location: Pensacola, FL, USA

PostPosted: Sat Jan 17, 2009 12:47 am   
 
its not smart enough to realize the trigger pattern is what is to be subbed?
_________________
Discord: Shalimarwildcat
Reply with quote
oldguy2
Wizard


Joined: 17 Jun 2006
Posts: 1201

PostPosted: 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().
Reply with quote
Fang Xianfu
GURU


Joined: 26 Jan 2004
Posts: 5155
Location: United Kingdom

PostPosted: 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.
_________________
Rorso's syntax colouriser.

- Happy bunny is happy! (1/25)
Reply with quote
Gael
Beginner


Joined: 18 Sep 2006
Posts: 29

PostPosted: Sat Jan 17, 2009 8:41 am   
 
My bad. It's all new to me. :)
Reply with quote
Display posts from previous:   
Post new topic   Reply to topic     Home » Forums » CMUD General Discussion All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum

© 2009 Zugg Software. Hosted by Wolfpaw.net