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
chris74269
Novice


Joined: 26 Mar 2003
Posts: 40

PostPosted: Wed Mar 26, 2003 5:07 am   

question with if
 
im trying to make a bot to run for me when i get the message You are too fatigued
i made it so it assigned the room to run to, and where to run back, problem is it enters every single if i have, this is what i use
Pattern: You are too fatigued
Command: @rundir
#WA 50000
%if("@rundir=east",west,%null)
%if("@rundir=northeast",southwest,%null)
%if("@rundir=southeast",northwest,%null)
%if("@rundir=west",east,%null)
%if("@rundir=southwest",northeast,%null)
%if("@rundir=northwest",southeast,%null)
%if("@rundir=south",north,%null)
%if("@rundir=north",south,%null)

what happens is it goes every direction listed, not the one i want
Reply with quote
Wrudyn
Novice


Joined: 24 Mar 2003
Posts: 44
Location: USA

PostPosted: Wed Mar 26, 2003 5:16 am   
 
try it with only the direction name in quotes.

%if(@rundir="east", west, %null)
Reply with quote
Kjata
GURU


Joined: 10 Oct 2000
Posts: 4379
Location: USA

PostPosted: Wed Mar 26, 2003 1:19 pm   
 
What you need is not the %if function, but the #IF command. As it is right now, the script will send a blank line to the MUD for every condition that fails. It is normally good habit to start every line of script in zMUD with either a zMUD command, a MUD command, or an alias. You also need to make the change Wrudyn suggested. At the end, your script should be:
#EXEC {@rundir}
#WAIT 5000
#IF (@rundir = "east") {west}
#IF (@rundir = "northeast") {southwest}
#IF (@rundir = "southeast") {northwest}
#IF (@rundir = "west") {east}
#IF (@rundir = "southwest") {notheast}
#IF (@rundir = "southwest") {northeast}
#IF (@rundir = "south") {north}
#IF (@rundir = "north") {east}

The script would be slightly more efficient if the #IF's were nested, but it would not make a big difference and you might want to keep it that way to make it easier to read. Also, I left the #WAIT that you have in there but you should try reading up on the problems that #WAIT has and alternative solutions to using it. There is an article about this posted in the Support Library.


Kjata
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