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
dazed-n-confused999
Wanderer


Joined: 03 Aug 2004
Posts: 79

PostPosted: Thu Oct 20, 2005 3:53 pm   

multi-variable nested #if HELP!!!
 
What im looking for here is a script that will take into account more than one variable, and decide what to do based on a priority system. Im trying the nested if statement below but its giving me nothing but grief.

What its suppose to do is check for defences, which happens all at once fyi. then based on if they have def1,def2,def3, or def4, it chooses the proper attack. So if they have def1 it should stop there and issue attack1. if no def1, but def2 then it should stop there and issue attack2, ect.

Im not sure if its because im not using a common variable and zmud is having problems with that, or that i forgot a bracket or something mundane like that. Im using version 7.13. If I could solve the problem above, it would help me on so many levels in my gaming experience, I havent come to you guys after a 30 minuet attempt and giving up. Ive been kicking this around cussing ect. for over a year now. If there is anyway someone help close this problem once and for all. pretty please. with sugar on top.



#IF (@def1 = 1) {attack1}{#if (@def2 = 1) {attack2}{#if (@def3 = 1) {attack3}{#if (@def4 = 1) {attack4}}}}


is this even close to what i need to be doing?!!?
Reply with quote
darmir
Sorcerer


Joined: 10 Oct 2000
Posts: 706
Location: USA

PostPosted: Thu Oct 20, 2005 5:22 pm   
 
First thing I would do is upgrade to the lastest verision of zmud. I think there was some issues with nested if's if prior versions of zmud.
_________________
Run as hard as a wild beast if you will, but you won't get any reward greater than that destined for you.
Source: (Egyptian)
Reply with quote
Tech
GURU


Joined: 18 Oct 2000
Posts: 2733
Location: Atlanta, USA

PostPosted: Thu Oct 20, 2005 6:53 pm   
 
The issue your having is with spacing. A quirk of the editor I think.
You have
Code:
#IF (@def1 = 1) {attack1}{#if (@def2 = 1) {attack2}{#if (@def3 = 1) {attack3}{#if (@def4 = 1) {attack4}}}}

when you need
Code:
#IF (@def1 == 1) {attack1} {#if (@def2 == 1) {attack2} {#if (@def3 == 1) {attack3} {#if (@def4 == 1) {attack4}}}}

for it to work.

If you can map def1-4 to integer numbers then you can use the #CASE command as well.. It may make your code more elegant.
_________________
Asati di tempari!
Reply with quote
dazed-n-confused999
Wanderer


Joined: 03 Aug 2004
Posts: 79

PostPosted: Fri Oct 21, 2005 2:27 am   
 
OMG, that works like a charm. Guess I never asked the right question. Well thanks a ton man.
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