generated from your-land/yl_template
luacheck and formatting
This commit is contained in:
parent
625a6a4841
commit
1e098338a5
19
config.lua
19
config.lua
@ -1,12 +1,19 @@
|
||||
|
||||
-- Setting a configuration, switch the order in which the settings shall take precedence. First valid one taken.
|
||||
|
||||
yl_survey_fs.settings = {}
|
||||
|
||||
yl_survey_fs.settings.debug = minetest.settings:get_bool("yl_survey_fs.debug", false)
|
||||
yl_survey_fs.settings.debug = minetest.settings:get_bool("yl_survey_fs.debug",
|
||||
false)
|
||||
|
||||
yl_survey_fs.settings.external_value = "mod_default" or minetest.settings:get("yl_survey_fs.external_value") or "default"
|
||||
yl_survey_fs.settings.external_value = "mod_default" or
|
||||
minetest.settings:get(
|
||||
"yl_survey_fs.external_value") or
|
||||
"default"
|
||||
|
||||
yl_survey_fs.settings.save_path = "yl_survey_fs" or minetest.settings:get("yl_survey_fs.save_path") or "default"
|
||||
yl_survey_fs.settings.save_path = "yl_survey_fs" or
|
||||
minetest.settings:get(
|
||||
"yl_survey_fs.save_path") or "default"
|
||||
|
||||
yl_survey_fs.settings.admin_priv = "admin_priv" or minetest.settings:get("yl_survey_fs.admin_priv") or "server"
|
||||
yl_survey_fs.settings.admin_priv = "admin_priv" or
|
||||
minetest.settings:get(
|
||||
"yl_survey_fs.admin_priv") or
|
||||
"server"
|
||||
|
40
internal.lua
40
internal.lua
@ -57,12 +57,12 @@ end
|
||||
|
||||
local function get_cache(survey_id, question_id, playername)
|
||||
|
||||
local r_success, responses = yl_survey.get_response(survey_id, question_id,
|
||||
playername, true, true)
|
||||
local _, responses = yl_survey.get_response(survey_id, question_id,
|
||||
playername, true, true)
|
||||
|
||||
-- q obj
|
||||
local q_success, q = yl_survey.get_question(survey_id, question_id, true,
|
||||
playername)
|
||||
local q_success = yl_survey.get_question(survey_id, question_id, true,
|
||||
playername)
|
||||
if (q_success == false) then return responses end
|
||||
|
||||
local cache = {}
|
||||
@ -113,7 +113,7 @@ local string_replacements = {
|
||||
local function construct_frame_formspec(playername, survey_id)
|
||||
|
||||
local record = yl_survey.get_record(survey_id)
|
||||
local owner = record["metadata"].owner
|
||||
-- local owner = record["metadata"].owner
|
||||
local title = record["metadata"].title or ""
|
||||
local description = record["metadata"].description or ""
|
||||
|
||||
@ -122,7 +122,7 @@ local function construct_frame_formspec(playername, survey_id)
|
||||
description = string.gsub(description, replaceme, tostring(r))
|
||||
end
|
||||
|
||||
local fs_owner = minetest.formspec_escape(owner)
|
||||
-- local fs_owner = minetest.formspec_escape(owner)
|
||||
local fs_title = minetest.formspec_escape(title)
|
||||
local fs_description = minetest.formspec_escape(description)
|
||||
|
||||
@ -143,7 +143,8 @@ yl_survey_fs.single_answer_formspec = table.concat({
|
||||
"textarea[0.5,%s;14,1;;;%s]" -- answer text
|
||||
}, "")
|
||||
|
||||
yl_survey_fs.single_freetext_formspec = "textarea[0.5,2.5;15.03,1;input_freetext;;%s]" -- Freetext
|
||||
yl_survey_fs.single_freetext_formspec =
|
||||
"textarea[0.5,2.5;15.03,1;input_freetext;;%s]" -- Freetext
|
||||
|
||||
yl_survey_fs.answers_formspec = table.concat({
|
||||
"formspec_version[6]", "size[16.18,10]", -- buttons
|
||||
@ -153,7 +154,7 @@ yl_survey_fs.answers_formspec = table.concat({
|
||||
"button[0.68,8.5;3,1;btn_back;< Back]", -- Content
|
||||
"label[0.5,0.75;%s]", -- Title
|
||||
"textarea[0.5,1.5;15.03,1;;;%s]", -- Question
|
||||
"%s", --"textarea[0.5,2.5;15.03,1;input_freetext;;%s]", -- Freetext
|
||||
"%s", -- "textarea[0.5,2.5;15.03,1;input_freetext;;%s]", -- Freetext
|
||||
"scrollbaroptions[arrows=show]",
|
||||
"scrollbar[15.35,3.75;0.5,4.5;vertical;scroll_options;]",
|
||||
"scroll_container[0.5,3.75;14.53,4.5;scroll_options;vertical;]", "%s", -- Answers
|
||||
@ -164,13 +165,9 @@ local function construct_answer_formspec(playername, survey_id, question_id)
|
||||
|
||||
local record = yl_survey.get_record(survey_id)
|
||||
if (record == nil) then return end
|
||||
local owner = record["metadata"].owner
|
||||
local title = record["metadata"].title or ""
|
||||
local description = record["metadata"].description or ""
|
||||
|
||||
local fs_owner = minetest.formspec_escape(owner)
|
||||
local fs_title = minetest.formspec_escape(title)
|
||||
local fs_description = minetest.formspec_escape(description)
|
||||
|
||||
local q_success, q = yl_survey.get_question(survey_id, question_id, true,
|
||||
playername)
|
||||
@ -179,7 +176,8 @@ local function construct_answer_formspec(playername, survey_id, question_id)
|
||||
if (q["enabled"] ~= true) then return end
|
||||
local fs_question = minetest.formspec_escape(q.question or "N/A")
|
||||
-- error:
|
||||
if (yl_survey.table_contains(q.allowed_types, "singlechoice") == true) and (yl_survey.table_contains(q.allowed_types, "multiplechoice") == true) then
|
||||
if (yl_survey.table_contains(q.allowed_types, "singlechoice") == true) and
|
||||
(yl_survey.table_contains(q.allowed_types, "multiplechoice") == true) then
|
||||
return
|
||||
end
|
||||
-- singlechoice
|
||||
@ -201,10 +199,10 @@ local function construct_answer_formspec(playername, survey_id, question_id)
|
||||
|
||||
local insert_freetext = ""
|
||||
if (yl_survey.table_contains(q.allowed_types, "freetext") == true) then
|
||||
insert_freetext = string.format(yl_survey_fs.single_freetext_formspec, fs_freetext)
|
||||
insert_freetext = string.format(yl_survey_fs.single_freetext_formspec,
|
||||
fs_freetext)
|
||||
end
|
||||
|
||||
|
||||
local t_answers = {}
|
||||
local spacer = 0
|
||||
local checkbox_spacer = 0.3
|
||||
@ -241,7 +239,7 @@ end)
|
||||
|
||||
--[[
|
||||
|
||||
yl_survey_fs.data =
|
||||
yl_survey_fs.data =
|
||||
{
|
||||
AliasAlreadyTaken = {
|
||||
survey_id = "somecrazy UUID",
|
||||
@ -253,7 +251,7 @@ yl_survey_fs.data =
|
||||
]] --
|
||||
|
||||
-- on_player_receive_fields
|
||||
--
|
||||
--
|
||||
|
||||
minetest.register_on_player_receive_fields(
|
||||
function(player, formname, fields)
|
||||
@ -287,7 +285,7 @@ minetest.register_on_player_receive_fields(
|
||||
minetest.log("warning", yl_survey_fs.t("cannot find questions"))
|
||||
return
|
||||
end
|
||||
local current_q_id = 0
|
||||
-- local current_q_id = 0
|
||||
local current_sort = 0
|
||||
local next_q_id, next_sort =
|
||||
yl_survey_fs.get_next_q_id_and_sort(questions, current_sort)
|
||||
@ -323,7 +321,7 @@ minetest.register_on_player_receive_fields(
|
||||
minetest.log("warning", yl_survey_fs.t("cannot find questions"))
|
||||
return
|
||||
end
|
||||
local current_q_id = yl_survey_fs.data[playername].q_id
|
||||
-- local current_q_id = yl_survey_fs.data[playername].q_id
|
||||
local current_sort = yl_survey_fs.data[playername].sort
|
||||
local previous_q_id, previous_sort, min_sort =
|
||||
yl_survey_fs.get_previous_q_id_and_sort(questions, current_sort)
|
||||
@ -370,7 +368,7 @@ minetest.register_on_player_receive_fields(
|
||||
minetest.log("warning", yl_survey_fs.t("cannot find questions"))
|
||||
return
|
||||
end
|
||||
local current_q_id = yl_survey_fs.data[playername].q_id
|
||||
-- local current_q_id = yl_survey_fs.data[playername].q_id
|
||||
local current_sort = yl_survey_fs.data[playername].sort
|
||||
local next_q_id, next_sort, max_sort =
|
||||
yl_survey_fs.get_next_q_id_and_sort(questions, current_sort)
|
||||
@ -440,7 +438,7 @@ minetest.register_on_player_receive_fields(
|
||||
end
|
||||
|
||||
-- store it!
|
||||
local a_success, a_responses =
|
||||
local a_success =
|
||||
yl_survey.answer_question(survey_id, question_id, playername,
|
||||
response, true)
|
||||
if (a_success == false) then
|
||||
|
Loading…
Reference in New Issue
Block a user