[Home] [Downloads] [Search] [Help/forum]


Register forum user name Search FAQ

Gammon Forum

[Folder]  Entire forum
-> [Folder]  MUSHclient
. -> [Folder]  VBscript
. . -> [Subject]  MC message: unable to invoke script subroutine ...

MC message: unable to invoke script subroutine ...

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


Posted by Unregistered user   (72 posts)  [Biography] bio
Date Sun 01 Oct 2000 (UTC)
Message
I very well may be misunderstanding something very fundamental, but I get this message when a trigger tries to invoke a subroutine, testscript. However, if I enter /testscript on the MC command line, it works just fine. I have "testscript" entered in the trigger's Script: field. The vbs dll is registered. What am I not getting?

Thanks

Bruce Boyer
[Go to top] top

Posted by Nick Gammon   Australia  (22,973 posts)  [Biography] bio   Forum Administrator
Date Reply #1 on Tue 03 Oct 2000 (UTC)
Message
The trigger calls the script with three arguments (parameters). If the script is not defined to take three you will get that error message.

Look in the exampscript.vbs file that comes with MUSHclient for examples of handling triggers.

Here is the sort of things you need to do ...


 
sub OnMyTrigger (strTriggerName, trig_line, arrWildCards)

' do something here

End Sub



- Nick Gammon

www.gammon.com.au, www.mushclient.com
[Go to top] top

Posted by Unregistered user   (72 posts)  [Biography] bio
Date Reply #2 on Wed 04 Oct 2000 (UTC)
Message
Well, it worked. Thanks. But, I'm puzzled as to why. Since my little test sub didn't use any of those arguments, it looked like I didn't need them, based even on examples.vbs. Perhaps something changed with 3.04? Or, with the more recent VBScript dll? In working around, I switched to JavaScript, and it worked fine without having to accept the arguments.

But it worked, so good enough. Just for completeness, and for anyone else who might stumble on this, my silly little sub was:

[code]
sub testscript
world.send "test"
end sub
[/code]

That failed, but:

[code]
sub testscript (a, b, c)
world.send "test"
end sub
[/code]

succeeded.

Thanks again. I am enjoying MUSHclient

Bruce
[Go to top] top

Posted by Nick Gammon   Australia  (22,973 posts)  [Biography] bio   Forum Administrator
Date Reply #3 on Thu 05 Oct 2000 (UTC)
Message
It worked when you tested it because your sub required no arguments, and when you tested it you supplied none.

Most languages do not allow you to call a subroutine with the incorrect number of parameters.

As to why JavaScript worked, it must have set the missing arguments to "null" or something like that.

- Nick Gammon

www.gammon.com.au, www.mushclient.com
[Go to top] top

Posted by Riven   (2 posts)  [Biography] bio
Date Reply #4 on Fri 04 May 2001 01:48 AM (UTC)
Message
I'm getting the same error message, but I have all the correct parameters. I have a script set up to automatically practice spells, and so far it's worked great. I was trying to add in another bit so I'd automatically sleep for a certain amount of time, then automatically wake back up and start practicing again. The subroutine I have to start practicing is as follows:


sub beginprac (strAliasName, strOutput, arrWildCards)
world.addtrigger "practicer", "Saving...$", "c slow self\nc slow self\nc slow self\nc slow self\nsave", 33, 0, 0, "", ""
world.addtrigger "hungry", "(You are hungry.$|You are thirsty.$)", "", 33, 0, 0, "", "imhungry0"
world.addtrigger "outomana", "You don't have enough mana.$", "", 33, 0, 0, "", "endprac"
world.send "save"
end sub


When I call it with an alias, it works fine. However, with my end practice subroutine, here:


sub endprac (strAliasName, strOutput, arrWildCards)
world.deletetrigger "practicer"
world.deletetrigger "hungry"
world.deletetrigger "outomana"
world.addtimer "sleep_timer", 0, 1, 30, "wake", 5, "beginprac"
world.send "where"
end sub


It errors when the timer pops up. The command "wake" still goes through, but the "unable to invoke script subroutine" pops up and MUSHclient crashes (last time it crashed, I had to restart my whole system).

Also, in another part of my script, I have triggers call scripts with no trouble, and they're in the same format as the one I'm trying to get to work.

Any assistance would be greatly appreciated.

Thanks,
Riven
[Go to top] top

Posted by Nick Gammon   Australia  (22,973 posts)  [Biography] bio   Forum Administrator
Date Reply #5 on Fri 04 May 2001 04:55 AM (UTC)
Message
Triggers and aliases are called with three arguments, timers with one, like this:


sub OnTimer (strTimerName)
  world.note "Timer has fired!"
end sub



Thus, you cannot call "beginprac" from a timer, which is what you are doing.

What you can do to work around this is to put the code you currently have into a separate routine (eg. Start_Practice) and call that from both the alias and the timer.

eg.




sub Start_Practice (strName)
world.addtrigger "practicer", "Saving...$", "c slow self\nc slow self\nc slow self\nc slow self\nsave", 33, 0, 0, "", ""
world.addtrigger "hungry", "(You are hungry.$|You are thirsty.$)", "", 33, 0, 0, "", "imhungry0"
world.addtrigger "outomana", "You don't have enough mana.$", "", 33, 0, 0, "", "endprac"
world.send "save"
end sub

sub beginprac (strAliasName, strOutput, arrWildCards)
  call Start_Practice (strAliasName)
end sub

sub endprac (strAliasName, strOutput, arrWildCards)
world.deletetrigger "practicer"
world.deletetrigger "hungry"
world.deletetrigger "outomana"
world.addtimer "sleep_timer", 0, 1, 30, "wake", 5, "Start_Practice"
world.send "where"
end sub



- Nick Gammon

www.gammon.com.au, www.mushclient.com
[Go to top] 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.


16,196 views.

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

Go to topic:           Search the forum


[Go to top] top

Quick links: MUSHclient. MUSHclient help. Forum shortcuts. Posting templates. Lua modules. Lua documentation.

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

[Home]


Written by Nick Gammon - 5K   profile for Nick Gammon on Stack Exchange, a network of free, community-driven Q&A sites   Marriage equality

Comments to: Gammon Software support
[RH click to get RSS URL] Forum RSS feed ( https://gammon.com.au/rss/forum.xml )

[Best viewed with any browser - 2K]    [Hosted at HostDash]