|
Progonoi Magician
Joined: 28 Jan 2007 Posts: 430
|
Posted: Sat Mar 08, 2008 2:23 pm
%roomkey/%roomid and Expression Trigger. |
Is it possible to make a code bit such as this?
Code: |
#var Key {667}
#trigger {%roomkey=@Key} {do something} {exp}
|
The point is to change something thats only done in one particular room completely unique.
I tried with %roomkey and it didn't work, so I figured I'd ask here if its even possible.
Prog |
|
|
|
JQuilici Adept
Joined: 21 Sep 2005 Posts: 250 Location: Austin, TX
|
Posted: Sat Mar 08, 2008 2:53 pm |
The easiest way to achieve that effect is to put your 'do something' script into the room script for room 667 in the mapper, rather than using a trigger.
To do so, put the map in Map Mode (and make sure it's unlocked), then right-click on the room and choose 'Properties'. In the resulting dialog, there should be a pane below the room description with tabs for 'Notes', 'Room Script', and 'Walk Script'. Click on 'Room Script' and type in your 'do something' commands. Those commands will be invoked whenever the mapper detects you entering that room. |
|
_________________ Come visit Mozart Mud...and tell an imm that Aerith sent you! |
|
|
|
Progonoi Magician
Joined: 28 Jan 2007 Posts: 430
|
Posted: Sat Mar 08, 2008 3:06 pm |
Thats a good idea, but I'd like to have the ability to disable this function once its done. A trigger of some sort would do exactly that.
Prog |
|
_________________ The Proud new owner of CMud.
--------------------------------
Intel Core i5-650 3,2GHz
4 DD3 RAM
GTX 460 768MB
Win 7 Home Premium 64x
-------------------------------- |
|
|
|
Arminas Wizard
Joined: 11 Jul 2002 Posts: 1265 Location: USA
|
Posted: Sat Mar 08, 2008 3:25 pm |
Here you go Prog. I tested it before posting in the sample session.
Code: |
#TRIGGER "rk5" ((%roomkey==5)) {#show {You are in room 5!};#T- rk5} "" {disable} |
Edit: Well it worked the first time. *grumbles*
There needs to be a variable in there as mentioned below, that Changes.
I know you have loads of variables and at least two that change every time you change rooms. Just place one of them into the expression.
Something like.
Code: |
#TRIGGER "rk5" ((%roomkey==5)and(@okExit) {#show {You are in room 5!};#T- rk5} "" {disable} |
|
|
_________________ Arminas, The Invisible horseman
Windows 7 Pro 32 bit
AMD 64 X2 2.51 Dual Core, 2 GB of Ram
Last edited by Arminas on Sat Mar 08, 2008 3:39 pm; edited 1 time in total |
|
|
|
JQuilici Adept
Joined: 21 Sep 2005 Posts: 250 Location: Austin, TX
|
Posted: Sat Mar 08, 2008 3:28 pm |
So wrap the room script commands in an #if statement, and use a variable to enable/disable the code. E.g. '#if (@room667CmdsEnabled) {do something}', and you can set room667CmdsEnabled to true or false to turn the code on and off.
The description of the expression trigger from the KB is "The Pattern field is an Expression. When this Expression evaluates to True, then the trigger fires. The trigger is only tested when variables used in the expression change their values." My suspicion (on the basis of no investigation whatsoever) is that expression triggers do NOT fire when predefined variables (%something) change - only when regular user-defined variables (@something) change. |
|
_________________ Come visit Mozart Mud...and tell an imm that Aerith sent you! |
|
|
|
Progonoi Magician
Joined: 28 Jan 2007 Posts: 430
|
Posted: Sat Mar 08, 2008 3:39 pm |
Weird, it isn't working for me. I pasted your exact trigger as well, checked if the map pointer is on correct Roomkey and nothing, not a beep.
If its any significance, Perl regex bit on Trigger's Test Tab is giving it as ((oomkey==5)) instead. Kind of strange.
Thanks for all the help so far, too.
Prog
EDIT: Hrm. In a nutshell I was just now sending a command into MUD for a gathering certain data and the Expression Trigger suddenly hit and gave the succession message. But nothing happend when I was just sitting around, doing nothing other than randomly pressing Enter at times :/ |
|
Last edited by Progonoi on Sat Mar 08, 2008 3:44 pm; edited 1 time in total |
|
|
|
Arminas Wizard
Joined: 11 Jul 2002 Posts: 1265 Location: USA
|
Posted: Sat Mar 08, 2008 3:42 pm |
Look at the edit to my above post. Note that it fires when @Okexit==1, and NOT when @Okexit==0.
But it does need @Okexit to have changed from 0 to 1. |
|
_________________ Arminas, The Invisible horseman
Windows 7 Pro 32 bit
AMD 64 X2 2.51 Dual Core, 2 GB of Ram |
|
|
|
Progonoi Magician
Joined: 28 Jan 2007 Posts: 430
|
Posted: Sat Mar 08, 2008 3:54 pm |
Great! Additional variable did the trick. Basically what I need to do now is switch this Variable true when I have to use the Trigger and then turn it false once its done. Seems that there really isn't any need to turn Trigger itself off.
Thanks for all the help Arminas and JQ. I feel tidbit smarter yet again!
Prog |
|
|
|
Progonoi Magician
Joined: 28 Jan 2007 Posts: 430
|
Posted: Sat Mar 08, 2008 9:06 pm |
I ended up using Pattern Trigger to grab the Room Name saved inside a Variable and made this Trigger to set KeyRoom Variable to 1.
Then the Expression trigger activated when KeyRoom wasn't null and everything was ok.
Basically this was needed to prevent wrong data received/sent when Char's location wasn't the same as the pointer on Map.
That being said, started to think about a feature (obviously would be a CMud deal which I don't use myself yet) which would check if Char's actual location and Map's Pointer location are the same. When they are, it would give 1, if not 0.
If such function already exists, please point me towards it! If not, maybe something cool to add for CMud if its even possible.
Thanks,
Prog |
|
|
|
|
|