feat(events): add direction option to teleporting

This commit is contained in:
Kazhnuz 2021-04-21 18:46:30 +02:00
parent e50c9f6e54
commit d7b47933b3
4 changed files with 10 additions and 4 deletions

View file

@ -6,7 +6,7 @@ return {
["playSFX"] = {"sfx"}, ["playSFX"] = {"sfx"},
["getRings"] = {"number"}, ["getRings"] = {"number"},
["getItems"] = {"type", "item", "number"}, ["getItems"] = {"type", "item", "number"},
["teleport"] = {"area", "x", "y"} ["teleport"] = {"area", "x", "y", "charDir"}
--[name] = {args...}, --[name] = {args...},
} }

View file

@ -7,8 +7,12 @@ function SimpleMessageStep:new(controller, args)
end end
function SimpleMessageStep:start() 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, 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) 0, 0)
end end

View file

@ -8,8 +8,9 @@ end
function Teleporter:applyProperties() function Teleporter:applyProperties()
Teleporter.super.applyProperties(self) Teleporter.super.applyProperties(self)
local charDir = self.properties.charDir or "default"
self.event = { self.event = {
{"teleport", "", self.properties.area, self.properties.x, self.properties.y}, {"teleport", "", self.properties.area, self.properties.x, self.properties.y, charDir},
} }
end end

View file

@ -21,7 +21,7 @@ function RPGWorld:savePosition()
game.position.area = self.area game.position.area = self.area
end end
function RPGWorld:teleport(area, x, y) function RPGWorld:teleport(area, x, y, charDir)
if (area == self.area) then if (area == self.area) then
self.players[1].actor.x = x * 16 self.players[1].actor.x = x * 16
self.players[1].actor.y = y * 16 self.players[1].actor.y = y * 16
@ -31,6 +31,7 @@ function RPGWorld:teleport(area, x, y)
self.playery = y self.playery = y
self:reset() self:reset()
collectgarbage() collectgarbage()
self.players[1].actor.charDir = charDir
end end
end end