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

Play RetroMUD
Post new topic  Reply to topic     Home » Forums » CMUD Beta Forum
GenericGun
Beginner


Joined: 23 Jul 2009
Posts: 12

PostPosted: Sat Jan 23, 2010 3:14 pm   

[3.12] Another serious substitution bug.
 
This is the trigger:
Code:
<?xml version="1.0" encoding="ISO-8859-1" ?>
<cmud>
  <trigger priority="13350" regex="true" language="Lua" copy="yes">
    <pattern>\b(troll(e|a|em)?)\b</pattern>
    <value>local txt = "<color goldenrod>" .. zs.param(1) .. "</color>"
zs.sub(txt)</value>
  </trigger>
</cmud>



This is the test line:
Code:
#SH Masywny paskudny troll, ciezki czerwonooki troll i ogromny czerwonooki troll.


This is the result:
Code:

Masywny paskudny troll, ciezki czerwonooki txt =  .. zs.param(1) ..
zs.sub(txt) i ogromny czerwonooki troll.Masywny paskudny txt =  .. zs.param(1) ..
zs.sub(txt), ciezki czerwonooki troll i ogromny czerwonooki txt =  .. zs.param(1) ..
zs.sub(txt).zs.sub(txt)                                                        txt =  .. zs.param(1) .. zs.sub(txt)             txt =  .. zs.param(1) ..
zs.sub(txt)


I don't think it gets more serious than that ;)

G.

PS The alternative version using zScript also fails but less miserably.
Reply with quote
intoK
Apprentice


Joined: 18 Feb 2007
Posts: 190

PostPosted: Sat Jan 23, 2010 7:38 pm   
 
how about with repeat on? Cool
Reply with quote
Zugg
MASTER


Joined: 25 Sep 2000
Posts: 23379
Location: Colorado, USA

PostPosted: Mon Jan 25, 2010 5:48 pm   
 
Why in the world are you using Lua for something like this? You should only use Lua for doing things that you cannot do in zScript. For your above script, a simple:
Code:
#SUB {<color goldenrod>%1</color>}

works fine. The #SUB (and #CW) commands are pretty tightly tied with the actual trigger code so that multiple substitutions on a line can be performed. It's very possible that Lua cannot control the #SUB command properly because it is an external scripting engine.
Reply with quote
GenericGun
Beginner


Joined: 23 Jul 2009
Posts: 12

PostPosted: Tue Jan 26, 2010 5:33 pm   
 
Zugg, I'm sorry maybe I did not make my self clear, I only wish to highlight the first occurrence and well..
Without repeat within line, this is what I get with your suggestion:

Code:
Masywny paskudny troll, ciezki czerwonooki {troll} i ogromny czerwonooki {troll}.


And truth be told, I use lua in much more serious substitutions and it is quite important to me.

Thanks again.
Reply with quote
Zugg
MASTER


Joined: 25 Sep 2000
Posts: 23379
Location: Colorado, USA

PostPosted: Wed Jan 27, 2010 1:25 am   
 
You will need to use the #PSUB command. The #SUB command will *always* replace multiple occurrences on the same line. With #PSUB you specify the exact start and end positions (both X and Y) of what you want to replace. That should work within Lua because the #PSUB command doesn't have the special code for handling multiple matches which is causing the problem between Lua and the normal Sub command.
Reply with quote
Display posts from previous:   
Post new topic   Reply to topic     Home » Forums » CMUD Beta Forum 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