lol
This commit is contained in:
@@ -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
|
||||
|
||||
BIN
Assets/lua/luaScripts.zip
Normal file
BIN
Assets/lua/luaScripts.zip
Normal file
Binary file not shown.
7
Assets/lua/luaScripts.zip.meta
Normal file
7
Assets/lua/luaScripts.zip.meta
Normal file
@@ -0,0 +1,7 @@
|
||||
fileFormatVersion: 2
|
||||
guid: b0f059e707384a245bba2c3dc3c43aae
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -13,8 +13,12 @@ end
|
||||
function onInteract(self)
|
||||
selected = not selected
|
||||
if selected then
|
||||
Controls.SetEnabled(false)
|
||||
Interact.SetEnabled(self, false)
|
||||
setStatus("Object selected! D-pad to move, Triangle to deselect.")
|
||||
else
|
||||
Controls.SetEnabled(true)
|
||||
Interact.SetEnabled(self, true)
|
||||
setStatus("Object deselected.")
|
||||
end
|
||||
end
|
||||
@@ -23,7 +27,8 @@ function onButtonPress(self, button)
|
||||
if not selected then return end
|
||||
|
||||
local pos = self.position
|
||||
local step = 1
|
||||
local one = FixedPoint.new(1)
|
||||
local step = one / 64
|
||||
|
||||
if button == Input.UP then
|
||||
Entity.SetPosition(self, Vec3.new(pos.x, pos.y, pos.z + step))
|
||||
@@ -39,6 +44,8 @@ function onButtonPress(self, button)
|
||||
Entity.SetPosition(self, Vec3.new(pos.x, pos.y - step, pos.z))
|
||||
elseif button == Input.TRIANGLE then
|
||||
selected = false
|
||||
Controls.SetEnabled(true)
|
||||
Interact.SetEnabled(self, true)
|
||||
setStatus("Object deselected.")
|
||||
elseif button == Input.SQUARE then
|
||||
local rot = Entity.GetRotationY(self)
|
||||
|
||||
@@ -4,17 +4,16 @@
|
||||
|
||||
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()
|
||||
if Animation.IsPlaying("anim_spinner") then
|
||||
Animation.Stop("anim_spinner")
|
||||
setStatus("Spinner stopped!")
|
||||
Debug.Log("Spinner stopped at rotY=" .. Entity.GetRotationY(self)
|
||||
.. " frame=" .. Timer.GetFrameCount())
|
||||
else
|
||||
Cutscene.Play("spin_loop", {loop = true})
|
||||
Animation.Play("anim_spinner", {loop = true})
|
||||
setStatus("Spinner started!")
|
||||
end
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user