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


Joined: 25 Mar 2003
Posts: 2

PostPosted: Tue Mar 25, 2003 10:21 pm   

How to use a list and push/pop
 
Hi there I hope someone can help me out :)
I seem to have trouble with using lists. I'll short tell what I want to do, and what I've done sofar

btw im using Zmud6.40

..Ok what I want to do:
When i flee from a mob, it'll make me move two rooms. What I want to do is just walking back to the mob again, so if I flee north and west, I want to walk east and south to get back to the mob.
(That is when I have healed myself but that is not the problem atm)

..What I've done sofar:
I "pushed" the 2 directions into a list, I'm using push and a list because for example if I flee 'north' and 'west', I'm storing 'south' and 'east' in the list, when I want to go back to the mob I first have to "pop" 'east' and after that 'north'.

The things that I've done sofar is:
1. I created an empty variable FleeDir
2. when I flee east I push 'east' in the list with the command:
%push(@FleeDir, "east")
3. the same thing for north south west
4. with a test command I try to pop the two directions from the list with the commands:
%pop(FleeDir)
%pop(FleeDir)

5.and well uh it does nothing :P

Wonder what i'm doin wrong
I hope someone can help me out with this, thanks in advance!
Reply with quote
AzCowboy
Adept


Joined: 09 Nov 2000
Posts: 222
Location: USA

PostPosted: Tue Mar 25, 2003 11:43 pm   
 
%functions() are NOT meant to be used as a command. They are ARGUMENTS for OTHER commands. Try something like:

#var dir %pop(FleeDir)
@dir
#var dir %pop(FleeDir)
@dir


There are other ways to do this, as well..
Reply with quote
TonDiening
GURU


Joined: 26 Jul 2001
Posts: 1958
Location: Canada

PostPosted: Wed Mar 26, 2003 1:38 am   
 
quote:

push

Syntax: %push(item,list)
Adds the item to the beginning of the list, and returns the new list.
Example:

List="a|b|c"
#SHOW %pop(List)
displays "a"
#SHOW @List
displays "b|c"
List=%push("a",@List)
display "a|b|c"



From the example, change the syntax of when you push.
#VAR FleeDir %push("east",@FleeDir)

Then you should be able to retrace with
%pop(FleeDir)
%pop(FleeDir)

Ton Diening
Reply with quote
misty
Newbie


Joined: 25 Mar 2003
Posts: 2

PostPosted: Tue Apr 01, 2003 12:48 am   
 
Ooh I see the syntax of the pushing was wrong. I used the info of pushing from the support section on this site. Guess they tried to fool me ;) hehe
Wasn't able to try it last few days just got back, but it works now!
Thanks alot AzCowboy and TonDiening really appreciate it!
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