| Message |
This test routine worked for me. For all open worlds it displays a message showing the world name, and whether it is active or not:
message = "test"
for k, v in pairs (GetWorldIdList ()) do
w = GetWorldById (v) -- world userdatum
w:Tell (w:WorldName() .. ": ")
w:Tell (tostring (w:GetInfo (113)) .. ": ")
w:ColourNote ("red", "white", message)
end -- for
I would also take the the comma you have in "white,".
Now using that idea, we can write the loop like this:
message = "test"
for k, v in pairs (GetWorldIdList ()) do
w = GetWorldById (v) -- world userdatum
if w:GetInfo (113) then -- is it active?
w:ColourNote ("red", "white", message)
end -- if
end -- for
If you want to keep your separate isActive function, you could write it like this:
function isActive (w)
if w then
return w:GetInfo (113)
else
return GetInfo (113)
end -- if
end -- function isActive
message = "test"
for k, v in pairs (GetWorldIdList ()) do
w = GetWorldById (v) -- world userdatum
if isActive (w) then -- is it active?
w:ColourNote ("red", "white", message)
end -- if
end -- for
You have to pass down to isActive which world is the one whose activity you are testing for. |
- Nick Gammon
www.gammon.com.au, www.mushclient.com | top |
|