From a890e42352d323825d9cfed5c83fff4d4375c959 Mon Sep 17 00:00:00 2001 From: Kazhnuz Date: Sun, 21 Mar 2021 22:02:13 +0100 Subject: [PATCH] feat: add event loading --- sonic-radiance.love/datas/gamedata/events/test/espio.lua | 5 +++++ .../datas/gamedata/maps/sti/plain/test.lua | 1 + .../datas/gamedata/maps/sti/plain/test.tmx | 1 + sonic-radiance.love/scenes/overworld/actors/gizmo.lua | 9 +++++++-- 4 files changed, 14 insertions(+), 2 deletions(-) create mode 100644 sonic-radiance.love/datas/gamedata/events/test/espio.lua diff --git a/sonic-radiance.love/datas/gamedata/events/test/espio.lua b/sonic-radiance.love/datas/gamedata/events/test/espio.lua new file mode 100644 index 0000000..dd71819 --- /dev/null +++ b/sonic-radiance.love/datas/gamedata/events/test/espio.lua @@ -0,0 +1,5 @@ +return { + ["actions"] = { + {"dialogBox", "", "Hello Sonic. I'm testing the dialog system of Sonic Radiance. Here, I should do an in-character joke, but the dev is too lazy to even think about that. But don't do that. Remember than only training and discipline will help you.", "Espio", ""} + } +} \ No newline at end of file diff --git a/sonic-radiance.love/datas/gamedata/maps/sti/plain/test.lua b/sonic-radiance.love/datas/gamedata/maps/sti/plain/test.lua index 43bf338..11e4b3a 100644 --- a/sonic-radiance.love/datas/gamedata/maps/sti/plain/test.lua +++ b/sonic-radiance.love/datas/gamedata/maps/sti/plain/test.lua @@ -467,6 +467,7 @@ return { properties = { ["charId"] = 1, ["charset"] = "perso2", + ["event"] = "test.espio", ["isSolid"] = true } }, diff --git a/sonic-radiance.love/datas/gamedata/maps/sti/plain/test.tmx b/sonic-radiance.love/datas/gamedata/maps/sti/plain/test.tmx index 80807ba..8509c2c 100644 --- a/sonic-radiance.love/datas/gamedata/maps/sti/plain/test.tmx +++ b/sonic-radiance.love/datas/gamedata/maps/sti/plain/test.tmx @@ -97,6 +97,7 @@ + diff --git a/sonic-radiance.love/scenes/overworld/actors/gizmo.lua b/sonic-radiance.love/scenes/overworld/actors/gizmo.lua index 94d3df2..6f4df2e 100644 --- a/sonic-radiance.love/scenes/overworld/actors/gizmo.lua +++ b/sonic-radiance.love/scenes/overworld/actors/gizmo.lua @@ -2,7 +2,7 @@ local cwd = (...):gsub('%.gizmo$', '') .. "." local Parent = require(cwd .. "parent") local Gizmo = Parent:extend() -local defaultEffect = { +local defaultEvent = { {"simpleMessage", "", "ERROR 000 NO EVENT"}, } @@ -12,6 +12,7 @@ function Gizmo:new(world, x, y, w, h, overrides) Gizmo.super.new(self, world, "gizmo", x, y, w, h, false) self.overrides = overrides self.drawDebugBox = true + self.event = defaultEvent end function Gizmo:setProperties(properties) @@ -34,6 +35,10 @@ function Gizmo:applyProperties() self.charId = self.properties.charId or 1 self.charset = self.properties.charset or nil self.cantTurn = self.properties.cantTurn or self.cantTurn + if (self.properties.event ~= nil) then + local data = require("datas.gamedata.events." .. self.properties.event) + self.event = data.actions + end end function Gizmo:setDefaultProperties() @@ -53,7 +58,7 @@ function Gizmo:replaceProperties(properties) end function Gizmo:doAction() - self.scene.events:startEvent(self, defaultEffect) + self.scene.events:startEvent(self, self.event) end return Gizmo; \ No newline at end of file