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
TiberSeptim
Beginner


Joined: 20 Jun 2006
Posts: 24

PostPosted: Sat Jan 26, 2008 7:10 am   

A Complex Alias
 
So I thought I was getting the hang of things, but I attempted to write an alias this evening which fell flat on its face.

My goal is to type:
synch <arbitrary length string>

The result I desire is to have a trigger created:
#TRIGGER <specified string> <teleport to current room>

This basically creates a landmark which will automatically resynchronize my map. This is useful on the MUD I play as fleeing from combat while blind desynchronizes the map and this can be very dangerous for obvious reasons (PK MUD).

The syntax I attempted for a 'synch' alias was:
#CLASS MapSynch
#TRIG %0 {#TELEPORT %roomnum(,)}
#CLASS 0

I'm sure you veterans see the obvious errors here. Any advice to steer my newb butt in the right direction? It's taking the %roomnum(,) literally instead of expanding it to create the trigger. How do I get it to execute and have the RESULT placed in the trigger instead of having the function call itself become part of the new trigger?
Reply with quote
charneus
Wizard


Joined: 19 Jun 2005
Posts: 1876
Location: California

PostPosted: Sat Jan 26, 2008 7:49 am   
 
Try doing it this way:

#ALIAS synch {#CLASS MapSynch;$temp=%-1;#TRIGGER {$temp} {#TELEPORT %roomnum(,)};#CLASS 0}

What's happening is CMUD is taking the %0 in your example and making it the Trigger ID instead of the Trigger itself. I tested mine, and it works.

Charneus
Reply with quote
Fang Xianfu
GURU


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

PostPosted: Sat Jan 26, 2008 8:11 am   
 
You shouldn't be using a comma inside the %roomnum's brackets - that looks like you're specifying both arguments and they're both null, which'll reset the current room's number to nothing. Just have empty brackets to return the current room's number.

If your problem continues after charneus' improvement, use another local variable for the room number:

#ALIAS synch {#CLASS MapSynch;$temp=%-1;$roomnum=%roomnum();#TRIGGER {$temp} {#TELEPORT $roomnum};#CLASS 0}
_________________
Rorso's syntax colouriser.

- Happy bunny is happy! (1/25)
Reply with quote
Vijilante
SubAdmin


Joined: 18 Nov 2001
Posts: 5182

PostPosted: Sat Jan 26, 2008 2:42 pm   
 
Both the above are not quite right because of the expansion rules for creating settings. The script portion of the trigger will be exactly "#TELEPORT %roomnum", which will teleport you to wherever you are at the time the trigger fires. You actually want to have a fixed number there that is set at the time of creation. In order to do this you have to bypass the expansion rules with the #EXECUTE trick.
Code:
#ALIAS synch {#CLASS MapSynch;#EXEC {%concat("#TRIGGER {",%-1,"} {#TELEPORT ",%roomnum(),"}")};#CLASS 0}

_________________
The only good questions are the ones we have never answered before.
Search the Forums
Reply with quote
Fang Xianfu
GURU


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

PostPosted: Sat Jan 26, 2008 3:06 pm   
 
The script I gave above works absolutely fine - the $roomnum variable is set when the synch alias is run, which is then expanded properly when the trigger's created (try it). Charbal's script, excluding the comma problem, does suffer from that, and it's one of the things I was trying to fix.
_________________
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