This commit is contained in:
Jan Racek
2026-03-29 18:40:52 +02:00
parent 2cd9af28f1
commit fcb25a5388
22 changed files with 1307 additions and 175 deletions

View File

@@ -1,38 +1,44 @@
-- ============================================================================
-- door.lua - Interactable door that plays an open cutscene
-- door.lua - Interactable door that opens/closes via animation
-- ============================================================================
-- Tests: onInteract, Cutscene.Play with onComplete, Entity.Find,
-- Entity.SetActive, Controls, Audio
-- Tests: onInteract, Animation.Play with onComplete, Animation.IsPlaying,
-- Interact.SetEnabled, self.position, self.rotation, Audio
local isOpen = false
function onCreate(self)
isOpen = false
Debug.Log("Door created")
Debug.Log("Door created at " .. self.position.x .. "," .. self.position.y .. "," .. self.position.z)
end
function onInteract(self)
if isOpen then
setStatus("Door is already open")
if Animation.IsPlaying("door_open") or Animation.IsPlaying("door_close") then
return
end
if Cutscene.IsPlaying() then return end
isOpen = true
Audio.Play("door_open", 100, 64)
Controls.SetEnabled(false)
setStatus("Opening door...")
if isOpen then
isOpen = false
Interact.SetEnabled(self, false)
Audio.Play("door_close", 100, 64)
setStatus("Closing door...")
Cutscene.Play("door_open", {
onComplete = function()
Controls.SetEnabled(true)
setStatus("Door opened! Path is clear.")
-- Disable the door blocker object
local blocker = Entity.Find("DoorBlocker")
if blocker then
Entity.SetActive(blocker, false)
Animation.Play("door_close", {
onComplete = function()
Interact.SetEnabled(self, true)
setStatus("Door closed.")
end
end
})
})
else
isOpen = true
Interact.SetEnabled(self, false)
Audio.Play("door_open", 100, 64)
setStatus("Opening door...")
Animation.Play("door_open", {
onComplete = function()
Interact.SetEnabled(self, true)
setStatus("Door opened!")
end
})
end
end