Page 1 of 1
getCurrentRoomID() - keeping track of current room
Posted: Tue Oct 04, 2016 7:12 pm
by chrio
Ok, so before an easy way to find the current room is implemented, we can do it ourself as a script in lua. It's not perfect, so if a room is deleted after we have centerviewed it, the currentRoomID will still be valid even if the room is gone.
-- getCurrentRoomID()
-- returns last RoomID that was used with centerview()
-- or 0 if centerview() failed.
-------------------------------------------------------
if not getCurrentRoomID then
getCurrentRoomID = function ()
currentRoomID = currentRoomID or 0
return currentRoomID
end
oldCenterView = oldCenterView or centerview
centerview = function(id)
local retval = oldCenterView(id)
if retval then
currentRoomID = id
else
currentRoomID = 0
end
return retval
end
end
After using this script, a global variable (currentRoomID) is always set when using centerview(). You can read it by calling the function
getCurrentRoomID(). You could also read it directly as a variable, but then you have to be careful so you don't change its value by mistake.
Re: getCurrentRoomID() - keeping track of current room
Posted: Tue Oct 04, 2016 8:00 pm
by SlySven
Yeah, this will help until I (or some other coder) can get a command into the system to retrieve it...