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
yeedoo
Beginner


Joined: 13 Dec 2007
Posts: 16

PostPosted: Wed Jan 09, 2008 2:07 pm   

question about the type of VARIABLE
 
for example

Code:
#class aaa {}
#var fc_n
#TRIGGER {^(*)%s/(*)%s~(+(*)~)} {
  fc_n=%1
}
#class 0
now if %1=700
in another class ,i write
Code:
#math a @fc_n+500
#show @a

700 500 was shown on

obviously it's not my mean ,it's more like the two strings were concated.

so i replace the (*) with (%d),it's ok

i don't konw what's wrong ,VARIABLE's type changed ?
Reply with quote
Progonoi
Magician


Joined: 28 Jan 2007
Posts: 430

PostPosted: Wed Jan 09, 2008 2:17 pm   
 
I barely understand what you're trying to say but.

I just tried with two pseudoclasses in my system.

I named on to 'aaa' and wrote a variable inside of it, fc_n and gave it a value of 200.

Then I made second class, named it 'aaa1' and put a variable that I called 'a' there.

To the "script part" of the Variable a, I wrote

Code:


%eval(@fc_n+500)



And chose it not to be text but Zmud script. Then I hit Save.

When I now use Command Line and type #show @a it shows me 700 as its supposed to.


Prog
_________________
The Proud new owner of CMud.

--------------------------------
Intel Core i5-650 3,2GHz
4 DD3 RAM
GTX 460 768MB
Win 7 Home Premium 64x
--------------------------------
Reply with quote
Taz
GURU


Joined: 28 Sep 2000
Posts: 1395
Location: United Kingdom

PostPosted: Wed Jan 09, 2008 3:22 pm   
 
Keep the wildcard as %d rather than * since if that does actually match and store your value correctly then not only is it faster but it's also the correct way to match numbers.
_________________
Taz :)
Reply with quote
ralgith
Sorcerer


Joined: 13 Jan 2006
Posts: 715

PostPosted: Wed Jan 09, 2008 4:55 pm   
 
Taz nailed it. Ninjaed again ;)
_________________
CrossOver: Windows Compatibility on Mac and Linux CMUD Advocate
Reply with quote
Fang Xianfu
GURU


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

PostPosted: Wed Jan 09, 2008 5:54 pm   
 
Mmm, the probable cause is that the * wildcard is being greedy and capturing all but one of the spaces at the end (which will be matched by %s since %s is the regex \s+ and not \s*). "700 " is a string but "700" is probably a number.
_________________
Rorso's syntax colouriser.

- Happy bunny is happy! (1/25)
Reply with quote
ralgith
Sorcerer


Joined: 13 Jan 2006
Posts: 715

PostPosted: Wed Jan 09, 2008 9:09 pm   
 
So, to encapsulate this...

Here is what you SHOULD have (This worked right for me)
Code:
#class aaa {}
#var fc_n
#TRIGGER {^(%d)%s~/(%d)%s~(+(%d)~)} {
  fc_n=%1
}
#class 0

#math a @fc_n+500
#show @a
_________________
CrossOver: Windows Compatibility on Mac and Linux CMUD Advocate
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