Files
sampleproj/Assets/lua/spinner.lua
2026-03-29 13:18:13 +02:00

25 lines
823 B
Lua

-- spinner.lua - Object that spins using a looping cutscene
-- Tests: onCreate, Cutscene.Play with loop, Cutscene.Stop, Cutscene.IsPlaying,
-- onInteract, onCollideWithPlayer, Entity.GetRotationY, Timer
function onCreate(self)
Debug.Log("Spinner created, initial rotY: " .. self.rotationY)
Cutscene.Play("spin_loop", {loop = true})
end
function onInteract(self)
if Cutscene.IsPlaying() then
Cutscene.Stop()
setStatus("Spinner stopped!")
Debug.Log("Spinner stopped at rotY=" .. Entity.GetRotationY(self)
.. " frame=" .. Timer.GetFrameCount())
else
Cutscene.Play("spin_loop", {loop = true})
setStatus("Spinner started!")
end
end
function onCollideWithPlayer(self)
Debug.Log("Player touched spinner at frame " .. Timer.GetFrameCount())
end