Register forum user name Search FAQ

Gammon Forum

Notice: Any messages purporting to come from this site telling you that your password has expired, or that you need to verify your details, confirm your email, resolve issues, making threats, or asking for money, are spam. We do not email users with any such messages. If you have lost your password you can obtain a new one by using the password reset link.
 Entire forum ➜ MUSHclient ➜ Plugins ➜ grrrr. can someone please tell me why I get an error message on this plugin?

grrrr. can someone please tell me why I get an error message on this plugin?

It is now over 60 days since the last post. This thread is closed.     Refresh page


Posted by Nobody   (38 posts)  Bio
Date Thu 18 May 2006 09:36 AM (UTC)
Message
I'm trying to make it myself, I setup the triggers in mushclient, exported them to the plugin file, and now I'm writing the script that I want it to use in the xml file.

In the plugin area, I have
language="PerlScript"

In the trigger area:
<trigger
enabled="y"
group="ticktimer"
name="prompt"
match="^(.*?)hp (.*?)mv (.*?)xp (.*?)$"
omit_from_output="y"
regexp="y"
script="handle_prompt"
sequence="100"
>

In the script area I have:
<script>
<![CDATA[

def handle_prompt()
{
$args = shift;
$world->Note("DEBUG: $args");

}
]]>

</script>

When I load (try to load) the plugin, I get:
syntax error at (eval 2) line 2, near ")
{"
syntax error
Line in error:

followed by another popup saying:
You have not specified a script file name:

The trigger (prompt) subroutine named "handle_prompt" could not be found.

Why can't the subroutine be found? IT'S RIGHT THERE. I explicitly define it right there!!!

Someone please explain how to get plugins to work with scripts?
Top

Posted by Nick Gammon   Australia  (23,121 posts)  Bio   Forum Administrator
Date Reply #1 on Thu 18 May 2006 10:22 AM (UTC)
Message
I'm not a Perl expert, but are you sure you have the right syntax? My exampscript.pl file, which ships with MUSHclient, defines subroutines a bit differently to that, for example:


# ------------------------------------------
# Example showing a script called by a timer
# -------------------------------------------
sub OnTimer
{
my ($strTimerName) = @_;

$world->note ("Timer $strTimerName has fired!");
}	# end of OnTimer 


- Nick Gammon

www.gammon.com.au, www.mushclient.com
Top

Posted by David Haley   USA  (3,881 posts)  Bio
Date Reply #2 on Thu 18 May 2006 04:28 PM (UTC)
Message
There are two problems. For starters you shouldn't use def, you should be using sub, as Nick said.

Second, you declared it with a no-argument prototype (by adding the () at the end). Either you should declare it with an "open" prototype (with just sub FunctionName) or you should use the correct prototype. My advice is to not use prototypes unless you have a fairly good reason to.

Also, by doing $args = shift, you will only be getting the first argument into $args. If you want the whole array of arguments, you should do @args = @_. Or, do like what Nick posted. Or yet again, $arg1 = shift; $arg2 = shift; etc.

David Haley aka Ksilyan
Head Programmer,
Legends of the Darkstone

http://david.the-haleys.org
Top

Posted by Nick Gammon   Australia  (23,121 posts)  Bio   Forum Administrator
Date Reply #3 on Thu 18 May 2006 10:08 PM (UTC)
Message
There is a Perlscript plugin:

http://www.mushclient.com/plugins/Perlscript_Version.xml

This simply shows the current version of Perlscript, however as a fully-working plugin written in Perlscript you should be able to see the syntax of getting a plugin working in Perl.

Quote:

I get: syntax error at (eval 2) line 2,

...

Why can't the subroutine be found? IT'S RIGHT THERE. I explicitly define it right there!!!


If you get a syntax error, then the module won't be found, as it didn't compile. Fix the syntax error first.

- Nick Gammon

www.gammon.com.au, www.mushclient.com
Top

Posted by Nobody   (38 posts)  Bio
Date Reply #4 on Fri 19 May 2006 04:09 AM (UTC)
Message
My god how embarassing. How did I get that syntax screwed up? In my defense, I was tired and so on but still... what language is 'sub' from? Clearly I was getting all confused. This is the trouble with learning 4 scripting languages at once!

No doubt I'll have many many more questions in the future, I just hope that I get the basic language syntax correct :\
Top

Posted by Rakon   USA  (123 posts)  Bio
Date Reply #5 on Fri 19 May 2006 08:17 AM (UTC)

Amended on Fri 19 May 2006 08:19 AM (UTC) by Rakon

Message
Sub is a lua or Perl syntax, where is def is a python syntax.
But asking questions is how you learn! So feel free to ask em here. I've always found the peoples on this forum very helpful and considerate, so long as you yourself are respectful, and courteous.

-- Rakon

**EDIT**
Can't spell for the life of me.

Yes, I am a criminal.
My crime is that of curiosity.
My crime is that of judging people by what they say and think, not what they look like.
My crime is that of outsmarting you, something that you will never forgive me for.
Top

Posted by David Haley   USA  (3,881 posts)  Bio
Date Reply #6 on Fri 19 May 2006 08:46 AM (UTC)
Message
Actually, Lua uses 'function', not 'sub' -- at least it does as of 5.1 and I believe 5.0 as well. Perl definitely uses at least 'sub'. And just for kicks, Lisp uses something in between def and function: 'defun'. :)

David Haley aka Ksilyan
Head Programmer,
Legends of the Darkstone

http://david.the-haleys.org
Top

The dates and times for posts above are shown in Universal Co-ordinated Time (UTC).

To show them in your local time you can join the forum, and then set the 'time correction' field in your profile to the number of hours difference between your location and UTC time.


22,233 views.

It is now over 60 days since the last post. This thread is closed.     Refresh page

Go to topic:           Search the forum


[Go to top] top

Information and images on this site are licensed under the Creative Commons Attribution 3.0 Australia License unless stated otherwise.