I've just started digging into MUSHclient's scripting capabilities after a number of years of using it. I started with VBScript, but given Nick's recommendation of LUA for scripting novices, it seemed the wiser choice. I've managed quite a few of the things I wanted to do, but I'd like to refine it if possible.
I've got a trigger that ends up sending a message to all open worlds (I always run several) when it's run -- basically, notifying me that I've been contacted on said world. What I'd like to do is have it send only to the active world. What I'm using to send to all worlds is this:
function SendToAllWorlds (message)
for k, v in pairs (GetWorldIdList ()) do
GetWorldById (v):ColourNote ("red","white,",message)
end
What I'd like to do is something like this instead:
function SendToActiveWorld (message)
for k, v in pairs (GetWorldIdList ()) do
if GetWorldById (v):isActive() then
GetWorldById (v):ColourNote ("red","white,",message)
end
end
Where isActive() is something that uses GetInfo(113), I guess (I suspect this may be a place where I'm going wrong):
function isActive ()
GetInfo(113)
end
What's happening right now is that I get this error message when the trigger's script tries to execute:
[string "Script file"]:676: attempt to call method `isActive' (a nil value)
stack traceback:
[string "Script file"]:676: in function `SendToActiveWorld'
[string "Trigger: "]:2: in main chunk
Any pointers much appreciated.
I've got a trigger that ends up sending a message to all open worlds (I always run several) when it's run -- basically, notifying me that I've been contacted on said world. What I'd like to do is have it send only to the active world. What I'm using to send to all worlds is this:
function SendToAllWorlds (message)
for k, v in pairs (GetWorldIdList ()) do
GetWorldById (v):ColourNote ("red","white,",message)
end
What I'd like to do is something like this instead:
function SendToActiveWorld (message)
for k, v in pairs (GetWorldIdList ()) do
if GetWorldById (v):isActive() then
GetWorldById (v):ColourNote ("red","white,",message)
end
end
Where isActive() is something that uses GetInfo(113), I guess (I suspect this may be a place where I'm going wrong):
function isActive ()
GetInfo(113)
end
What's happening right now is that I get this error message when the trigger's script tries to execute:
[string "Script file"]:676: attempt to call method `isActive' (a nil value)
stack traceback:
[string "Script file"]:676: in function `SendToActiveWorld'
[string "Trigger: "]:2: in main chunk
Any pointers much appreciated.