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
doomfyre
Apprentice


Joined: 03 Jan 2002
Posts: 152
Location: USA

PostPosted: Sat Feb 16, 2002 8:19 pm   

#VAR
 
I want to understand this once and for all. I've seen it written a couple different ways on here. I just want to know the proper way to store multiple items in a variable.

I tend to use the editor for everything, rather than the command line.

so, to store the various types of food for an auto eat trigger.

#TR {You are STARVING} {get @food sack; eat @food}

ok, in the var screen, Name would of course be food.

in the value field, whats the correct way to enter the various types? for instance, meat, mushroom, etc?
Reply with quote
MattLofton
GURU


Joined: 23 Dec 2000
Posts: 4834
Location: USA

PostPosted: Sat Feb 16, 2002 8:33 pm   
 
quote:

I want to understand this once and for all. I've seen it written a couple different ways on here. I just want to know the proper way to store multiple items in a variable.

I tend to use the editor for everything, rather than the command line.

so, to store the various types of food for an auto eat trigger.

#TR {You are STARVING} {get @food sack; eat @food}

ok, in the var screen, Name would of course be food.

in the value field, whats the correct way to enter the various types? for instance, meat, mushroom, etc?



If you notice, with a variable selected the editor will give you 4 tabs to choose from. For lists, you want to click on the stringlist tab. Record is similar to String List, except that you can assign values to each element in the list.

string list
cat
dog
mouse

data record
cat = 2
dog = 1
mouse = 0

Text should be obvious, and Script is there to handle functions (anything like %ansi() or @RollMoreDice(), since the latter cannot handle #commands).

EDIT: The above is how to do it properly from the editor, which isn't always possible to do (especially if you're cutting and pasting). To enter a string list in text mode, you can do it like this:

cat|dog|mouse

each element must be separated by the pipe symbol (|), and ZMud will convert that when needed automatically.

li'l shmoe of Dragon's Gate MUD
Reply with quote
doomfyre
Apprentice


Joined: 03 Jan 2002
Posts: 152
Location: USA

PostPosted: Sat Feb 16, 2002 11:32 pm   
 
my problem is, when i enter the items in the string list, when the trigger fires, it sends:

get meat|mushroom|eyeball sack
eat meat|mushroom|eyeball

then:

i see nothing like that in the sack.
Reply with quote
Troubadour
GURU


Joined: 14 Oct 2000
Posts: 556
Location: USA

PostPosted: Sun Feb 17, 2002 4:38 am   
 
You must use the %item function to select individual items from the list. You might try this, but it is spammy:

#TR {You are STARVING} {#T+ get_food; count = 1; get %item(@food, @count) sack}

#CLASS {get_food}
#TR {i see nothing like that in the sack.} {#ADD count 1; #IF (@count <= %numitems(@food)) {get %item(@food, @count) sack} {#SAY You have no food!}
#TR {You get * from the sack.} {eat %item(@food, @count); #T- get_food}
#CLASS 0

Troubadour
Reply with quote
Kjata
GURU


Joined: 10 Oct 2000
Posts: 4379
Location: USA

PostPosted: Sun Feb 17, 2002 1:22 pm   
 
Yeha, what Troubadour said. You must remember that zMUD isn't a person, so you can't just tell zMUD to get either meat, mushroom, or eyeball (whichever one of those is present) from the sack. Especially if it is a command that is going to be sent to the MUD.

For another person, this may seem natural. You tell them to do that, and they know what to do. For a program, you must detail each step: 1) Look in the sack, 2) Determine if I have one of the three items I want, 3) If one of the items is found, get it and eat it.

Also, there is usually more than one way of doing stuff. For example, Troubadour's script would be like: 1) Try to get the first item from the list, 2) If the item is retrieved, eat it; do not continue, 3) If can't get the first item, check to see if there are more items in the list, 4) If there are more items, try to get next item from the list, 5) If there are no more items, give error saying that none of the items were found, 6) If the item is retrieved, eat it; do not continue, 7) If can't get the item, repeat 4 to 7 until item is gotten or there are no more items in the list.

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