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
mthree984
Newbie


Joined: 02 Sep 2004
Posts: 3

PostPosted: Thu Sep 02, 2004 12:16 am   

Help with changing a "two" to "2"
 
So on my mud (LP style) when you enter a room you get a brief room name with room exits. After a new line there is a list of npc's.

Example:

South Wall of Amador [e,w].
Two Wall Guards are here.

Now i have it set up to walk around a simple area attacking monsters. My trouble is when there are more than one npc in the room. In this example there are two. What i need to do is to count how many npc's are in the room and subtract that number when one is killed. When that number is down to 0 the path will continue (#step).

So heres my trouble code... im new to zmud scripting but not new to programming.
----------------------------------------------
pattern: %1 Wall Guards are here.

#pause
%1=@temp_num
#if {@temp_num=~"two"} {@num_guards=2}
#if {@temp_num=~"three"} {@num_guards=2}
#if {@temp_num=~"four"} {@num_guards=3}
#if {@temp_num=~"five"} {@num_guards=4}
kill guards
-----------------------------------------------
@num_guards is a variable with a default of 0.

I have a nother piece of code that subtracts the kills. It seems to be troublesome also and looks like this:
-----------------------------------------------
pattern: * dealt the death blow to *

#math @num_guards @num_guards-1
#if {@num_guards=0} {#step}
-----------------------------------------------

All suggestions are welcome... thanks!
Reply with quote
mr_kent
Enchanter


Joined: 10 Oct 2000
Posts: 698

PostPosted: Thu Sep 02, 2004 12:37 am   
 
#VAR cardnums {one|two|three|four|five}
#TRIGGER {&temp_num Wall Guards are here.$} {#PAUSE;num_guards=%ismember(@temp_num,@cardnums);kill guards}
#TRIGGER {* dealt the death blow to *} {#ADD num_guards -1;#IF (@num_guards < '1') {#STEP} {}}
Reply with quote
mthree984
Newbie


Joined: 02 Sep 2004
Posts: 3

PostPosted: Thu Sep 02, 2004 1:23 am   
 
That didnt seem to work either, it just stops after killing the npc's in the room.

Some investigation shows the culprit is the variable num_guards. It was sitting at -2. The test was on 2 wall guards. It looks like everything got subtracted fine, just that the num_guards variable never added 2 up in the first place.
Reply with quote
mr_kent
Enchanter


Joined: 10 Oct 2000
Posts: 698

PostPosted: Thu Sep 02, 2004 2:33 am   
 
Whew, I knew better. Capitalization caused the problem. Also added prompt char to the beginning since in my tests, &temp_num was grabbing the '>' character. Sorry about that and try this:

#TRIGGER {{~> |}&temp_num Wall Guards are here.$} {#PAUSE;num_guards=%ismember(%lower(@temp_num),@cardnums);kill guards}
Reply with quote
mthree984
Newbie


Joined: 02 Sep 2004
Posts: 3

PostPosted: Thu Sep 02, 2004 6:32 am   
 
^Worked great!
Im understanding the zmud scripting language faster than i thought. This is getting exciting :)
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