|
Ralph1971 Wanderer
Joined: 01 Mar 2008 Posts: 64
|
Posted: Tue Apr 19, 2011 1:19 pm
ismember |
I have the following code, and works great in zmud, tried to cut/paste into cmud, and recieve an error "invalid function: ismember".. went to the help files for cmud, and it appears I'm using the correct syntax.. any ideas?
Code: |
#class {dig}
#alias dig {digdirection=%1;#if (%ismember(%1,@dirlist)) {~dig @direction} {~dig}}
|
|
|
|
|
shalimar GURU
Joined: 04 Aug 2002 Posts: 4715 Location: Pensacola, FL, USA
|
Posted: Tue Apr 19, 2011 2:42 pm |
looks good to me.... does it fail in an empty session as well?
might just be a corrupted package file |
|
_________________ Discord: Shalimarwildcat |
|
|
|
Ralph1971 Wanderer
Joined: 01 Mar 2008 Posts: 64
|
Posted: Tue Apr 19, 2011 3:01 pm |
hmm.. have to try that..
along those lines, how can I rip apart a script and make parts of it stand alone packages? in the above script snip, a 'dig' package, another package with alias' and #paths for directions "paths", etc..
I have a main script where I have alot of that in one big on, but some chars don't need some things that others do (namely class specific stuff).. |
|
_________________ Win7-home - Cmud 3.33a
WinXP-pro - Zmud 7.21 |
|
|
|
shalimar GURU
Joined: 04 Aug 2002 Posts: 4715 Location: Pensacola, FL, USA
|
Posted: Tue Apr 19, 2011 3:42 pm |
in the settings edior under files, create new Package... then drag the scripts you want over to it
|
|
_________________ Discord: Shalimarwildcat |
|
|
|
Ralph1971 Wanderer
Joined: 01 Mar 2008 Posts: 64
|
Posted: Tue Apr 19, 2011 3:51 pm |
awesome.. thanks..
new issue with the script..
Code: |
#class {dig}
#var digdirection {N|E|S|W|NE|SE|NW|SW|D|U}
#alias dig($digdir) {#if (%ismember($digdir,@digdirection) {~dig $digdir} {~dig}
#trigger {Your dig uncovered nothing} {~dig}
#trigger {Your dig did not discover any exit...} {~dig $digdir}
|
it works if there's no parameter (basic dig), but when I try to dig a direction, I recieve the "your dig did not discover" line, and then a message:
ERROR: Trigger "Your dig did not discover any exit..." fired but did not compile. |
|
|
|
shalimar GURU
Joined: 04 Aug 2002 Posts: 4715 Location: Pensacola, FL, USA
|
Posted: Tue Apr 19, 2011 3:58 pm |
thats cause you are using an undefined local variable in that trigger
local variables only live as long as the script using it is running, so if you plan to use $digdir in another trigger, make it a regular variable |
|
_________________ Discord: Shalimarwildcat |
|
|
|
Ralph1971 Wanderer
Joined: 01 Mar 2008 Posts: 64
|
Posted: Tue Apr 19, 2011 4:11 pm |
Ok.. changed to:
Code: |
digdir=%1
#alias dig (#if (%ismember(@digdir,@digdirection)) {~dig @digdir} {~dig}
|
and now, I get a
Syntax error in Alias: dig : illegal character in expression: {
I haven't re-defined any characters, tokens, anything..
appreciate the help, Shalimar.. once I can wrap my noggin around a few of these, it'll get easier.... |
|
_________________ Win7-home - Cmud 3.33a
WinXP-pro - Zmud 7.21 |
|
|
|
Zugg MASTER
Joined: 25 Sep 2000 Posts: 23379 Location: Colorado, USA
|
Posted: Tue Apr 19, 2011 4:22 pm |
This is because you need to put {} around the alias definition and you want to assign your variable within the alias. Your code should be:
Code: |
#alias dig {digdir=%1;#if (%ismember(@digdir,@digdirection)) {~dig @digdir} {~dig}} |
|
|
|
|
|
|