Extension-Druid/example/example.gui.gui_script
2019-03-27 22:13:45 +01:00

65 lines
1.4 KiB
Plaintext

local druid = require("druid.druid")
local druid_settings = require("druid.settings")
local lang = {
locale_text = "Localized"
}
local function setup_druid(self)
-- two different way of exernal component regesstration
druid.comps["my_mega_test_comp"] = require "druid.base.text"
druid.register("my_custom_component", {})
druid_settings.is_debug = true
druid_settings.play_sound = function(name)
sound.play("sounds#" .. name)
end
druid_settings.get_text = function(text_id)
return lang[text_id]
end
end
function init(self)
setup_druid(self)
self.druid = druid.new(self)
self.druid:new_button("button_1", function()
print("On button 1")
end)
--alternative way of component creation
self.druid:new(druid.comps.button, "button_2", function()
print("On button 2")
end)
self.druid:new_button("button_3", function()
print("On button 3")
end)
self.druid:new_android_back(function(self, params)
print("On android back", params)
end, 2)
self.druid:new_text("text_2", "Simple text")
self.druid:new_text("text_3", "locale_text", true)
self.druid:new_timer("text_1", 0.5, 0, function()
print("On timer end")
end)
end
function update(self, dt)
self.druid:update(dt)
end
function on_message(self, message_id, message, sender)
self.druid:on_message(message_id, message, sender)
end
function on_input(self, action_id, action)
self.druid:on_input(action_id, action)
end