Indeed. You could also use a single cursor & add all the animation frames for each of the different cursors to the active animation part & then use Lua script to force which frames should be played / looped.
I guess there are multiple ways to approach this.
P.S: your mouse event handler function isn't quite right. In your example it is executing the code regardless of which event is triggered. Please see example 2 of this
page. How you have written the registerEventHandler function is fine because if you don't include any flag events then it will automatically declare all events available.
P.P.S: technically Lua index tables start with an index value of 1, but you have forced it to start with 0. Also because you are using index values there was no reason to write each cursor name on a new line.
local t = { "obj", "exit_left", "exit_right", "exit_up", "exit_down" }
function setCursor(n)
startAction(Actions["cursor_" .. n])
end
function onMouseEvent(eventType, mousePosition)
if eventType == eEvtMouseMove and game.CurrentObject:getId().tableId == eObjects then
for i = 1, #t do
if string.find( game.CurrentObject:getName(), t[i] ) and Values["exitcode"].Int ~= i then setCursor(i); break end
end
end
end
registerEventHandler("mouseEvent", "onMouseEvent")
...untested. There's no reason to directly access said values, as you should only need 1 instance of them, which you could create anywhere you like.