Improve TA4 button wrench menu
This commit is contained in:
parent
d3126bff70
commit
e2f72ca57e
@ -137,9 +137,9 @@ local function generate_formspec_substring(pos, meta, form_def, player_name)
|
||||
return player_inv_needed, table.concat(tbl, "")
|
||||
end
|
||||
|
||||
local function value_check(elem, value)
|
||||
local function value_check(elem, value, player_name)
|
||||
if elem.check then
|
||||
return elem.check(value)
|
||||
return elem.check(value, player_name)
|
||||
end
|
||||
return value ~= nil
|
||||
end
|
||||
@ -159,7 +159,7 @@ local function evaluate_data(pos, meta, form_def, fields, player_name)
|
||||
meta:set_string(elem.name, "")
|
||||
elseif fields[elem.name]:find("^[%d ]+$") then
|
||||
local val = tonumber(fields[elem.name])
|
||||
if value_check(elem, val) then
|
||||
if value_check(elem, val, player_name) then
|
||||
meta:set_int(elem.name, val)
|
||||
--print("set_int", elem.name, val)
|
||||
else
|
||||
@ -173,7 +173,8 @@ local function evaluate_data(pos, meta, form_def, fields, player_name)
|
||||
if fields[elem.name] then
|
||||
if fields[elem.name] == "" then
|
||||
meta:set_string(elem.name, "")
|
||||
elseif fields[elem.name]:find("^[%d ]+$") and value_check(elem, fields[elem.name]) then
|
||||
elseif fields[elem.name]:find("^[%d ]+$") and
|
||||
value_check(elem, fields[elem.name], player_name) then
|
||||
meta:set_string(elem.name, fields[elem.name])
|
||||
else
|
||||
res = false
|
||||
@ -184,7 +185,7 @@ local function evaluate_data(pos, meta, form_def, fields, player_name)
|
||||
meta:set_string(elem.name, "")
|
||||
elseif fields[elem.name] then
|
||||
local val = tonumber(fields[elem.name])
|
||||
if val and value_check(elem, val) then
|
||||
if val and value_check(elem, val, player_name) then
|
||||
meta:set_string(elem.name, val)
|
||||
else
|
||||
res = false
|
||||
@ -194,7 +195,7 @@ local function evaluate_data(pos, meta, form_def, fields, player_name)
|
||||
if fields[elem.name] == ""then
|
||||
meta:set_string(elem.name, "")
|
||||
elseif fields[elem.name] then
|
||||
if value_check(elem, fields[elem.name]) then
|
||||
if value_check(elem, fields[elem.name], player_name) then
|
||||
meta:set_string(elem.name, fields[elem.name])
|
||||
else
|
||||
res = false
|
||||
|
@ -1633,7 +1633,7 @@ techage.manual_DE.aText = {
|
||||
"\n"..
|
||||
"\n",
|
||||
"",
|
||||
"Beim TA4 Taster/Schalter hat sich nur das Aussehen geändert. Die Funktionalität ist gleich wie beim TA3 Taster/Schalter.\n"..
|
||||
"Beim TA4 Taster/Schalter hat sich nur das Aussehen geändert. Die Funktionalität ist gleich wie beim TA3 Taster/Schalter. Mit dem Schraubenschlüssel-Menü können die Daten aber nachträglich geändert werden.\n"..
|
||||
"\n"..
|
||||
"\n"..
|
||||
"\n",
|
||||
|
@ -1639,7 +1639,7 @@ techage.manual_EN.aText = {
|
||||
"\n"..
|
||||
"\n",
|
||||
"",
|
||||
"Only the appearance of the TA4 button/switch has changed. The functionality is the same as with the TA3 button/switch.\n"..
|
||||
"Only the appearance of the TA4 button/switch has changed. The functionality is the same as with the TA3 button/switch. With the wrench menu\\, however\\, the data can be changed later.\n"..
|
||||
"\n"..
|
||||
"\n"..
|
||||
"\n",
|
||||
|
@ -114,7 +114,11 @@ TA3 Booster=TA3 Gebläse
|
||||
### button.lua ###
|
||||
|
||||
Access:=Zugriff:
|
||||
Button or switch=Taster oder Schalter
|
||||
Change the block name (infotext)=Ändere den Blocknamen
|
||||
Command to be sent=Zu sendender Befehl
|
||||
Destination block number(s)=Zielblocknummer
|
||||
Infotext=Infotext
|
||||
TA3 Button/Switch=TA3 Taster/Schalter
|
||||
TA4 Button/Switch=TA4 Schalter/Taster
|
||||
|
||||
@ -122,7 +126,11 @@ TA4 Button/Switch=TA4 Schalter/Taster
|
||||
### button_2x.lua ###
|
||||
### button_4x.lua ###
|
||||
|
||||
Access=Zugriff
|
||||
Button protection=Tastenschutz
|
||||
Command=Kommando
|
||||
Number=Nummer
|
||||
Type=Typ
|
||||
|
||||
### button.lua ###
|
||||
### cart_detector.lua ###
|
||||
@ -154,14 +162,10 @@ TA4 2x Button=TA4 2x Taster
|
||||
### button_2x.lua ###
|
||||
### button_4x.lua ###
|
||||
|
||||
Access=Zugriff
|
||||
Button protection=Tastenschutz
|
||||
Command to be sent (ignored for switches)=Zu sendender Befehl (wird für Schalter ignoriert)
|
||||
Destination block number=Zielblocknummer
|
||||
Label for the button=Beschriftung für die Taste
|
||||
Momentary button or on/off switch=Taster oder Ein-/Ausschalter
|
||||
Number=Nummer
|
||||
Type=Typ
|
||||
|
||||
### button_2x.lua ###
|
||||
### button_4x.lua ###
|
||||
|
@ -114,7 +114,11 @@ TA3 Booster=
|
||||
### button.lua ###
|
||||
|
||||
Access:=
|
||||
Button or switch=
|
||||
Change the node name (infotext)=
|
||||
Command to be sent=
|
||||
Destination block number(s)=
|
||||
Infotext=
|
||||
TA3 Button/Switch=
|
||||
TA4 Button/Switch=
|
||||
|
||||
@ -122,7 +126,11 @@ TA4 Button/Switch=
|
||||
### button_2x.lua ###
|
||||
### button_4x.lua ###
|
||||
|
||||
Access=
|
||||
Button protection=
|
||||
Command=
|
||||
Number=
|
||||
Type=
|
||||
|
||||
### button.lua ###
|
||||
### cart_detector.lua ###
|
||||
@ -154,14 +162,10 @@ TA4 2x Button=
|
||||
### button_2x.lua ###
|
||||
### button_4x.lua ###
|
||||
|
||||
Access=
|
||||
Button protection=
|
||||
Command to be sent (ignored for switches)=
|
||||
Destination block number=
|
||||
Label for the button=
|
||||
Momentary button or on/off switch=
|
||||
Number=
|
||||
Type=
|
||||
|
||||
### button_2x.lua ###
|
||||
### button_4x.lua ###
|
||||
|
@ -20,6 +20,22 @@ local NDEF = function(pos) return (minetest.registered_nodes[techage.get_node_lv
|
||||
local logic = techage.logic
|
||||
|
||||
local WRENCH_MENU = {
|
||||
{
|
||||
type = "dropdown",
|
||||
choices = "switch,button 1s,button 2s,button 4s,button 8s,button 16s,button 32s",
|
||||
name = "type",
|
||||
label = S("Type"),
|
||||
tooltip = S("Button or switch"),
|
||||
default = "1",
|
||||
},
|
||||
{
|
||||
type = "numbers",
|
||||
name = "numbers",
|
||||
label = S("Number"),
|
||||
tooltip = S("Destination block number(s)"),
|
||||
default = "",
|
||||
check = techage.check_numbers,
|
||||
},
|
||||
{
|
||||
type = "ascii",
|
||||
name = "command",
|
||||
@ -27,6 +43,21 @@ local WRENCH_MENU = {
|
||||
tooltip = S("Command to be sent"),
|
||||
default = "on",
|
||||
},
|
||||
{
|
||||
type = "dropdown",
|
||||
choices = "private,protected,public",
|
||||
name = "access",
|
||||
label = S("Access"),
|
||||
tooltip = S("Button protection"),
|
||||
default = "1",
|
||||
},
|
||||
{
|
||||
type = "ascii",
|
||||
name = "decription",
|
||||
label = S("Infotext"),
|
||||
tooltip = S("Change the block name (infotext)"),
|
||||
default = "",
|
||||
},
|
||||
}
|
||||
|
||||
local function switch_on(pos)
|
||||
@ -81,14 +112,8 @@ local function formspec(meta)
|
||||
"button_exit[2,4;3,1;exit;"..S("Save").."]"
|
||||
end
|
||||
|
||||
local function on_receive_fields(pos, formname, fields, player)
|
||||
if minetest.is_protected(pos, player:get_player_name()) then
|
||||
return
|
||||
end
|
||||
local function store_fields_data(pos, fields)
|
||||
local meta = M(pos)
|
||||
if not techage.check_numbers(fields.numbers, player:get_player_name()) then
|
||||
return
|
||||
end
|
||||
meta:set_string("numbers", fields.numbers)
|
||||
if fields.access == "protected" then
|
||||
meta:set_string("protected", "true")
|
||||
@ -128,6 +153,20 @@ local function on_receive_fields(pos, formname, fields, player)
|
||||
if cycle_time ~= nil then
|
||||
meta:set_int("cycle_time", cycle_time)
|
||||
end
|
||||
meta:set_string("access", fields.access)
|
||||
meta:set_string("type", fields.type)
|
||||
end
|
||||
|
||||
local function on_receive_fields(pos, formname, fields, player)
|
||||
if minetest.is_protected(pos, player:get_player_name()) then
|
||||
return
|
||||
end
|
||||
if not techage.check_numbers(fields.numbers, player:get_player_name()) then
|
||||
return
|
||||
end
|
||||
store_fields_data(pos, fields)
|
||||
|
||||
local meta = M(pos)
|
||||
logic.infotext(meta, NDEF(pos).description)
|
||||
if fields.exit then
|
||||
meta:set_string("formspec", nil)
|
||||
@ -137,6 +176,16 @@ local function on_receive_fields(pos, formname, fields, player)
|
||||
end
|
||||
end
|
||||
|
||||
local function ta_after_formspec(pos, fields, playername)
|
||||
store_fields_data(pos, fields)
|
||||
local meta = M(pos)
|
||||
if fields.decription ~= "" then
|
||||
logic.infotext(meta, fields.decription)
|
||||
else
|
||||
logic.infotext(meta, NDEF(pos).description)
|
||||
end
|
||||
end
|
||||
|
||||
local function can_access(pos, player)
|
||||
local meta = M(pos)
|
||||
local public = meta:get_string("public") == "true"
|
||||
@ -269,6 +318,7 @@ minetest.register_node("techage:ta4_button_off", {
|
||||
end,
|
||||
|
||||
ta4_formspec = WRENCH_MENU,
|
||||
ta_after_formspec = ta_after_formspec,
|
||||
on_receive_fields = on_receive_fields,
|
||||
on_rightclick = on_rightclick_on,
|
||||
techage_set_numbers = techage_set_numbers,
|
||||
@ -305,6 +355,8 @@ minetest.register_node("techage:ta4_button_on", {
|
||||
},
|
||||
},
|
||||
|
||||
ta4_formspec = WRENCH_MENU,
|
||||
ta_after_formspec = ta_after_formspec,
|
||||
on_rightclick = on_rightclick_off,
|
||||
on_timer = switch_off,
|
||||
on_rotate = screwdriver.disallow,
|
||||
|
@ -55,6 +55,7 @@ local WRENCH_MENU = {
|
||||
label = S("Number") .. " 1",
|
||||
tooltip = S("Destination block number"),
|
||||
default = "",
|
||||
check = techage.check_numbers,
|
||||
},
|
||||
{
|
||||
type = "ascii",
|
||||
@ -76,6 +77,7 @@ local WRENCH_MENU = {
|
||||
label = S("Number") .. " 2",
|
||||
tooltip = S("Destination block number"),
|
||||
default = "",
|
||||
check = techage.check_numbers,
|
||||
},
|
||||
{
|
||||
type = "ascii",
|
||||
|
@ -59,6 +59,7 @@ local WRENCH_MENU = {
|
||||
label = S("Number") .. " 1",
|
||||
tooltip = S("Destination block number"),
|
||||
default = "",
|
||||
check = techage.check_numbers,
|
||||
},
|
||||
{
|
||||
type = "ascii",
|
||||
@ -80,6 +81,7 @@ local WRENCH_MENU = {
|
||||
label = S("Number") .. " 2",
|
||||
tooltip = S("Destination block number"),
|
||||
default = "",
|
||||
check = techage.check_numbers,
|
||||
},
|
||||
{
|
||||
type = "ascii",
|
||||
@ -101,6 +103,7 @@ local WRENCH_MENU = {
|
||||
label = S("Number") .. " 3",
|
||||
tooltip = S("Destination block number"),
|
||||
default = "",
|
||||
check = techage.check_numbers,
|
||||
},
|
||||
{
|
||||
type = "ascii",
|
||||
@ -122,6 +125,7 @@ local WRENCH_MENU = {
|
||||
label = S("Number") .. " 4",
|
||||
tooltip = S("Destination block number"),
|
||||
default = "",
|
||||
check = techage.check_numbers,
|
||||
},
|
||||
{
|
||||
type = "ascii",
|
||||
|
@ -467,7 +467,7 @@ Das Terminal dient zur Ein-/Ausgabe für den Lua Controller.
|
||||
|
||||
### TA4 Taster/Schalter / Button/Switch
|
||||
|
||||
Beim TA4 Taster/Schalter hat sich nur das Aussehen geändert. Die Funktionalität ist gleich wie beim TA3 Taster/Schalter.
|
||||
Beim TA4 Taster/Schalter hat sich nur das Aussehen geändert. Die Funktionalität ist gleich wie beim TA3 Taster/Schalter. Mit dem Schraubenschlüssel-Menü können die Daten aber nachträglich geändert werden.
|
||||
|
||||
[ta4_button|image]
|
||||
|
||||
|
@ -459,7 +459,7 @@ The terminal is used for input / output for the Lua controller.
|
||||
|
||||
### TA4 Button/Switch
|
||||
|
||||
Only the appearance of the TA4 button/switch has changed. The functionality is the same as with the TA3 button/switch.
|
||||
Only the appearance of the TA4 button/switch has changed. The functionality is the same as with the TA3 button/switch. With the wrench menu, however, the data can be changed later.
|
||||
|
||||
[ta4_button|image]
|
||||
|
||||
|
@ -46,7 +46,7 @@ local WRENCH_MENU = {
|
||||
|
||||
local function formspec(nvm, meta)
|
||||
local status = meta:get_string("status")
|
||||
local path = meta:contains("fs_path") and meta:get_string("fs_path") or
|
||||
local path = meta:contains("fs_path") and meta:get_string("fs_path") or
|
||||
meta:contains("path") and meta:get_string("path") or "0,3,0"
|
||||
return "size[8,6.7]" ..
|
||||
"style_type[textarea;font=mono;textcolor=#FFFFFF;border=true]" ..
|
||||
|
@ -40,6 +40,7 @@ local WRENCH_MENU = {
|
||||
label = S("Handover to B"),
|
||||
tooltip = S("Number of the next movecontroller"),
|
||||
default = "",
|
||||
check = techage.check_numbers,
|
||||
},
|
||||
{
|
||||
type = "number",
|
||||
@ -47,6 +48,7 @@ local WRENCH_MENU = {
|
||||
label = S("Handover to A"),
|
||||
tooltip = S("Number of the previous movecontroller"),
|
||||
default = "",
|
||||
check = techage.check_numbers,
|
||||
},
|
||||
{
|
||||
type = "float",
|
||||
|
Loading…
Reference in New Issue
Block a user