mirror of
https://gitlab.com/4w/mtimer.git
synced 2024-11-28 02:03:46 +01:00
make table line function a formspec helper
This commit is contained in:
parent
57a9284bca
commit
917de32cfd
@ -3,6 +3,33 @@ local S = m.translator
|
||||
local esc = minetest.formspec_escape
|
||||
|
||||
|
||||
-- Get a table line
|
||||
--
|
||||
-- The index determines the position from top within the current container and
|
||||
-- is calculated to display the string in the correct position.
|
||||
--
|
||||
-- If `name` is a literal `'-'` then a line is printed at the position.
|
||||
--
|
||||
-- @param index The numerical index for the line
|
||||
-- @param name Human-readable name for the variable
|
||||
-- @param variable The variable like it’s used in the definition
|
||||
-- @param value The value to show for that variable
|
||||
-- @return string The created formspec string
|
||||
mtimer.get_table_line = function (index, name, variable, value)
|
||||
local position = ((index-1) * 0.4)
|
||||
|
||||
if name == '-' then
|
||||
return 'box[0,'..position..';+contentWidth,0.02;#ffffff]'
|
||||
end
|
||||
|
||||
return table.concat({
|
||||
'label[0,'..position..';'..name..']',
|
||||
'label[4,'..position..';'..variable..']',
|
||||
'label[7,'..position..';'..value..']'
|
||||
}, ' ')
|
||||
end
|
||||
|
||||
|
||||
-- Get a button with icon
|
||||
--
|
||||
-- This function returns a fully formatted button with icon.
|
||||
|
@ -1,33 +1,7 @@
|
||||
local m = mtimer
|
||||
local S = m.translator
|
||||
local esc = minetest.formspec_escape
|
||||
|
||||
|
||||
-- Return a table line
|
||||
--
|
||||
-- The index determines the position from top within the current container and
|
||||
-- is calculated to display the string in the correct position.
|
||||
--
|
||||
-- If `name` is a literal `'-'` then a line is printed at the position.
|
||||
--
|
||||
-- @param index The numerical index for the line
|
||||
-- @param name Human-readable name for the variable
|
||||
-- @param variable The variable like it’s used in the definition
|
||||
-- @param value The value to show for that variable
|
||||
-- @return string The created formspec string
|
||||
local line = function (index, name, variable, value)
|
||||
local position = ((index-1) * 0.4)
|
||||
|
||||
if name == '-' then
|
||||
return 'box[0,'..position..';+contentWidth,0.02;#ffffff]'
|
||||
end
|
||||
|
||||
return table.concat({
|
||||
'label[0,'..position..';'..name..']',
|
||||
'label[4,'..position..';'..variable..']',
|
||||
'label[7,'..position..';'..value..']'
|
||||
}, ' ')
|
||||
end
|
||||
local line = mtimer.get_table_line
|
||||
|
||||
|
||||
-- Real Time Universal Formspec
|
||||
|
Loading…
Reference in New Issue
Block a user