Completed checkbox_query and rewrite of change_modules module with checkboxes
This commit is contained in:
@ -501,7 +501,8 @@ function modpol.interactions.checkbox_query(
|
||||
local fs_line = ""
|
||||
vertical = i * .5
|
||||
fs_line = "checkbox[0,"..vertical..";checkbox_"..i..";"..
|
||||
v[1]..";"..tostring(v[2]).."]"
|
||||
minetest.formspec_escape(v[1])..";"..
|
||||
tostring(v[2]).."]"
|
||||
table.insert(checkbox_options, fs_line)
|
||||
end
|
||||
local max = vertical * 4
|
||||
@ -514,14 +515,9 @@ function modpol.interactions.checkbox_query(
|
||||
"scrollbar[9,1;0.3,5.5;vertical;scroller;0]",
|
||||
"scroll_container[0.5,1;9,5.5;scroller;vertical]",
|
||||
}
|
||||
-- prepare options
|
||||
for i,v in ipairs(options) do
|
||||
local fs_line = ""
|
||||
local vertical = i * .5
|
||||
fs_line = "checkbox[0,"..vertical..";checkbox_"..i..";"..
|
||||
minetest.formspec_escape(v[1])..";"
|
||||
..tostring(v[2]).."]"
|
||||
table.insert(formspec, fs_line)
|
||||
-- insert options
|
||||
for i,v in ipairs(checkbox_options) do
|
||||
table.insert(formspec, v)
|
||||
end
|
||||
table.insert(formspec,"scroll_container_end[]")
|
||||
table.insert(formspec,"button[0.5,7;1.5,0.8;submit;Submit]")
|
||||
@ -533,7 +529,8 @@ function modpol.interactions.checkbox_query(
|
||||
-- put func in _contexts
|
||||
if _contexts[user] == nil then _contexts[user] = {} end
|
||||
_contexts[user]["checkbox_query_func"] = func
|
||||
_contexts[user]["checkbox_query_result"] = options
|
||||
_contexts[user]["checkbox_query_result"] =
|
||||
modpol.util.copy_table(options)
|
||||
end
|
||||
-- receive fields
|
||||
minetest.register_on_player_receive_fields(function (player, formname, fields)
|
||||
|
Reference in New Issue
Block a user