Trigger Send To Script Not Working

Posted by 1of10 on Sat 07 Jun 2003 09:03 PM — 4 posts, 21,273 views.

Canada #0
I just discovered the Send To Script option for triggers, etc. and I've been trying to make use of this feature. I cannot seem to get the inline script to work. I always get an error box saying immediate execution line in error.

I have searched the site (docs and forums) looking for help and examples of this feature. Most of it looks to be written in VBScript. I use PerlScript.

I have tried the following variations:

run~if (!defined($world->getVariable("TestVar"))) { $world->send("Some \"quoted\" text."); }

if (!defined($world->getVariable("TestVar"))) { $world->send("Some \"quoted\" text."); }

run~if (!defined(getVariable("TestVar"))) { send("Some \"quoted\" text."); }

if (!defined(getVariable("TestVar"))) { send("Some \"quoted\" text."); }


Above, run~ is my script alias, as opposed to /.

As far as I can tell, the trigger is setup correctly. I use the same !defined() test in a script file subroutine for another trigger that is not inline script, and that works. I even copied the inline script out of the trigger and pasted to the input window. It worked perfectly there. The script will not work for me as an inline script.

Screen captures of the trigger setup:
http://fr.1of10.net/nx01/inline_trigger_script_1.jpg
http://fr.1of10.net/nx01/inline_trigger_script_2.jpg
Greece #1
Just a question.. Are you sure the language is set to Perl in the script dialog? :P
Australia Forum Administrator #2
The problem is a bit more subtle. :)

First, the variant you want is your second one, because "send to script" already knows you want to script it, and adding the script prefix is unnecessary, and in fact, wrong.

If you want to use the script prefix (why, I can't think) then you need to "send to execute" so it goes through the command parser, which then notices the script prefix.

However the idea of "send to script" was that triggers like that would continue to work even if you changed the script prefix.

The main problem is that triggers very helpfully translate backslash sequences for you, so that \" becomes simply ".

To make it work, which it did for me you need to escape the backslash, so it makes it through to the Perl engine. This works:


if (!defined($world->getVariable("TestVar")))
{ $world->send("Some \\"quoted\\" text."); }

Note the extra backslashes.



Canada #3
That was VERY subtle... It's working now.

Thanks. :)