Timerproblem

Posted by Simon on Mon 28 Jun 2004 08:20 PM — 8 posts, 31,867 views.

Sweden #0
I try this in my script:
$world->note($world->addtimer("commandtimer", 0, 1, 30, "", 1+4+1024+16384, "timetrig1"));

And I get 30009, script name is not in script file. This kinda boggles me since I don't think addtimer is supposed to be able to return that. Plus I don't know what it means :P

Any suggestions?

Best regards,
Simon
USA #1
eScriptNameNotLocated: The script name cannot be located in the script file
Is at the bottom of return on this page:
http://www.gammon.com.au/scripts/function.php?name=AddTimer



Your problem is the script name that your timer is supposed to call, doesnt exist. Make a routine in your script file and you should be fine.
Sweden #2
Ah thanks. But I do have that routine. It's just above the routine where I make the timer.
Sweden #3
This is the routines:



sub commandhook
{
if($world->istimer("commandtimer"))
{
$world->deletetimer("commandtimer");
}
$world->note($world->addtimer("commandtimer", 0, 1, 30, "", 1+4+1024+16384, "timetrig1"));
}

sub timetrig1
{
$world->setvariable("commands", 0);
$world->addtimer("commandtimer", 0, 3, 20, "", 1+4+1024+16384, "timetrig2");
}

sub timetrig2
{
$world->sound("bork.wav");
}

Australia Forum Administrator #4
I pasted that snippet you gave there into a script file, enabled Perl scripting and then typed (into the command window):

/commandhook

It showed 0 (success) on the output window, and the timer was added.
Sweden #5
Funny enough, it does that for me also. But I'm calling this function from my plugin:


<?xml version="1.0" encoding="iso-8859-1"?>
<!DOCTYPE muclient>
<!-- Saved on Monday, June 28, 2004, 8:59 PM -->
<!-- MuClient version 3.50 -->

<!-- Plugin "Commandcall" generated by Plugin Wizard -->

<muclient>
<plugin
name="Commandcall"
author="Simon Lundmark"
id="09b6d58de9fc047136bcac86"
language="PerlScript"
purpose="Calls commandhook() in your script (using prefix /) when the user types a command."
save_state="y"
date_written="2004-06-28 20:58:24"
requires="3.50"
version="1.0"
>

</plugin>


<!-- Get our standard constants -->

<include name="constants.pl"/>

<!-- Script -->


<script>
<![CDATA[
## On received a command ##
sub OnPluginSend
{
$world->execute("/commandhook();");
return 1;
}
#################################################
]]>
</script>


</muclient>


And that's when it starts to bug out.
Australia Forum Administrator #6
Hmm - I gather you are trying to communicate from the plugin to the global script?

It seems that the current plugin script space is still active when you do a world.Execute, *however* there is a workaround.

  1. Change your plugin to read:

    $world->execute("some_word_you_wont_use_normally");

    instead of:

    $world->execute("/commandhook();");
  2. Make an alias in the *global* script (not the plugin) to catch that word, and execute commandhook, like this:

    
    <aliases>
      <alias
       match="some_word_you_wont_use_normally"
       enabled="y"
       send_to="12"
       sequence="100"
      >
      <send>commandhook</send>
      </alias>
    </aliases>
    


What this will do is switch to the global script space to process the alias, and then "commandhook" will be executed in global script space. I assume this is what it is all about.

Amended on Tue 29 Jun 2004 05:40 AM by Nick Gammon
Sweden #7
That got it kicking! Many many thanks.