lul
This commit is contained in:
36
Assets/lua/collectible.lua
Normal file
36
Assets/lua/collectible.lua
Normal file
@@ -0,0 +1,36 @@
|
||||
-- ============================================================================
|
||||
-- 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
|
||||
Reference in New Issue
Block a user