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
shalimar
GURU


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

PostPosted: 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
Reply with quote
Vorax
Apprentice


Joined: 29 Jun 2001
Posts: 198
Location: USA

PostPosted: 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.
Reply with quote
shalimar
GURU


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

PostPosted: 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
Reply with quote
Vorax
Apprentice


Joined: 29 Jun 2001
Posts: 198
Location: USA

PostPosted: 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.
_________________
Implementor at House of Ghouls
Telnet to House of Ghouls
Reply with quote
Theragil
Apprentice


Joined: 13 Feb 2004
Posts: 157
Location: USA

PostPosted: 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.
Reply with quote
Vorax
Apprentice


Joined: 29 Jun 2001
Posts: 198
Location: USA

PostPosted: 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?
_________________
Implementor at House of Ghouls
Telnet to House of Ghouls
Reply with quote
Vijilante
SubAdmin


Joined: 18 Nov 2001
Posts: 5182

PostPosted: 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
Reply with quote
nexela
Wizard


Joined: 15 Jan 2002
Posts: 1644
Location: USA

PostPosted: 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
_________________
Zmud Support Library
Zmud Knowledge Base
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