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


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, 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 ➜ Python ➜ Setting a variable in the global scope

Setting a variable in the global scope

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


Pages: 1  2 

Posted by Nick Gammon   Australia  (23,046 posts)  Bio   Forum Administrator
Date Reply #15 on Sun 16 May 2010 01:17 AM (UTC)
Message
I got this (in orange):


Run-time error
World: SmaugFUSS
Immediate execution
[string "Command line"]:1: attempt to call global 'imaginaryfunc' (a nil value)
stack traceback:
        [string "Command line"]:1: in main chunk


WillFa said:

So my thought was to use a pcall(TablewithCallmeta(arg)) which should pass your check, since pcall is a function.


The issue isn't whether or not it is a function, but whether it is a function at global scope. For example, hotspot callback functions need to be found at global scope (in Lua) so they can't be local functions (and I imagine a similar thing applies to Python).

What you may be able to do is make a stub function in global scope which calls the function you really want called. In fact, in Lua since you can assign functions as they are first-class values, there is no reason the function that is detected by MUSHclient (eg. when loading a trigger) has to be the same one later on. In Lua's case they are simply called by name later on, in the case of the WSH they are called by dispatch ID (the ID being the thing that is checked for as described above).

So depending on the internals of the script engine, if you can make it resolve a dispatch ID to be something else later, the function it calls might vary. Or, just use a stub function.

- Nick Gammon

www.gammon.com.au, www.mushclient.com
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.


55,235 views.

This is page 2, subject is 2 pages long:  [Previous page]  1  2 

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

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]