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
Ryltar Lizzle
Newbie


Joined: 05 Apr 2006
Posts: 4

PostPosted: Fri Apr 07, 2006 8:03 pm   

#vars not wanting to work for me
 
there maybe an ezer way to do this but I dunno it
but anyways heres what I got

#if {@eguard=1} {#var eguard 0;k elite guard}
#if {@eguard=0 and @guard=1} {#var guard 0;k guard}
#if {@eguard=0 and @guard=0 and @rat=1} {#var rat 0;k rat}
#if {@eguard=0 and @guard=0 and @rat=0 and @priest=1} {#var priest 0;kill priest}
#if {@eguard=0 and @guard=0 and @rat=0 and @priest=0 and @troll=1} {#var troll 0;k troll}
#if {@eguard=0 and @guard=0 and @rat=0 and @priest=0 and @troll=0 and @dwarf=1} {#var dwarf 0;k dwarf}
#if {@eguard=0 and @guard=0 and @rat=0 and @priest=0 and @troll=0 and @dwarf=0 and @gnome=1} {#var gnome 0;k gnome}
#if {@eguard=0 and @guard=0 and @rat=0 and @priest=0 and @troll=0 and @dwarf=0 and @gnome=0 and @prisoner=1} {#var prisoner 0;k prisoner}
#if {@eguard=0 and @guard=0 and @rat=0 and @priest=0 and @troll=0 and @dwarf=0 and @gnome=0 and @prisoner=0 and @trainee=1} {#var trainee 0;k trainee}
#if {@eguard=0 and @guard=0 and @rat=0 and @priest=0 and @troll=0 and @dwarf=0 and @gnome=0 and @prisoner=0 and @trainee=0 and @woman=1} {#var woman 0;k woman}
#if {@eguard=0 and @guard=0 and @rat=0 and @priest=0 and @troll=0 and @dwarf=0 and @gnome=0 and @prisoner=0 and @trainee=0 and @woman=0 and @baker=0 and @chef=1} {#var chef 0;k chef}
#if {@eguard=0 and @guard=0 and @rat=0 and @priest=0 and @troll=0 and @dwarf=0 and @gnome=0 and @prisoner=0 and @trainee=0 and @woman=0 and @baker=0 and @chef=0 and @cook=1} {#var cook 0;k cook}
#if {@eguard=0 and @guard=0 and @rat=0 and @priest=0 and @troll=0 and @dwarf=0 and @gnome=0 and @prisoner=0 and @trainee=0 and @woman=0 and @baker=0 and @chef=0 and @cook=0 and @orderly=1} {#var orderly 0;k orderly}
#if {@eguard=0 and @guard=0 and @rat=0 and @priest=0 and @troll=0 and @dwarf=0 and @gnome=0 and @prisoner=0 and @trainee=0 and @woman=0 and @baker=0 and @chef=0 and @cook=0 and @orderly=0 and @nurse=1} {#var nurse 0;k nurse}
#if {@eguard=0 and @guard=0 and @rat=0 and @priest=0 and @troll=0 and @dwarf=0 and @gnome=0 and @prisoner=0 and @trainee=0 and @woman=0 and @baker=0 and @chef=0 and @cook=0 and @orderly=0 and @nurse=0 and @servant=1} {#var servant 0;k servant}



It should(if it worked) allow me to attack mobs in a zone in a certin order
but of corse It doesn't wanna work for me I have triggers with all the mobs descr makeing the vars 1 and that part is working but its only1 attcking the first 2 eguard and guard

any ideas?
Reply with quote
Larkin
Wizard


Joined: 25 Mar 2003
Posts: 1113
Location: USA

PostPosted: Fri Apr 07, 2006 8:40 pm   
 
Try using the "else" part of the if statements.

Code:
#if (@eguard == 1) {eguard = 0;k elite guard} {#if (@guard == 1) {guard = 0;k guard} {#if (@rat == 1) {rat = 0;k rat} {and so on and so on...}}}


If you have more than one of any of these in the room, you should be doing "#add mobname -1" until you reach 0 and check for @mobname > 0 in your condition.
Reply with quote
Ryltar Lizzle
Newbie


Joined: 05 Apr 2006
Posts: 4

PostPosted: Mon Apr 10, 2006 6:39 am   
 
Would that attack anything thing in a room?

what does the == do?
Reply with quote
Guinn
Wizard


Joined: 03 Mar 2001
Posts: 1127
Location: London

PostPosted: Mon Apr 10, 2006 10:51 am   
 
== is the conventional syntax for an expression in an IF statement.
using a single = is for assigning a value to a variable.

For example if you had
testvar = 1
#show (@testvar == 1)

then it would show 'True'

I'm not sure of whether zmud does this or not (don't have it to hand to check), but if it doesn't then most likely Larkin was thinking of another language.
Reply with quote
Larkin
Wizard


Joined: 25 Mar 2003
Posts: 1113
Location: USA

PostPosted: Mon Apr 10, 2006 1:36 pm   
 
zMUD works just fine with the traditional == syntax, and I use it all the time. I prefer it because it's good practice for anyone to learn this if they ever might use a real scripting language. Many languages, especially C-like ones, will allow assignment inside an expression before evaluation takes place, and that's usually not the desired effect.

And, the script as I suggested it would attack the first match. If you find an elite guard, you'll kill that. Else, if you find a guard, you'll kill that. Etc, etc. The "else" clause in the "if" command is the key to simplicity.
Reply with quote
MattLofton
GURU


Joined: 23 Dec 2000
Posts: 4834
Location: USA

PostPosted: Mon Apr 10, 2006 8:38 pm   
 
ZMud completely ignores the == and simply refers to it as =. Dunno if this is going to change with CMud, but I sort of doubt it.
_________________
EDIT: I didn't like my old signature
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