Object touchability not updated if touch event assigned outside global scope
Frionil Fang
Specifically: the object's touchable state will reflect only if touch_start has a function assigned in the global script scope. The function assignments appear to work as expected, it's only the viewer UI that is not properly updated to allow/disallow touches.
Unsure if this affects other types of events. Being able to disable or reassign an event handler at any time would be useful e.g. to make an object unclickable while it does some processing.
Repro script:
function func()
ll.OwnerSay("touched, remove touch")
touch_start = nil
end
function timer()
ll.OwnerSay("(re)enable touch_start")
touch_start = func
ll.SetTimerEvent(0)
end
touch_start = func --assign a function in global scope, object becomes touchable
ll.OwnerSay(`starting, touch_start type = {type(touch_start)}`)
ll.SetTimerEvent(5) -- timer restores touchability in 5 seconds
Touching removes the touch function, but the object still appears as touchable. Once restored by the timer, you can touch it again.
If you comment out the global-scope touch_start = func assignment, the object remains untouchable even after the timer assigns the function.
Log In
WolfGang Senizen
A slightly simpler repro
timer = function()
touch_start = ll.OwnerSay
ll.SetTimerEvent(0.0)
end
ll.SetTimerEvent(0.01)
touching should ownersay but it doesn't