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


Joined: 30 Oct 2004
Posts: 127

PostPosted: Mon Jul 24, 2006 10:30 pm   

Array Accessing.
 
Currently in my system I have:

#If (@stupidity = 1) {eat goldenseal}
#if (@dizziness = 1) {eat goldenseal}

Stuff like that.

I have many variables that could be linked and processed at the same time. I'm wondering if there's a way to do multiple checks on the same variable, like:

GlobalVariable contains all afflictions, the first 10 of which are goldenseal afflictions.

Soooo is there anything like this that would work?

#if (@GlobalVariable.[0-9] = 1) {eat goldenseal}
Reply with quote
Taz
GURU


Joined: 28 Sep 2000
Posts: 1395
Location: United Kingdom

PostPosted: Mon Jul 24, 2006 10:39 pm   
 
#loop 0,9 {#if (@globalvariable.%i = 1) {eat goldenseal}}

probably won't work since the 0 probably won't do anything. 1,10 won't work cause you get the wrong numbers.

Try

#loop 1,10 {#if (@globalvariable.%eval(%i - 1) = 1) {eat goldenseal}}
or
#loop 1,10 {#if (@globalvariable.{%eval(%i - 1)} = 1) {eat goldenseal}}
_________________
Taz :)

Last edited by Taz on Mon Jul 24, 2006 10:44 pm; edited 1 time in total
Reply with quote
talonnb
Apprentice


Joined: 30 Oct 2004
Posts: 127

PostPosted: Mon Jul 24, 2006 10:43 pm   
 
I'll give it a try once I get the global variable all set up, appreciate the help.
Reply with quote
Taz
GURU


Joined: 28 Sep 2000
Posts: 1395
Location: United Kingdom

PostPosted: Mon Jul 24, 2006 10:51 pm   
 
Scrub all the extra stuff I put it seems that 0,9 will work perfectly. Oh and note the edit I did to change %1 to %i, very important.
_________________
Taz :)
Reply with quote
shalimar
GURU


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

PostPosted: Mon Jul 24, 2006 11:49 pm   
 
try a case statment with %ismember() for the number, it will return which possition the item is located in the array
_________________
Discord: Shalimarwildcat
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