Register to post in forums, or Log in to your existing account
 

Play RetroMUD
Post new topic  Reply to topic     Home » Forums » CMUD General Discussion
harley
Apprentice


Joined: 05 Apr 2008
Posts: 121

PostPosted: Thu May 29, 2008 8:05 am   

help cleaning up an alias..
 
below is an alias i use sometimes..
Its ugly and i dont like it, but it works.. Any ideas on cleaning it up
the #says are for debugging purpose only.. not really needed anymore.
Code:
#say 1
    #say {Curr Area = @AreaSwitchDB.CurrentAreaNumber}
    #if (@AreaSwitchDB.CurrentAreaNumber = 1) {#say 2
      #exec {@AreaSwitchDB.walk1}
      #show 2.1
      #say Activate window
      #say 2.2
      #Alarm Switcharea +3 {#T+ {Test|Trigger}
      #say 2.3
      #exec {@AreaSwitchDB.path1}
      #say 2.4}} {
    #if (@AreaSwitchDB.CurrentAreaNumber = 2) {#say 3
      #exec {@AreaSwitchDB.walk2}
      #show 3.1
      #say Activate window
      #say 3.2
      #Alarm Switcharea +3 {#T+ {Test|Trigger}
      #say 3.3
      #exec {@AreaSwitchDB.path2}
      #say 3.4}} {
    #if (@AreaSwitchDB.CurrentAreaNumber = 3) {#say 4
      #exec {@AreaSwitchDB.walk3}
      #show 4.1
      #say Activate window
      #say 4.2
      #Alarm Switcharea +3 {#T+ {Test|Trigger}
      #say 4.3
      #exec {@AreaSwitchDB.path3}
      #say 4.4}} {
    #if (@AreaSwitchDB.CurrentAreaNumber = 4) {#say 5
      #exec {@AreaSwitchDB.walk4}
      #show 5.1
      #say Activate window
      #say 5.2
      #Alarm Switcharea +3 {#T+ {Test|Trigger}
      #say 5.3
      #exec {@AreaSwitchDB.path4}
      #say 5.4}} {
    #if (@AreaSwitchDB.CurrentAreaNumber = 5) {#say 6
      #exec {@AreaSwitchDB.walk5}
      #show 6.1
      #say Activate window
      #say 6.2
      #Alarm Switcharea +3 {#T+ {Test|Trigger}
      #say 6.3
      #exec {@AreaSwitchDB.path5}
      #say 6.4}} {
    #if (@AreaSwitchDB.CurrentAreaNumber = 6) {
      #exec {@AreaSwitchDB.walk6}
      #show 7.1
      #say Activate window
      #say 7.2
      #Alarm Switcharea +3 {#T+ {Test|Trigger}
      #say 7.3
      #exec {@AreaSwitchDB.path6}
      #say 7.4}} {
    #if (@AreaSwitchDB.CurrentAreaNumber = 7) {#say 8
      #exec {@AreaSwitchDB.walk5}
      #show 8.1
      #say Activate window
      #say 8.2
      #Alarm Switcharea +3 {#T+ {Test|Trigger}
      #say 8.3
      #exec {@AreaSwitchDB.path5}
      #say 8.4}} {
    #if (@AreaSwitchDB.CurrentAreaNumber = 8) {#say 9
      #exec {@AreaSwitchDB.walk5}
      #show 9.1
      #say Activate window
      #say 9.2
      #Alarm Switcharea +3 {#T+ {Test|Trigger}
      #say 9.3
      #exec {@AreaSwitchDB.path5}
      #say 9.4}} {
      }}}}}}}}
Reply with quote
Fang Xianfu
GURU


Joined: 26 Jan 2004
Posts: 5155
Location: United Kingdom

PostPosted: Thu May 29, 2008 8:14 am   
 
Something like:

#call @AreaSwitchDBFunc(@AreaSwitchDB.CurrentAreaNumber)

#func AreaSwitchDBFunc($num) {#say $num;#exec %db(@AreaSwitchDB,%concat("walk",$num));#say %concat($num,".1");#say Activate Window;#say %concat($num,".2");#alarm SwitchArea +3 {#t+ {Test|Trigger};#say %concat($num,".3");#exec %db(@AreaSwitchDB,%concat("path",$num));#say %concat($num,".4")}}


I haven't tested this, but hopefully it demonstrates the idea.
_________________
Rorso's syntax colouriser.

- Happy bunny is happy! (1/25)
Reply with quote
Display posts from previous:   
Post new topic   Reply to topic     Home » Forums » CMUD 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