mirror of
https://github.com/Insality/druid
synced 2025-09-27 18:12:21 +02:00
Renamed class functions
This commit is contained in:
@@ -15,11 +15,11 @@ local const = require("druid.const")
|
||||
local Event = require("druid.event")
|
||||
local component = require("druid.component")
|
||||
|
||||
local M = component.create("checkbox", { const.ON_LAYOUT_CHANGE })
|
||||
local Checkbox = component.create("checkbox", { const.ON_LAYOUT_CHANGE })
|
||||
|
||||
|
||||
local function on_click(self)
|
||||
M.set_state(self, not self.state)
|
||||
self:set_state(not self.state)
|
||||
end
|
||||
|
||||
|
||||
@@ -28,7 +28,7 @@ end
|
||||
-- or create your own style
|
||||
-- @table Style
|
||||
-- @tfield function on_change_state (self, node, state)
|
||||
function M.on_style_change(self, style)
|
||||
function Checkbox:on_style_change(style)
|
||||
self.style = {}
|
||||
|
||||
self.style.on_change_state = style.on_change_state or function(_, node, state)
|
||||
@@ -42,19 +42,19 @@ end
|
||||
-- @tparam node node Gui node
|
||||
-- @tparam function callback Checkbox callback
|
||||
-- @tparam[opt=node] node click node Trigger node, by default equals to node
|
||||
function M.init(self, node, callback, click_node)
|
||||
function Checkbox:init(node, callback, click_node)
|
||||
self.druid = self:get_druid()
|
||||
self.node = self:get_node(node)
|
||||
self.click_node = self:get_node(click_node)
|
||||
|
||||
self.button = self.druid:new_button(self.click_node or self.node, on_click)
|
||||
M.set_state(self, false, true)
|
||||
self:set_state(false, true)
|
||||
|
||||
self.on_change_state = Event(callback)
|
||||
end
|
||||
|
||||
|
||||
function M.on_layout_change(self)
|
||||
function Checkbox:on_layout_change()
|
||||
self:set_state(self.state, true)
|
||||
end
|
||||
|
||||
@@ -63,7 +63,7 @@ end
|
||||
-- @function checkbox:set_state
|
||||
-- @tparam bool state Checkbox state
|
||||
-- @tparam bool is_silent Don't trigger on_change_state if true
|
||||
function M.set_state(self, state, is_silent)
|
||||
function Checkbox:set_state(state, is_silent)
|
||||
self.state = state
|
||||
self.style.on_change_state(self, self.node, state)
|
||||
|
||||
@@ -76,9 +76,9 @@ end
|
||||
--- Return checkbox state
|
||||
-- @function checkbox:get_state
|
||||
-- @treturn bool Checkbox state
|
||||
function M.get_state(self)
|
||||
function Checkbox:get_state()
|
||||
return self.state
|
||||
end
|
||||
|
||||
|
||||
return M
|
||||
return Checkbox
|
||||
|
@@ -12,7 +12,7 @@
|
||||
local Event = require("druid.event")
|
||||
local component = require("druid.component")
|
||||
|
||||
local M = component.create("checkbox_group")
|
||||
local CheckboxGroup = component.create("checkbox_group")
|
||||
|
||||
|
||||
--- Component init function
|
||||
@@ -20,7 +20,7 @@ local M = component.create("checkbox_group")
|
||||
-- @tparam node[] node Array of gui node
|
||||
-- @tparam function callback Checkbox callback
|
||||
-- @tparam[opt=node] node[] click node Array of trigger nodes, by default equals to nodes
|
||||
function M.init(self, nodes, callback, click_nodes)
|
||||
function CheckboxGroup:init(nodes, callback, click_nodes)
|
||||
self.druid = self:get_druid()
|
||||
self.checkboxes = {}
|
||||
|
||||
@@ -40,7 +40,7 @@ end
|
||||
--- Set checkbox group state
|
||||
-- @function checkbox_group:set_state
|
||||
-- @tparam bool[] indexes Array of checkbox state
|
||||
function M.set_state(self, indexes)
|
||||
function CheckboxGroup:set_state(indexes)
|
||||
for i = 1, #indexes do
|
||||
if self.checkboxes[i] then
|
||||
self.checkboxes[i]:set_state(indexes[i], true)
|
||||
@@ -52,7 +52,7 @@ end
|
||||
--- Return checkbox group state
|
||||
-- @function checkbox_group:get_state
|
||||
-- @treturn bool[] Array if checkboxes state
|
||||
function M.get_state(self)
|
||||
function CheckboxGroup:get_state()
|
||||
local result = {}
|
||||
|
||||
for i = 1, #self.checkboxes do
|
||||
@@ -63,4 +63,4 @@ function M.get_state(self)
|
||||
end
|
||||
|
||||
|
||||
return M
|
||||
return CheckboxGroup
|
||||
|
@@ -1,64 +1,64 @@
|
||||
local const = require("druid.const")
|
||||
local component = require("druid.component")
|
||||
|
||||
local M = component.create("my_component_name", { const.ON_UPDATE })
|
||||
local Component = component.create("my_component_name", { const.ON_UPDATE })
|
||||
|
||||
|
||||
-- Component constructor
|
||||
function M.init(self, ...)
|
||||
function Component:init(...)
|
||||
end
|
||||
|
||||
|
||||
-- Call only if exist interest: const.ON_UPDATE
|
||||
function M.update(self, dt)
|
||||
function Component:update(dt)
|
||||
end
|
||||
|
||||
|
||||
-- Call only if exist interest: const.ON_INPUT or const.ON_INPUT_HIGH
|
||||
function M.on_input(self, action_id, action)
|
||||
function Component:on_input(action_id, action)
|
||||
return false
|
||||
end
|
||||
|
||||
|
||||
-- Call on component creation and on component:set_style() function
|
||||
function M.on_style_change(self, style)
|
||||
function Component:on_style_change(style)
|
||||
end
|
||||
|
||||
|
||||
-- Call only if exist interest: const.ON_MESSAGE
|
||||
function M.on_message(self, message_id, message, sender)
|
||||
function Component:on_message(message_id, message, sender)
|
||||
end
|
||||
|
||||
|
||||
-- Call only if component with ON_LANGUAGE_CHANGE interest
|
||||
function M.on_language_change(self)
|
||||
function Component:on_language_change()
|
||||
end
|
||||
|
||||
|
||||
-- Call only if component with ON_LAYOUT_CHANGE interest
|
||||
function M.on_layout_change(self)
|
||||
function Component:on_layout_change()
|
||||
end
|
||||
|
||||
|
||||
-- Call, if input was capturing before this component
|
||||
-- Example: scroll is start scrolling, so you need unhover button
|
||||
function M.on_input_interrupt(self)
|
||||
function Component:on_input_interrupt()
|
||||
end
|
||||
|
||||
|
||||
-- Call, if game lost focus. Need ON_FOCUS_LOST intereset
|
||||
function M.on_focus_lost(self)
|
||||
function Component:on_focus_lost()
|
||||
end
|
||||
|
||||
|
||||
-- Call, if game gained focus. Need ON_FOCUS_GAINED intereset
|
||||
function M.on_focus_gained(self)
|
||||
function Component:on_focus_gained()
|
||||
end
|
||||
|
||||
|
||||
-- Call on component remove or on druid:final
|
||||
function M.on_remove(self)
|
||||
function Component:on_remove()
|
||||
end
|
||||
|
||||
|
||||
return M
|
||||
return Component
|
||||
|
@@ -25,6 +25,7 @@ local component = require("druid.component")
|
||||
|
||||
local DynamicGrid = component.create("dynamic_grid", { const.ON_LAYOUT_CHANGE })
|
||||
|
||||
|
||||
local SIDE_VECTORS = {
|
||||
LEFT = vmath.vector3(-1, 0, 0),
|
||||
RIGHT = vmath.vector3(1, 0, 0),
|
||||
|
@@ -27,7 +27,7 @@ local const = require("druid.const")
|
||||
local component = require("druid.component")
|
||||
local utf8 = require("druid.system.utf8")
|
||||
|
||||
local M = component.create("input", { const.ON_INPUT, const.ON_FOCUS_LOST })
|
||||
local Input = component.create("input", { const.ON_INPUT, const.ON_FOCUS_LOST })
|
||||
|
||||
|
||||
--- Mask text by replacing every character with a mask character
|
||||
@@ -97,7 +97,7 @@ end
|
||||
-- @tfield function on_unselect (self, button_node) Callback on input field unselecting
|
||||
-- @tfield function on_input_wrong (self, button_node) Callback on wrong user input
|
||||
-- @tfield table button_style Custom button style for input node
|
||||
function M.on_style_change(self, style)
|
||||
function Input:on_style_change(style)
|
||||
self.style = {}
|
||||
|
||||
self.style.IS_LONGTAP_ERASE = style.IS_LONGTAP_ERASE or false
|
||||
@@ -115,7 +115,7 @@ function M.on_style_change(self, style)
|
||||
end
|
||||
|
||||
|
||||
function M.init(self, click_node, text_node, keyboard_type)
|
||||
function Input:init(click_node, text_node, keyboard_type)
|
||||
self.druid = self:get_druid(self)
|
||||
self.text = self.druid:new_text(text_node)
|
||||
|
||||
@@ -149,7 +149,7 @@ function M.init(self, click_node, text_node, keyboard_type)
|
||||
end
|
||||
|
||||
|
||||
function M.on_input(self, action_id, action)
|
||||
function Input:on_input(action_id, action)
|
||||
if self.selected then
|
||||
local input_text = nil
|
||||
if action_id == const.ACTION_TEXT then
|
||||
@@ -213,12 +213,12 @@ function M.on_input(self, action_id, action)
|
||||
end
|
||||
|
||||
|
||||
function M.on_focus_lost(self)
|
||||
function Input:on_focus_lost()
|
||||
unselect(self)
|
||||
end
|
||||
|
||||
|
||||
function M.on_input_interrupt(self)
|
||||
function Input:on_input_interrupt()
|
||||
-- unselect(self)
|
||||
end
|
||||
|
||||
@@ -226,7 +226,7 @@ end
|
||||
--- Set text for input field
|
||||
-- @function input:set_text
|
||||
-- @tparam string input_text The string to apply for input field
|
||||
function M.set_text(self, input_text)
|
||||
function Input:set_text(input_text)
|
||||
-- Case when update with marked text
|
||||
if input_text then
|
||||
self.value = input_text
|
||||
@@ -273,7 +273,7 @@ end
|
||||
--- Return current input field text
|
||||
-- @function input:get_text
|
||||
-- @treturn string The current input field text
|
||||
function M.get_text(self)
|
||||
function Input:get_text()
|
||||
return self.value .. self.marked_value
|
||||
end
|
||||
|
||||
@@ -283,7 +283,7 @@ end
|
||||
-- @function input:set_max_length
|
||||
-- @tparam number max_length Maximum length for input text field
|
||||
-- @treturn druid.input Current input instance
|
||||
function M.set_max_length(self, max_length)
|
||||
function Input:set_max_length(max_length)
|
||||
self.max_length = max_length
|
||||
return self
|
||||
end
|
||||
@@ -295,7 +295,7 @@ end
|
||||
-- @function input:set_allowerd_characters
|
||||
-- @tparam string characters Regulax exp. for validate user input
|
||||
-- @treturn druid.input Current input instance
|
||||
function M.set_allowed_characters(self, characters)
|
||||
function Input:set_allowed_characters(characters)
|
||||
self.allowed_characters = characters
|
||||
return self
|
||||
end
|
||||
@@ -303,10 +303,10 @@ end
|
||||
|
||||
--- Reset current input selection and return previous value
|
||||
-- @function input:reset_changes
|
||||
function M.reset_changes(self)
|
||||
function Input:reset_changes()
|
||||
self:set_text(self.previous_value)
|
||||
unselect(self)
|
||||
end
|
||||
|
||||
|
||||
return M
|
||||
return Input
|
||||
|
@@ -15,7 +15,7 @@ local const = require("druid.const")
|
||||
local settings = require("druid.system.settings")
|
||||
local component = require("druid.component")
|
||||
|
||||
local M = component.create("lang_text", { const.ON_LANGUAGE_CHANGE })
|
||||
local LangText = component.create("lang_text", { const.ON_LANGUAGE_CHANGE })
|
||||
|
||||
|
||||
--- Component init function
|
||||
@@ -23,7 +23,7 @@ local M = component.create("lang_text", { const.ON_LANGUAGE_CHANGE })
|
||||
-- @tparam node node The text node
|
||||
-- @tparam string locale_id Default locale id
|
||||
-- @tparam bool no_adjust If true, will not correct text size
|
||||
function M.init(self, node, locale_id, no_adjust)
|
||||
function LangText:init(node, locale_id, no_adjust)
|
||||
self.druid = self:get_druid()
|
||||
self.text = self.druid:new_text(node, locale_id, no_adjust)
|
||||
self.last_locale_args = {}
|
||||
@@ -36,9 +36,9 @@ function M.init(self, node, locale_id, no_adjust)
|
||||
end
|
||||
|
||||
|
||||
function M.on_language_change(self)
|
||||
function LangText:on_language_change()
|
||||
if self.last_locale then
|
||||
M.translate(self, self.last_locale, unpack(self.last_locale_args))
|
||||
self:translate(self.last_locale, unpack(self.last_locale_args))
|
||||
end
|
||||
end
|
||||
|
||||
@@ -46,7 +46,7 @@ end
|
||||
--- Setup raw text to lang_text component
|
||||
-- @function lang_text:set_to
|
||||
-- @tparam string text Text for text node
|
||||
function M.set_to(self, text)
|
||||
function LangText:set_to(text)
|
||||
self.last_locale = false
|
||||
self.text:set_to(text)
|
||||
self.on_change:trigger()
|
||||
@@ -56,11 +56,11 @@ end
|
||||
--- Translate the text by locale_id
|
||||
-- @function lang_text:translate
|
||||
-- @tparam string locale_id Locale id
|
||||
function M.translate(self, locale_id, ...)
|
||||
function LangText:translate(locale_id, ...)
|
||||
self.last_locale_args = {...}
|
||||
self.last_locale = locale_id or self.last_locale
|
||||
self.text:set_to(settings.get_text(self.last_locale, ...))
|
||||
end
|
||||
|
||||
|
||||
return M
|
||||
return LangText
|
||||
|
@@ -20,7 +20,7 @@ local const = require("druid.const")
|
||||
local helper = require("druid.helper")
|
||||
local component = require("druid.component")
|
||||
|
||||
local M = component.create("progress", { const.ON_UPDATE, const.ON_LAYOUT_CHANGE })
|
||||
local Progress = component.create("progress", { const.ON_UPDATE, const.ON_LAYOUT_CHANGE })
|
||||
|
||||
|
||||
local function check_steps(self, from, to, exactly)
|
||||
@@ -71,7 +71,7 @@ end
|
||||
-- @table Style
|
||||
-- @tfield[opt=5] number SPEED Progress bas fill rate. More -> faster
|
||||
-- @tfield[opt=0.005] number MIN_DELTA Minimum step to fill progress bar
|
||||
function M.on_style_change(self, style)
|
||||
function Progress:on_style_change(style)
|
||||
self.style = {}
|
||||
self.style.SPEED = style.SPEED or 5
|
||||
self.style.MIN_DELTA = style.MIN_DELTA or 0.005
|
||||
@@ -83,7 +83,7 @@ end
|
||||
-- @tparam string|node node Progress bar fill node or node name
|
||||
-- @tparam string key Progress bar direction: const.SIDE.X or const.SIDE.Y
|
||||
-- @tparam[opt=1] number init_value Initial value of progress bar
|
||||
function M.init(self, node, key, init_value)
|
||||
function Progress:init(node, key, init_value)
|
||||
assert(key == const.SIDE.X or const.SIDE.Y, "Progress bar key should be 'x' or 'y'")
|
||||
|
||||
self.prop = hash("scale."..key)
|
||||
@@ -106,12 +106,12 @@ function M.init(self, node, key, init_value)
|
||||
end
|
||||
|
||||
|
||||
function M.on_layout_change(self)
|
||||
function Progress:on_layout_change()
|
||||
self:set_to(self.last_value)
|
||||
end
|
||||
|
||||
|
||||
function M.update(self, dt)
|
||||
function Progress:update(dt)
|
||||
if self.target then
|
||||
local prev_value = self.last_value
|
||||
local step = math.abs(self.last_value - self.target) * (self.style.SPEED*dt)
|
||||
@@ -133,14 +133,14 @@ end
|
||||
|
||||
--- Fill a progress bar and stop progress animation
|
||||
-- @function progress:fill
|
||||
function M.fill(self)
|
||||
function Progress:fill()
|
||||
set_bar_to(self, 1, true)
|
||||
end
|
||||
|
||||
|
||||
--- Empty a progress bar
|
||||
-- @function progress:empty
|
||||
function M.empty(self)
|
||||
function Progress:empty()
|
||||
set_bar_to(self, 0, true)
|
||||
end
|
||||
|
||||
@@ -148,14 +148,14 @@ end
|
||||
--- Instant fill progress bar to value
|
||||
-- @function progress:set_to
|
||||
-- @tparam number to Progress bar value, from 0 to 1
|
||||
function M.set_to(self, to)
|
||||
function Progress:set_to(to)
|
||||
set_bar_to(self, to)
|
||||
end
|
||||
|
||||
|
||||
--- Return current progress bar value
|
||||
-- @function progress:get
|
||||
function M.get(self)
|
||||
function Progress:get()
|
||||
return self.last_value
|
||||
end
|
||||
|
||||
@@ -165,7 +165,7 @@ end
|
||||
-- @tparam number[] steps Array of progress bar values
|
||||
-- @tparam function callback Callback on intersect step value
|
||||
-- @usage progress:set_steps({0, 0.3, 0.6, 1}, function(self, step) end)
|
||||
function M.set_steps(self, steps, callback)
|
||||
function Progress:set_steps(steps, callback)
|
||||
self.steps = steps
|
||||
self.step_callback = callback
|
||||
end
|
||||
@@ -175,7 +175,7 @@ end
|
||||
-- @function progress:to
|
||||
-- @tparam number to value between 0..1
|
||||
-- @tparam[opt] function callback Callback on animation ends
|
||||
function M.to(self, to, callback)
|
||||
function Progress:to(to, callback)
|
||||
to = helper.clamp(to, 0, 1)
|
||||
-- cause of float error
|
||||
local value = helper.round(to, 5)
|
||||
@@ -190,4 +190,4 @@ function M.to(self, to, callback)
|
||||
end
|
||||
|
||||
|
||||
return M
|
||||
return Progress
|
||||
|
@@ -12,7 +12,7 @@
|
||||
local Event = require("druid.event")
|
||||
local component = require("druid.component")
|
||||
|
||||
local M = component.create("radio_group")
|
||||
local RadioGroup = component.create("radio_group")
|
||||
|
||||
|
||||
local function on_checkbox_click(self, index)
|
||||
@@ -29,7 +29,7 @@ end
|
||||
-- @tparam node[] node Array of gui node
|
||||
-- @tparam function callback Radio callback
|
||||
-- @tparam[opt=node] node[] click node Array of trigger nodes, by default equals to nodes
|
||||
function M.init(self, nodes, callback, click_nodes)
|
||||
function RadioGroup:init(nodes, callback, click_nodes)
|
||||
self.druid = self:get_druid()
|
||||
self.checkboxes = {}
|
||||
|
||||
@@ -49,7 +49,7 @@ end
|
||||
--- Set radio group state
|
||||
-- @function radio_group:set_state
|
||||
-- @tparam number index Index in radio group
|
||||
function M.set_state(self, index)
|
||||
function RadioGroup:set_state(index)
|
||||
on_checkbox_click(self, index)
|
||||
end
|
||||
|
||||
@@ -57,7 +57,7 @@ end
|
||||
--- Return radio group state
|
||||
-- @function radio_group:get_state
|
||||
-- @treturn number Index in radio group
|
||||
function M.get_state(self)
|
||||
function RadioGroup:get_state()
|
||||
local result = -1
|
||||
|
||||
for i = 1, #self.checkboxes do
|
||||
@@ -71,4 +71,4 @@ function M.get_state(self)
|
||||
end
|
||||
|
||||
|
||||
return M
|
||||
return RadioGroup
|
||||
|
@@ -22,7 +22,7 @@ local helper = require("druid.helper")
|
||||
local const = require("druid.const")
|
||||
local component = require("druid.component")
|
||||
|
||||
local M = component.create("slider", { const.ON_INPUT_HIGH, const.ON_LAYOUT_CHANGE })
|
||||
local Slider = component.create("slider", { const.ON_INPUT_HIGH, const.ON_LAYOUT_CHANGE })
|
||||
|
||||
|
||||
local function on_change_value(self)
|
||||
@@ -41,7 +41,7 @@ end
|
||||
-- @tparam node node Gui pin node
|
||||
-- @tparam vector3 end_pos The end position of slider
|
||||
-- @tparam[opt] function callback On slider change callback
|
||||
function M.init(self, node, end_pos, callback)
|
||||
function Slider:init(node, end_pos, callback)
|
||||
self.node = self:get_node(node)
|
||||
|
||||
self.start_pos = gui.get_position(self.node)
|
||||
@@ -59,12 +59,12 @@ function M.init(self, node, end_pos, callback)
|
||||
end
|
||||
|
||||
|
||||
function M.on_layout_change(self)
|
||||
function Slider:on_layout_change()
|
||||
self:set(self.value, true)
|
||||
end
|
||||
|
||||
|
||||
function M.on_input(self, action_id, action)
|
||||
function Slider:on_input(action_id, action)
|
||||
if action_id ~= const.ACTION_TOUCH then
|
||||
return false
|
||||
end
|
||||
@@ -133,7 +133,7 @@ end
|
||||
-- @function slider:set
|
||||
-- @tparam number value Value from 0 to 1
|
||||
-- @tparam[opt] bool is_silent Don't trigger event if true
|
||||
function M.set(self, value, is_silent)
|
||||
function Slider:set(value, is_silent)
|
||||
value = helper.clamp(value, 0, 1)
|
||||
set_position(self, value)
|
||||
self.value = value
|
||||
@@ -148,9 +148,9 @@ end
|
||||
-- @function slider:set_steps
|
||||
-- @tparam number[] steps Array of steps
|
||||
-- @usage slider:set_steps({0, 0.2, 0.6, 1})
|
||||
function M.set_steps(self, steps)
|
||||
function Slider:set_steps(steps)
|
||||
self.steps = steps
|
||||
end
|
||||
|
||||
|
||||
return M
|
||||
return Slider
|
||||
|
@@ -22,7 +22,7 @@ local formats = require("druid.helper.formats")
|
||||
local helper = require("druid.helper")
|
||||
local component = require("druid.component")
|
||||
|
||||
local M = component.create("timer", { const.ON_UPDATE })
|
||||
local Timer = component.create("timer", { const.ON_UPDATE })
|
||||
|
||||
|
||||
--- Component init function
|
||||
@@ -31,7 +31,7 @@ local M = component.create("timer", { const.ON_UPDATE })
|
||||
-- @tparam number seconds_from Start timer value in seconds
|
||||
-- @tparam[opt=0] number seconds_to End timer value in seconds
|
||||
-- @tparam[opt] function callback Function on timer end
|
||||
function M.init(self, node, seconds_from, seconds_to, callback)
|
||||
function Timer:init(node, seconds_from, seconds_to, callback)
|
||||
self.node = self:get_node(node)
|
||||
seconds_from = math.max(seconds_from, 0)
|
||||
seconds_to = math.max(seconds_to or 0, 0)
|
||||
@@ -52,7 +52,7 @@ function M.init(self, node, seconds_from, seconds_to, callback)
|
||||
end
|
||||
|
||||
|
||||
function M.update(self, dt)
|
||||
function Timer:update(dt)
|
||||
if not self.is_on then
|
||||
return
|
||||
end
|
||||
@@ -63,7 +63,7 @@ function M.update(self, dt)
|
||||
if self.temp > dist then
|
||||
self.temp = self.temp - dist
|
||||
self.value = helper.step(self.value, self.target, 1)
|
||||
M.set_to(self, self.value)
|
||||
self:set_to(self.value)
|
||||
|
||||
self.on_tick:trigger(self:get_context(), self.value)
|
||||
|
||||
@@ -77,7 +77,7 @@ end
|
||||
--- Set text to text field
|
||||
-- @function timer:set_to
|
||||
-- @tparam number set_to Value in seconds
|
||||
function M.set_to(self, set_to)
|
||||
function Timer:set_to(set_to)
|
||||
self.last_value = set_to
|
||||
gui.set_text(self.node, formats.second_string_min(set_to))
|
||||
end
|
||||
@@ -86,7 +86,7 @@ end
|
||||
--- Called when update
|
||||
-- @function timer:set_state
|
||||
-- @tparam bool is_on Timer enable state
|
||||
function M.set_state(self, is_on)
|
||||
function Timer:set_state(is_on)
|
||||
self.is_on = is_on
|
||||
|
||||
self.on_set_enabled:trigger(self:get_context(), is_on)
|
||||
@@ -97,14 +97,14 @@ end
|
||||
-- @function timer:set_interval
|
||||
-- @tparam number from Start time in seconds
|
||||
-- @tparam number to Target time in seconds
|
||||
function M.set_interval(self, from, to)
|
||||
function Timer:set_interval(from, to)
|
||||
self.from = from
|
||||
self.value = from
|
||||
self.temp = 0
|
||||
self.target = to
|
||||
M.set_state(self, true)
|
||||
M.set_to(self, from)
|
||||
self:set_state(true)
|
||||
self:set_to(from)
|
||||
end
|
||||
|
||||
|
||||
return M
|
||||
return Timer
|
||||
|
Reference in New Issue
Block a user