|
Kyote Novice
Joined: 13 Jan 2002 Posts: 36 Location: USA
|
Posted: Sat Jan 19, 2002 1:53 am
string list and #IF help please? |
A few days ago I posted this
http://www.zuggsoft.com/forum/topic.asp?TOPIC_ID=5177&FORUM_ID=7&CAT_ID=1&Topic_Title=String+list%3F%3F%3F&Forum_Title=zMUD+General+Discussion
And one of the responses that solved my problem was this;
#var list {armor|shield|sanctuary|protection good}
#alias spellup {#t+ Spellup;#var templist @list;castcurr}
#alias castcurr {#var currspell %item(@templist, 1);cast '@currspell'} "Spellup"
#trigger {^You lost your concentration!} {cast '@currspell'} "Spellup"
#trigger {^You cast {@list}} {#delitem templist @currspell;#if (@templist) {castcurr} {#say SpellUp Done!;#t- Spellup}} "Spellup"
Now, I've fiddled with it a bit and I think I'm making a bit of progress on learning this. But I can't figure out the last line. I mean I understand the trigger catches 'you cast @list' meaning the spell that was just cast. Then the delitem takes that spell out of the templist variable. Now, here's where I'm having trouble fully understanding. The #if @templist doesn't have anything it's being compared against, yet it has a true and false condition!! Wouldn't the @templist always be true? Could someone please explain it a bit for me? I mean, it's not being compared against anything.... It seems to me that it's just checking to see if it exists, which it does.... I mean, I know this can't be whats happening from the way it works. It goes through my string list casting each spell in turn and removing each from the @templist Variable, then when it's done with the last it activated the false statement. But I can't see why it does so...
---------------------
Kyote
Happiness isn't a destination. It's a way of life!!! In other words... Don't live until you can be happy... Be happy while you live!!!! |
|
|
|
Vijilante SubAdmin
Joined: 18 Nov 2001 Posts: 5182
|
Posted: Sat Jan 19, 2002 4:11 am |
%null, "", and 0 are considered false. Everything else is true. So when templist becomes empty by having all the items deleted the if considers it to be false. It is a programming shorthand.
|
|
|
|
Kyote Novice
Joined: 13 Jan 2002 Posts: 36 Location: USA
|
Posted: Sat Jan 19, 2002 4:47 am |
Ahhh!!!! Thanks Vijilante!!!! Now it makes sense. :) Thanks for your time!
---------------------
Kyote
Happiness isn't a destination. It's a way of life!!! In other words... Don't live until you can be happy... Be happy while you live!!!! |
|
|
|
|
|
|
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
|
|