|
PHLN Adept
Joined: 30 Dec 2001 Posts: 220 Location: Canada
|
Posted: Fri Sep 26, 2003 12:37 pm
Less than but greater than function... |
How would I have zMUD to accept less than X but greater than Y in my #IF function? I want to have #IF spirit is less than 10 but greater than 5 THEN etc...
|
|
|
|
PHLN Adept
Joined: 30 Dec 2001 Posts: 220 Location: Canada
|
Posted: Fri Sep 26, 2003 12:59 pm |
It seem zMUD doesn't support that function.. but I found a way to get around it.. Have it set to #IF @spirit/10=4 .. Since the real value I want is less than 50 but more than 40... Anyway, if anyone have a better solution.. please share.. =)
|
|
|
|
mr_kent Enchanter
Joined: 10 Oct 2000 Posts: 698
|
Posted: Fri Sep 26, 2003 2:39 pm |
quote: Originally posted by PHLN
It seem zMUD doesn't support that function.. but I found a way to get around it.. Have it set to #IF @spirit/10=4 .. Since the real value I want is less than 50 but more than 40... Anyway, if anyone have a better solution.. please share.. =)
#IF ((@spirit < 50) & (@spirit > 40) |
|
|
|
Talahaski Enchanter
Joined: 10 Oct 2000 Posts: 656 Location: USA
|
Posted: Fri Sep 26, 2003 4:07 pm |
There really is no need to support a BETWEEN or RANGE function since the same thing came be accomplished using 2 conditions AND together as MR Kent suggested.
#IF ((@spirit < 50) and (@spirit > 40)) |
|
|
|
PHLN Adept
Joined: 30 Dec 2001 Posts: 220 Location: Canada
|
Posted: Sat Sep 27, 2003 2:03 am |
Thanks
|
|
|
|
hatespyware Apprentice
Joined: 16 Dec 2002 Posts: 103
|
Posted: Sun Oct 26, 2003 5:23 pm |
quote: Originally posted by Talahaski
There really is no need to support a BETWEEN or RANGE function since the same thing came be accomplished using 2 conditions AND together as MR Kent suggested.
The reason most languages lack such a function is to resolve ambiguity in the order of comparison execution. |
|
|
|
PHLN Adept
Joined: 30 Dec 2001 Posts: 220 Location: Canada
|
Posted: Mon Oct 27, 2003 2:14 am |
I finnaly got around to update the trig, but it doesn't seem to work... I keep getting syntax error
#IF {(@spirit<50) and (@spirit>40)
announce Spirit is Low!
)
This is in the value field btw... |
|
|
|
PHLN Adept
Joined: 30 Dec 2001 Posts: 220 Location: Canada
|
Posted: Mon Oct 27, 2003 2:18 am |
Oh.. figured it out...
#IF ((@spirit<50) and (@spirit>40)) {
announce Spirit is Low!
} |
|
|
|
Rainchild Wizard
Joined: 10 Oct 2000 Posts: 1551 Location: Australia
|
Posted: Mon Oct 27, 2003 4:49 am |
Also (though this may be kinda hard to do it in zmud script) us programmers sometimes do stuff like:
if x < 10 then
announce "critically low"
else if x < 20 then
announce "moderately low"
else if x < 30 then
announce "low"
else if x < 40 then
etc etc
because you have the else's there, it's already done the previous test... the 'slow' way to write it (and the way it seems you have) is
if x > 0 and x < 10 then
announce "critically low"
if x > 10 and x < 20 then
announce "moderately low"
etc
also (you may have done this intentionally) but I was just going to bring it to your attention just in case...
x > 40 and x < 50 matches 41, 42, 43, 44, 45, 46, 47, 48, 49
x > 40 and x <= 50 matches 41, 42, 43, 44, 45, 46, 47, 48, 49, 50
x >= 40 and x < 50 matches 40, 41, 42, 43, 44, 45, 46, 47, 48, 49
x >= 40 and x <= 50 matches 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50
so currently you're only matching 41-49
something untested in zmud script would be...
Code: |
#IF (@spirit < 10) {
announce 0-9
} {
#IF (@spirit < 20) {
announce 10-19
} {
#IF (@spirit < 30) {
announce 20-29
} {
#IF (@spirit < 40) {
announce 30-39
} {
#IF (@spirit < 50) {
announce 40-49
} {
announce 50+
}
}
}
}
} |
So anyways, I might be barking up the wrong tree but thought I'd just mention a grounding of if's else's and alligators ;) |
|
|
|
PHLN Adept
Joined: 30 Dec 2001 Posts: 220 Location: Canada
|
Posted: Mon Oct 27, 2003 5:15 am |
Heh, I don't need anything that.. complicated.. =).. but thanks anyhow.. it look umm.. complicated... (meant it as a compliment)
|
|
|
|
|
|