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


Joined: 08 Apr 2004
Posts: 103
Location: USA

PostPosted: Thu Jan 24, 2008 3:54 am   

Variables changing other variables.
 
Alright, I have a variable for @item. It could be moss, valerian, cohosh, etc...
I am trying to make a trigger to read that

#if (@item > 0 and @picking = 1) {pick cohosh}

The problem is I want the @item to be judging whatever herb that is in question...
So lets say @item = cohosh

#if (@item(cohosh) > 0 and @picking = 1) {pick cohosh}

Thanks for your help folks!
Reply with quote
Arminas
Wizard


Joined: 11 Jul 2002
Posts: 1265
Location: USA

PostPosted: Thu Jan 24, 2008 4:21 am   
 
It sounds like you want a database variable.

VarName:Herbs
Value
cohosh=12
valerian=1
moss=3
Code:
#addkey Herbs cohosh 12
#addkey Herbs valerian 1
#addkey Herbs moss 3

VarName:item
Value:cohosh
Code:
#var item cohosh

Code:
#show You want to pick @{Herbs.@item} @item.

Displays:You want to pick 12 cohosh.
Code:
#var picking 1

Code:
#if (@{Herbs.@item} > 0 and @picking = 1) {pick @item}
_________________
Arminas, The Invisible horseman
Windows 7 Pro 32 bit
AMD 64 X2 2.51 Dual Core, 2 GB of Ram

Last edited by Arminas on Thu Jan 24, 2008 4:29 am; edited 1 time in total
Reply with quote
shalimar
GURU


Joined: 04 Aug 2002
Posts: 4782
Location: Pensacola, FL, USA

PostPosted: Thu Jan 24, 2008 4:24 am   
 
You could try

#IF (@item and @picking=1) {pick @item}

then its just checking to make sure @item has a non 0 value


Unless I am misunderstanding your intent.
_________________
Discord server
Reply with quote
Fang Xianfu
GURU


Joined: 26 Jan 2004
Posts: 5155
Location: United Kingdom

PostPosted: Thu Jan 24, 2008 9:56 am   
 
I think the idea is that @item would contain the string "cohosh" and @cohosh will contain a number. In that case, you can use @{@item} to access the value of @cohosh. However, I really would advise doing it Arminas' way - it's neater, probably faster, and makes for more readable code.
_________________
Rorso's syntax colouriser.

- Happy bunny is happy! (1/25)
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