Files
sampleproj/Assets/lua/collectible.lua
Jan Racek 1fdb223f5d lul
2026-03-29 09:34:46 +02:00

37 lines
1004 B
Lua

-- ============================================================================
-- collectible.lua - Pickup item
-- ============================================================================
-- Tests: onCreate, onDestroy, onCollideWithPlayer, onEnable, onDisable,
-- Entity.SetActive, Audio.Play, Persist, self.active, self.position
local collected = false
function onCreate(self)
collected = false
Debug.Log("Collectible created at " .. self.position.x .. "," .. self.position.y .. "," .. self.position.z)
end
function onDestroy(self)
Debug.Log("Collectible destroyed")
end
function onEnable(self)
Debug.Log("Collectible enabled")
end
function onDisable(self)
Debug.Log("Collectible disabled")
end
function onCollideWithPlayer(self)
if collected then return end
collected = true
Audio.Play("collect", 127, 64)
-- Update score via scene script global
addScore(100)
setStatus("Collected! +100 points")
Entity.SetActive(self, false)
end