Hi everybody!
Just got familiar with Druid and started to play with button. I would like to use it as a toggle.
If component is initialising, then I set state to required one.
When user will click this component styles will reverse component state to an opposite one.
local sound_toggle = self.druid:new_button("sound_toggle/toggle", toggle_sound)
sound_toggle:set_style(toggleStyle)
sound_toggle:set_enabled(settings.options.sound)
local M = {}
M["button"] = {
LONGTAP_TIME = 0.4,
DOUBLETAP_TIME = 0.4,
TEXTURE_ENABLED = "toggle_on",
TEXTURE_DISABLED = "toggle_off",
on_click = function(self, node)
self:set_enabled(not self:is_enabled())
end,
on_set_enabled = function(self, node, state)
dd('on_set_enabled', state)
if state then
gui.play_flipbook(node, hash(M.button.TEXTURE_ENABLED))
else
gui.play_flipbook(node, hash(M.button.TEXTURE_DISABLED))
end
end
}
return M
The problem is that with initial state it is working fine, but with toggling state it return error message:
ERROR:SCRIPT: /druid/base/hover.lua:86: attempt to index local ‘self’ (a boolean value)
Not sure why it is happening like that? Can anybody help with that?