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

Play RetroMUD
Post new topic  Reply to topic     Home » Forums » zMUD General Discussion
Dormouse
Newbie


Joined: 29 May 2004
Posts: 3

PostPosted: Sun Aug 07, 2005 11:31 pm   

Variable Only Correctly Parses Second Time [Cipher script]
 
I have created a simple class for allowing two players to speak in a custom language [cipher] and automatically translate it for them.

Unfortunately, after a player says something with the cipher alias [\ say], the next time they receive a ciphered line, it will display all of the %1 %2 &c parts properly, however for absolutely no reason that I can divine after many hours of debugging, it will reuse the previous value [that is the one stored when they spoke in cipher]. If they receive the exact same line again, however, it will properly decipher, and every time after tha tuntil they say something in cipher again at which point it repeats. Needless to say it is incredibly vexing and completely baffling. Any insight would be greatly appreciated.

Edit: Adding the #VAR cdbuff {%4} line makes it so that every time it will store the variable properl, as opposed to requiring twice the first time as with just the Perl in the trigger, but it's a pretty gross kludge, and doesn't shed any light on the original issue.

The class:
Code:

#CLASS {Crypt}
#ALIAS \ {
  #VARIABLE spmode {%1}
  #VARIABLE cebuff {%-2}
;#SAY c @cebuff
  #VARIABLE alebuff %subchar( %lower( %left( @cebuff, 1))%right( @cebuff, 1), @alph, @albalph)
;#say a @alebuff
;#VAR alebuff  @alebuff
  @spmode @gandbracket %item( @alkeys, %random( 1, %numitems( @alkeys))) @alebuff
;#var cdbuff clear
;#var cebuff clear
  }
#VAR cebuff {}
#VAR alebuff {}
#VAR alph {abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ} {abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ}
#VAR albalph {ypltavkrezgmshubxncdijfqowYPLTAVKREZGMSHUBXNCDIJFQOW} {ypltavkrezgmshubxncdijfqowYPLTAVKREZGMSHUBXNCDIJFQOW}
#VAR cdbuff {}
#VAR aldbuff {}
#VAR spmode {says}
#VAR spverbs {say|says|whisper|whispers} {say|says|whisper|whispers}
#VAR alkeys {Qux|Zxc|Spqr|Shme|Lrtzolnt|Grlkmextr|Sluh|Boz|Jlikta|Qwghlm|Xuy|Cwmy}
#VAR gandbracket {"&z[&CGand&z]&W"} {"&z[&CGand&z]&W"}
#REGEX {^([a-zA-z0-9\s]+) (?spmode:@spverbs)(,|) '\[Gand\] (?:@alkeys) (?cdbuff:.+)'} {
;#SAY "3" %3 "4" %4
;#SAY @cdbuff
  #VARIABLE cdbuff {%4}
  #VARIABLE aldbuff %subchar( %upper( %left( @cdbuff, 1))%right( @cdbuff, 1), @albalph, @alph)
;#SAY ald @aldbuff
;#VARIABLE aldbuff @gandbracket @aldbuff
;#say ald2 @aldbuff
;#SAY "1" %1 "2" %2 "d" '@aldbuff'
  #SUBSTITUTE {%1 %2 '%ansi(darkgray)~[%ansi(cyan)Gand%ansi(darkgray)~]%ansi(gray,bold) @aldbuff'}
  }
#CLASS 0


Sample output with debugging on:
Code:

> \ say This is a fruhstuck

c This is a fruhstuck
a drec ec y vnircdilg
say &z[&CGand&z]&W Xuy drec ec y vnircdilg
You say '[Gand] This is a fruhstuck'
3 , 4 drec ec y vnircdilg
drec ec y vnircdilg
Variable: cdbuff              drec ec y vnircdilg
ald This is a fruhstuck
1 You 2 say d 'This is a fruhstuck'


> #cr;#echo Foo says, '~[Gand~] Sluh drec ec y nvnvnvnvnv'

Foo says '[Gand] This is a fruhstuck'
3 , 4 drec ec y nvnvnvnvnv
drec ec y vnircdilg
Variable: cdbuff              drec ec y vnircdilg
ald This is a fruhstuck
1 Foo 2 says d 'This is a fruhstuck'


> #cr;#echo Foo says, '~[Gand~] Sluh drec ec y nvnvnvnvnv'

Foo says '[Gand] This is a rfrfrfrfrf'
3 , 4 drec ec y nvnvnvnvnv
drec ec y nvnvnvnvnv
Variable: cdbuff              drec ec y nvnvnvnvnv
ald This is a rfrfrfrfrf
1 Foo 2 says d 'This is a rfrfrfrfrf'
Reply with quote
Display posts from previous:   
Post new topic   Reply to topic     Home » Forums » zMUD 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