feat: add event loading

This commit is contained in:
Kazhnuz 2021-03-21 22:02:13 +01:00
parent 2e47d87abf
commit a890e42352
4 changed files with 14 additions and 2 deletions

View file

@ -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", ""}
}
}

View file

@ -467,6 +467,7 @@ return {
properties = {
["charId"] = 1,
["charset"] = "perso2",
["event"] = "test.espio",
["isSolid"] = true
}
},

View file

@ -97,6 +97,7 @@
<properties>
<property name="charId" type="int" value="1"/>
<property name="charset" value="perso2"/>
<property name="event" value="test.espio"/>
<property name="isSolid" type="bool" value="true"/>
</properties>
</object>

View file

@ -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;