|
shalimar GURU
Joined: 04 Aug 2002 Posts: 4690 Location: Pensacola, FL, USA
|
Posted: Fri Oct 29, 2004 8:10 pm
Easier way to do a true case other than nested if? |
#TRIGGER {That won't fit in your black rabuhide hunting sack.} {
#IF (@store ~= "first sack") {#var store {second sack}} {#IF (@store ~= "second sack") {#var store {third sack}} {#IF (@store ~= "third sack") {#var store {fourth sack}} {#IF (@store ~= "fourth sack") {#var store {fifth sack}} {#IF (@store ~= "fifth sack") {#var store {first sack}}}}}}
put @feed in my @store
col @feed
}
This is my attempt, though for some reason @store never incriments to the next value |
|
_________________ Discord: Shalimarwildcat |
|
|
|
Vorax Apprentice
Joined: 29 Jun 2001 Posts: 198 Location: USA
|
Posted: Fri Oct 29, 2004 8:27 pm |
Code: |
#TRIGGER {That won't fit in your black rabuhide hunting sack.} {
#IF (@store = "first sack") {#var store {second sack}} {
#IF (@store = "second sack") {#var store {third sack}} {
#IF (@store = "third sack") {#var store {fourth sack}} {
#IF (@store = "fourth sack") {#var store {fifth sack}} {
#IF (@store = "fifth sack") {#var store {first sack}} {
#NOOP
}
}
}
}
}
put @feed in my @store
col @feed
} |
Tested. Worked. |
|
|
|
shalimar GURU
Joined: 04 Aug 2002 Posts: 4690 Location: Pensacola, FL, USA
|
Posted: Fri Oct 29, 2004 8:45 pm |
odd, i had tried just an = and an == in there instead of the ~= and it never worked for me, is the #NOOP really that required?
|
|
_________________ Discord: Shalimarwildcat |
|
|
|
Vorax Apprentice
Joined: 29 Jun 2001 Posts: 198 Location: USA
|
Posted: Fri Oct 29, 2004 8:59 pm |
I don't believe it is required, but I always like to fill in the false condition of IF statments.
|
|
|
|
Theragil Apprentice
Joined: 13 Feb 2004 Posts: 157 Location: USA
|
Posted: Sat Oct 30, 2004 11:01 pm |
To avoid all that indenting (nice for five, ugly for fifty cases) you could use this kluge someone else just posted:
Code: |
#alias abortcmd ""
#if (first case) {do something;#alias abortcmd {#abort}}
abortcmd
#if (second case) {do something else;#alias abortcmd {#abort}}
abortcmd
#if (third case) {do something different;#alias abortcmd {#abort}}
abortcmd
|
The #alias abortcmd {#abort} part works kind of like break; in a C case block. |
|
|
|
Vorax Apprentice
Joined: 29 Jun 2001 Posts: 198 Location: USA
|
Posted: Sat Oct 30, 2004 11:54 pm |
I don't understand why the alias would have to be defined every time in order to be executed. Is there a reason for that?
|
|
|
|
Vijilante SubAdmin
Joined: 18 Nov 2001 Posts: 5182
|
Posted: Sun Oct 31, 2004 1:02 am |
Yeah because it is defined as null in the beginning. Then called after each #IF. By defining it within the #IF it then becomes a functional #ABORT. However it still shouldn't technically work, but does. This would likely be considered a work-around and may not function the same in future versions.
|
|
_________________ The only good questions are the ones we have never answered before.
Search the Forums |
|
|
|
nexela Wizard
Joined: 15 Jan 2002 Posts: 1644 Location: USA
|
Posted: Sun Oct 31, 2004 3:19 am |
Ya know there is the #CASE command simple example below
#TRIGGER {That won't fit in your black rabuhide hunting sack.} {
#IF (@sackNum>=5) {#VAR sackNum 1} {#ADD sackNum 1}
#CASE @sackNum {put @feed my first sack;col @feed} {put @feed my second sack;col @feed} {third} {fourth} {fifth} {#Noop leave this at end}
}
Just change the >=5 to >=Max num of bags and add the {} cases before the {#noop} one |
|
|
|
|
|