veek Beginner
Joined: 28 Sep 2006 Posts: 21
|
Posted: Tue Nov 14, 2006 5:59 pm
Calling a ALIAS from another class and waiting for a REGEX. |
Any idea how i can call a ALIAS in WalkToRoom from HealByWiggly.
I cannot use WalkToRoom/Main (at least on the cmd line) because if WalkToRoom has variables with the same name as HealByWiggly then there is a clash..
Also, if i uncomment the second line it works but a little weirdly. The code does not pause for the #REGEX to match and set @room to the new Wiggly position! Instead it merrily runs along and takes the old value of @room! How do i prevent this. How do i first destroy all the old VARIABLE VALUE's and re-initialise them..
and then wait for the REGEX to complete - i don't want to use a DELAY.
I could use a while and check if room gets a integer?
#CLASS {WalkToRoom}
; Function to map a room name to a room number.
; Usage: ???
#VAR temp {}
#VAR roomNo {}
#ALIAS RoomDescToNo {
#VAR desc %1
#VAR descToNum %2
temp = %ismember(@desc,@descToNum)
#ADD temp 1
roomNo = %item(@descToNum,@temp)
}
#ALIAS Main {
#VAR room %1
descToNum = %2
#IF (%isnumber(@room)) {roomNo=@room; #WALK @roomNo;} {RoomDescToNo @room @descToNum; #WALK @roomNo;}
}
#CLASS 0
#CLASS {HealByWiggly}
#VAR temp {}
#VAR room {}
#VAR descToNumWiggly {the southeast corner of Kelish Square.|93|the south side of Kelish Square.|87|the southwest corner of Kelish Square.|88|the east side of Kelish Square.|92|Main Street|146}
#REGEX "getWigglyLoc" {^Father Wiggly tells you: I am at (.+)$} {#COLOR Blue; room = %1;}
#ALIAS LocateWiggly {
#VAR tellWiggly {"tell Wiggly Where are You?"}
#SEND @tellWiggly
; #CLASS WalkToRoom; Main @room @descToNumWiggly;
; WalkToRoom/Main @room @descToNumWiggly
}
#ALIAS GetWigglyToHealYou {
open pack
get 1 platinum coin from pack
close pack
give 1 platinum coin to Wiggly
}
#ALIAS Main {LocateWiggly;}
#CLASS 0 |
|