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


Joined: 25 Mar 2003
Posts: 18

PostPosted: Sat Apr 02, 2005 8:55 am   

Problems using #forall/#loop
 
Hi,

I'm trying to use forall or loop in a context that my variables actually have a number ending w/ a number corresponding, um hard to descript but heres the code:
Code:

#FORALL @total_mobs {
  #IF (@monster%i > 0) {
    @attack @mob_nameTi
    #ADD monster%i -1
    #ABORT
    }
  }


what happens is it will send @attack and what ever reapeat its on so @attack 10 for the 10th loop, any way to use forall/loop in this context or do i just need to create triggs for each?

THanks
Josh
Reply with quote
Theragil
Apprentice


Joined: 13 Feb 2004
Posts: 157
Location: USA

PostPosted: Sat Apr 02, 2005 1:25 pm   
 
Try referring to your variable as @{monster%i}.
Reply with quote
Indica
Beginner


Joined: 25 Mar 2003
Posts: 18

PostPosted: Sat Apr 02, 2005 7:43 pm   
 
well i see whats basically happening now is this

#LOOP 1,10 {@mob_name%i}
instead of interpreting thevariable w/ the %i on the end it interprets the variable @mob_name and then the %i so it send @mob_name and then the %i to the mud....

i've tried @(mob_name%i) but thats not valide in zmud, i've tried @mob_name(%i), @mob_name%(i), (@mob_name%i)

Anyway for it to put the %i in before it interprets the variable?
Reply with quote
nexela
Wizard


Joined: 15 Jan 2002
Posts: 1644
Location: USA

PostPosted: Sat Apr 02, 2005 8:31 pm   
 
#EXECUTE @attack
_________________
Zmud Support Library
Zmud Knowledge Base
Reply with quote
Indica
Beginner


Joined: 25 Mar 2003
Posts: 18

PostPosted: Sat Apr 02, 2005 9:06 pm   
 
using this
#LOOP 1,10 {#EXECUTE @mob_name%i}

it still interprets the var then the %i, is what i want just not possible???
Reply with quote
nexela
Wizard


Joined: 15 Jan 2002
Posts: 1644
Location: USA

PostPosted: Sat Apr 02, 2005 9:35 pm   
 
#LOOP 1,10 {#EXECUTE @{mob_name%i}}
_________________
Zmud Support Library
Zmud Knowledge Base
Reply with quote
Theragil
Apprentice


Joined: 13 Feb 2004
Posts: 157
Location: USA

PostPosted: Mon Apr 04, 2005 12:44 pm   
 
Actually I think @attack @{mob_name%i} should work. You tried parentheses and stuff, but it's curly brackets you need like I replied originally. The #exec probably isn't needed, but it can't hurt.

#send might be even better if @attack doesn't point to an alias, though #send is a little wonky when it gets multiple parameters, so you need to futz about with %concat() and maybe %eval(). But the advantage is it doesn't echo even if you have things set to echo, so it's good to avoid spam without making your logs useless.

(Aside: we so need to be able to gag things from the screen but not the log!
Reply with quote
nexela
Wizard


Joined: 15 Jan 2002
Posts: 1644
Location: USA

PostPosted: Mon Apr 04, 2005 7:18 pm   
 
Quote:
#send is a little wonky when it gets multiple parameters, so you need to futz about with %concat() and maybe %eval().


Have you tried #SEND {multiple paramaters}
_________________
Zmud Support Library
Zmud Knowledge Base
Reply with quote
Theragil
Apprentice


Joined: 13 Feb 2004
Posts: 157
Location: USA

PostPosted: Mon Apr 04, 2005 8:47 pm   
 
There's a few ways to do it, that's one of them. Just don't think the OP wants to mess with that right now.
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