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


Joined: 09 Jun 2002
Posts: 15
Location: Norway

PostPosted: Sun Jun 09, 2002 8:13 pm   

Getting characters from a variable
 
I've run into an issue where I've got problems, and I've read the helpfile, but still can't figure this one out:
I've got the following variables.
Status
Statequilibrium
Statbalance

The Status variables keeps getting characters in it, but never more than one occurance of each (from a to z only). They aren't necessary in alphabetical order.
What I would like to to is to trigger if I find a certain character in the variable, but I can't figure out how to see if that character is there.
This is what I've tried:
Trigger: (%a)h, (%a)m (%a)
Value: health=%1
mana=%2
status=%3
#IF {@status="?e",@statequilibrium=1,@statequilibrium=0}
#IF {@status="*d",@statdiffusion=1,@statdiffusion=0}

The status variable can for an example have "dey" in it, where "e" is equilibrium. I don't want anything to happen while e is not there...

Can you help me please?

Many thanks


Best regards,

Dragonheart
Reply with quote
TonDiening
GURU


Joined: 26 Jul 2001
Posts: 1958
Location: Canada

PostPosted: Sun Jun 09, 2002 9:03 pm   
 
#IF {@status="?e",@statequilibrium=1,@statequilibrium=0}
#IF {@status="*d",@statdiffusion=1,@statdiffusion=0}

Is kinda in the %if the function syntax.

How about something like:

#IF (%pos("e",@Status) > 0) {@statequilibrium=1} {@statequilibrium=0}
#IF (%pos("d",@Status) > 0) {@statdiffusion=1} {@statdiffusion=0}

TonDiening
Beta Upgrading to 6.26

Fixed 12 minutes later to make me look smarter. Corrected my #IF () {} {} as dacheeba's
message
Reply with quote
dacheeba
Adept


Joined: 29 Oct 2001
Posts: 250

PostPosted: Sun Jun 09, 2002 9:04 pm   
 
kind of confusing,because the syntax you use for #IF is really the syntax for %if, but whatever. :)

Trigger:
(%a)h, (%a)m (%a)
Value:
health=%1
mana=%2
status=%3
#IF (%pos(e,@status)) {statequilibrium=1} {statequilibrium=0}
#IF (%pos(d,@status)) {statdiffusion=1} {statdiffusion=0}


That will do it
Reply with quote
dacheeba
Adept


Joined: 29 Oct 2001
Posts: 250

PostPosted: Sun Jun 09, 2002 9:06 pm   
 
Curse you TonDiening!50 seconds to slow :(

Heh, just goes to show great minds think alike(some faster than others however :P)
Reply with quote
LightBulb
MASTER


Joined: 28 Nov 2000
Posts: 4817
Location: USA

PostPosted: Sun Jun 09, 2002 9:06 pm   
 
You can use the %pos function for this, either directly or as a comparison.
Also, it's important to use the correct syntax for the #IF command, it's not identical to the %if function.
I've always preferred to test parameters from aliases and triggers directly, rather than store them to a variable and then test the variable.
#IF (%pos(e,@status) > 0) {statequilibrium=1} {statequilibrium=0}
#IF (%pos(d,%3)) {statdiffusion=1} {statdiffusion=0}


LightBulb
Vague questions get vague answers
Heh, we all seem agreed that %pos is the answer
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