Better testscene

This commit is contained in:
2026-03-29 13:18:13 +02:00
parent 1fdb223f5d
commit 3f462d3482
27 changed files with 3714 additions and 3036 deletions

View File

@@ -1,25 +1,24 @@
-- ============================================================================
-- spinner.lua - Continuously rotating object (onUpdate demo)
-- ============================================================================
-- Tests: onUpdate, self.rotationY, Entity.GetRotationY, Entity.SetRotationY,
-- Timer.GetFrameCount, self.position, Entity.GetPosition
local speed = 1 -- pi-units per frame
-- 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 onUpdate(self, dt)
-- Rotate the object by speed * dt each frame
local current = Entity.GetRotationY(self)
Entity.SetRotationY(self, current + speed * dt)
-- Every 300 frames, log position and rotation (test Timer)
if Timer.GetFrameCount() % 300 == 0 then
local pos = Entity.GetPosition(self)
Debug.Log("Spinner at frame " .. Timer.GetFrameCount()
.. " pos=" .. pos.x .. "," .. pos.y .. "," .. pos.z
.. " rotY=" .. Entity.GetRotationY(self))
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