From d7b47933b32e62daebaab7d2244951abb3af5ba2 Mon Sep 17 00:00:00 2001 From: Kazhnuz Date: Wed, 21 Apr 2021 18:46:30 +0200 Subject: [PATCH] feat(events): add direction option to teleporting --- sonic-radiance.love/game/events/arguments.lua | 2 +- sonic-radiance.love/game/events/event/teleport.lua | 6 +++++- sonic-radiance.love/scenes/overworld/actors/teleport.lua | 3 ++- sonic-radiance.love/scenes/overworld/world.lua | 3 ++- 4 files changed, 10 insertions(+), 4 deletions(-) diff --git a/sonic-radiance.love/game/events/arguments.lua b/sonic-radiance.love/game/events/arguments.lua index ae9f3ab..e642aa1 100644 --- a/sonic-radiance.love/game/events/arguments.lua +++ b/sonic-radiance.love/game/events/arguments.lua @@ -6,7 +6,7 @@ return { ["playSFX"] = {"sfx"}, ["getRings"] = {"number"}, ["getItems"] = {"type", "item", "number"}, - ["teleport"] = {"area", "x", "y"} + ["teleport"] = {"area", "x", "y", "charDir"} --[name] = {args...}, } diff --git a/sonic-radiance.love/game/events/event/teleport.lua b/sonic-radiance.love/game/events/event/teleport.lua index bca3bb4..620da50 100644 --- a/sonic-radiance.love/game/events/event/teleport.lua +++ b/sonic-radiance.love/game/events/event/teleport.lua @@ -7,8 +7,12 @@ function SimpleMessageStep:new(controller, args) end function SimpleMessageStep:start() + local charDir = self.arguments.charDir + if (charDir == "default") then + charDir = self.events.scene.world.players[1].actor.charDir or "down" + end core.screen:startTransition(defTransitions.default, defTransitions.default, - function() self.events.scene.world:teleport(self.arguments.area, self.arguments.x, self.arguments.y) end, + function() self.events.scene.world:teleport(self.arguments.area, self.arguments.x, self.arguments.y, charDir) end, 0, 0) end diff --git a/sonic-radiance.love/scenes/overworld/actors/teleport.lua b/sonic-radiance.love/scenes/overworld/actors/teleport.lua index 87e06c0..bbd826c 100644 --- a/sonic-radiance.love/scenes/overworld/actors/teleport.lua +++ b/sonic-radiance.love/scenes/overworld/actors/teleport.lua @@ -8,8 +8,9 @@ end function Teleporter:applyProperties() Teleporter.super.applyProperties(self) + local charDir = self.properties.charDir or "default" self.event = { - {"teleport", "", self.properties.area, self.properties.x, self.properties.y}, + {"teleport", "", self.properties.area, self.properties.x, self.properties.y, charDir}, } end diff --git a/sonic-radiance.love/scenes/overworld/world.lua b/sonic-radiance.love/scenes/overworld/world.lua index 3ef2f8d..a7a0b8c 100644 --- a/sonic-radiance.love/scenes/overworld/world.lua +++ b/sonic-radiance.love/scenes/overworld/world.lua @@ -21,7 +21,7 @@ function RPGWorld:savePosition() game.position.area = self.area end -function RPGWorld:teleport(area, x, y) +function RPGWorld:teleport(area, x, y, charDir) if (area == self.area) then self.players[1].actor.x = x * 16 self.players[1].actor.y = y * 16 @@ -31,6 +31,7 @@ function RPGWorld:teleport(area, x, y) self.playery = y self:reset() collectgarbage() + self.players[1].actor.charDir = charDir end end