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, "")
|
return player_inv_needed, table.concat(tbl, "")
|
||||||
end
|
end
|
||||||
|
|
||||||
local function value_check(elem, value)
|
local function value_check(elem, value, player_name)
|
||||||
if elem.check then
|
if elem.check then
|
||||||
return elem.check(value)
|
return elem.check(value, player_name)
|
||||||
end
|
end
|
||||||
return value ~= nil
|
return value ~= nil
|
||||||
end
|
end
|
||||||
@ -159,7 +159,7 @@ local function evaluate_data(pos, meta, form_def, fields, player_name)
|
|||||||
meta:set_string(elem.name, "")
|
meta:set_string(elem.name, "")
|
||||||
elseif fields[elem.name]:find("^[%d ]+$") then
|
elseif fields[elem.name]:find("^[%d ]+$") then
|
||||||
local val = tonumber(fields[elem.name])
|
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)
|
meta:set_int(elem.name, val)
|
||||||
--print("set_int", elem.name, val)
|
--print("set_int", elem.name, val)
|
||||||
else
|
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
|
||||||
if fields[elem.name] == "" then
|
if fields[elem.name] == "" then
|
||||||
meta:set_string(elem.name, "")
|
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])
|
meta:set_string(elem.name, fields[elem.name])
|
||||||
else
|
else
|
||||||
res = false
|
res = false
|
||||||
@ -184,7 +185,7 @@ local function evaluate_data(pos, meta, form_def, fields, player_name)
|
|||||||
meta:set_string(elem.name, "")
|
meta:set_string(elem.name, "")
|
||||||
elseif fields[elem.name] then
|
elseif fields[elem.name] then
|
||||||
local val = tonumber(fields[elem.name])
|
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)
|
meta:set_string(elem.name, val)
|
||||||
else
|
else
|
||||||
res = false
|
res = false
|
||||||
@ -194,7 +195,7 @@ 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, "")
|
meta:set_string(elem.name, "")
|
||||||
elseif fields[elem.name] then
|
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])
|
meta:set_string(elem.name, fields[elem.name])
|
||||||
else
|
else
|
||||||
res = false
|
res = false
|
||||||
|
@ -1633,7 +1633,7 @@ techage.manual_DE.aText = {
|
|||||||
"\n"..
|
"\n"..
|
||||||
"\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"..
|
"\n"..
|
||||||
"\n",
|
"\n",
|
||||||
|
@ -1639,7 +1639,7 @@ techage.manual_EN.aText = {
|
|||||||
"\n"..
|
"\n"..
|
||||||
"\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"..
|
"\n"..
|
||||||
"\n",
|
"\n",
|
||||||
|
@ -114,7 +114,11 @@ TA3 Booster=TA3 Gebläse
|
|||||||
### button.lua ###
|
### button.lua ###
|
||||||
|
|
||||||
Access:=Zugriff:
|
Access:=Zugriff:
|
||||||
|
Button or switch=Taster oder Schalter
|
||||||
|
Change the block name (infotext)=Ändere den Blocknamen
|
||||||
Command to be sent=Zu sendender Befehl
|
Command to be sent=Zu sendender Befehl
|
||||||
|
Destination block number(s)=Zielblocknummer
|
||||||
|
Infotext=Infotext
|
||||||
TA3 Button/Switch=TA3 Taster/Schalter
|
TA3 Button/Switch=TA3 Taster/Schalter
|
||||||
TA4 Button/Switch=TA4 Schalter/Taster
|
TA4 Button/Switch=TA4 Schalter/Taster
|
||||||
|
|
||||||
@ -122,7 +126,11 @@ TA4 Button/Switch=TA4 Schalter/Taster
|
|||||||
### button_2x.lua ###
|
### button_2x.lua ###
|
||||||
### button_4x.lua ###
|
### button_4x.lua ###
|
||||||
|
|
||||||
|
Access=Zugriff
|
||||||
|
Button protection=Tastenschutz
|
||||||
Command=Kommando
|
Command=Kommando
|
||||||
|
Number=Nummer
|
||||||
|
Type=Typ
|
||||||
|
|
||||||
### button.lua ###
|
### button.lua ###
|
||||||
### cart_detector.lua ###
|
### cart_detector.lua ###
|
||||||
@ -154,14 +162,10 @@ TA4 2x Button=TA4 2x Taster
|
|||||||
### button_2x.lua ###
|
### button_2x.lua ###
|
||||||
### button_4x.lua ###
|
### button_4x.lua ###
|
||||||
|
|
||||||
Access=Zugriff
|
|
||||||
Button protection=Tastenschutz
|
|
||||||
Command to be sent (ignored for switches)=Zu sendender Befehl (wird für Schalter ignoriert)
|
Command to be sent (ignored for switches)=Zu sendender Befehl (wird für Schalter ignoriert)
|
||||||
Destination block number=Zielblocknummer
|
Destination block number=Zielblocknummer
|
||||||
Label for the button=Beschriftung für die Taste
|
Label for the button=Beschriftung für die Taste
|
||||||
Momentary button or on/off switch=Taster oder Ein-/Ausschalter
|
Momentary button or on/off switch=Taster oder Ein-/Ausschalter
|
||||||
Number=Nummer
|
|
||||||
Type=Typ
|
|
||||||
|
|
||||||
### button_2x.lua ###
|
### button_2x.lua ###
|
||||||
### button_4x.lua ###
|
### button_4x.lua ###
|
||||||
|
@ -114,7 +114,11 @@ TA3 Booster=
|
|||||||
### button.lua ###
|
### button.lua ###
|
||||||
|
|
||||||
Access:=
|
Access:=
|
||||||
|
Button or switch=
|
||||||
|
Change the node name (infotext)=
|
||||||
Command to be sent=
|
Command to be sent=
|
||||||
|
Destination block number(s)=
|
||||||
|
Infotext=
|
||||||
TA3 Button/Switch=
|
TA3 Button/Switch=
|
||||||
TA4 Button/Switch=
|
TA4 Button/Switch=
|
||||||
|
|
||||||
@ -122,7 +126,11 @@ TA4 Button/Switch=
|
|||||||
### button_2x.lua ###
|
### button_2x.lua ###
|
||||||
### button_4x.lua ###
|
### button_4x.lua ###
|
||||||
|
|
||||||
|
Access=
|
||||||
|
Button protection=
|
||||||
Command=
|
Command=
|
||||||
|
Number=
|
||||||
|
Type=
|
||||||
|
|
||||||
### button.lua ###
|
### button.lua ###
|
||||||
### cart_detector.lua ###
|
### cart_detector.lua ###
|
||||||
@ -154,14 +162,10 @@ TA4 2x Button=
|
|||||||
### button_2x.lua ###
|
### button_2x.lua ###
|
||||||
### button_4x.lua ###
|
### button_4x.lua ###
|
||||||
|
|
||||||
Access=
|
|
||||||
Button protection=
|
|
||||||
Command to be sent (ignored for switches)=
|
Command to be sent (ignored for switches)=
|
||||||
Destination block number=
|
Destination block number=
|
||||||
Label for the button=
|
Label for the button=
|
||||||
Momentary button or on/off switch=
|
Momentary button or on/off switch=
|
||||||
Number=
|
|
||||||
Type=
|
|
||||||
|
|
||||||
### button_2x.lua ###
|
### button_2x.lua ###
|
||||||
### button_4x.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 logic = techage.logic
|
||||||
|
|
||||||
local WRENCH_MENU = {
|
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",
|
type = "ascii",
|
||||||
name = "command",
|
name = "command",
|
||||||
@ -27,6 +43,21 @@ local WRENCH_MENU = {
|
|||||||
tooltip = S("Command to be sent"),
|
tooltip = S("Command to be sent"),
|
||||||
default = "on",
|
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)
|
local function switch_on(pos)
|
||||||
@ -81,14 +112,8 @@ local function formspec(meta)
|
|||||||
"button_exit[2,4;3,1;exit;"..S("Save").."]"
|
"button_exit[2,4;3,1;exit;"..S("Save").."]"
|
||||||
end
|
end
|
||||||
|
|
||||||
local function on_receive_fields(pos, formname, fields, player)
|
local function store_fields_data(pos, fields)
|
||||||
if minetest.is_protected(pos, player:get_player_name()) then
|
|
||||||
return
|
|
||||||
end
|
|
||||||
local meta = M(pos)
|
local meta = M(pos)
|
||||||
if not techage.check_numbers(fields.numbers, player:get_player_name()) then
|
|
||||||
return
|
|
||||||
end
|
|
||||||
meta:set_string("numbers", fields.numbers)
|
meta:set_string("numbers", fields.numbers)
|
||||||
if fields.access == "protected" then
|
if fields.access == "protected" then
|
||||||
meta:set_string("protected", "true")
|
meta:set_string("protected", "true")
|
||||||
@ -128,6 +153,20 @@ local function on_receive_fields(pos, formname, fields, player)
|
|||||||
if cycle_time ~= nil then
|
if cycle_time ~= nil then
|
||||||
meta:set_int("cycle_time", cycle_time)
|
meta:set_int("cycle_time", cycle_time)
|
||||||
end
|
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)
|
logic.infotext(meta, NDEF(pos).description)
|
||||||
if fields.exit then
|
if fields.exit then
|
||||||
meta:set_string("formspec", nil)
|
meta:set_string("formspec", nil)
|
||||||
@ -137,6 +176,16 @@ local function on_receive_fields(pos, formname, fields, player)
|
|||||||
end
|
end
|
||||||
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 function can_access(pos, player)
|
||||||
local meta = M(pos)
|
local meta = M(pos)
|
||||||
local public = meta:get_string("public") == "true"
|
local public = meta:get_string("public") == "true"
|
||||||
@ -269,6 +318,7 @@ minetest.register_node("techage:ta4_button_off", {
|
|||||||
end,
|
end,
|
||||||
|
|
||||||
ta4_formspec = WRENCH_MENU,
|
ta4_formspec = WRENCH_MENU,
|
||||||
|
ta_after_formspec = ta_after_formspec,
|
||||||
on_receive_fields = on_receive_fields,
|
on_receive_fields = on_receive_fields,
|
||||||
on_rightclick = on_rightclick_on,
|
on_rightclick = on_rightclick_on,
|
||||||
techage_set_numbers = techage_set_numbers,
|
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_rightclick = on_rightclick_off,
|
||||||
on_timer = switch_off,
|
on_timer = switch_off,
|
||||||
on_rotate = screwdriver.disallow,
|
on_rotate = screwdriver.disallow,
|
||||||
|
@ -55,6 +55,7 @@ local WRENCH_MENU = {
|
|||||||
label = S("Number") .. " 1",
|
label = S("Number") .. " 1",
|
||||||
tooltip = S("Destination block number"),
|
tooltip = S("Destination block number"),
|
||||||
default = "",
|
default = "",
|
||||||
|
check = techage.check_numbers,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
type = "ascii",
|
type = "ascii",
|
||||||
@ -76,6 +77,7 @@ local WRENCH_MENU = {
|
|||||||
label = S("Number") .. " 2",
|
label = S("Number") .. " 2",
|
||||||
tooltip = S("Destination block number"),
|
tooltip = S("Destination block number"),
|
||||||
default = "",
|
default = "",
|
||||||
|
check = techage.check_numbers,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
type = "ascii",
|
type = "ascii",
|
||||||
|
@ -59,6 +59,7 @@ local WRENCH_MENU = {
|
|||||||
label = S("Number") .. " 1",
|
label = S("Number") .. " 1",
|
||||||
tooltip = S("Destination block number"),
|
tooltip = S("Destination block number"),
|
||||||
default = "",
|
default = "",
|
||||||
|
check = techage.check_numbers,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
type = "ascii",
|
type = "ascii",
|
||||||
@ -80,6 +81,7 @@ local WRENCH_MENU = {
|
|||||||
label = S("Number") .. " 2",
|
label = S("Number") .. " 2",
|
||||||
tooltip = S("Destination block number"),
|
tooltip = S("Destination block number"),
|
||||||
default = "",
|
default = "",
|
||||||
|
check = techage.check_numbers,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
type = "ascii",
|
type = "ascii",
|
||||||
@ -101,6 +103,7 @@ local WRENCH_MENU = {
|
|||||||
label = S("Number") .. " 3",
|
label = S("Number") .. " 3",
|
||||||
tooltip = S("Destination block number"),
|
tooltip = S("Destination block number"),
|
||||||
default = "",
|
default = "",
|
||||||
|
check = techage.check_numbers,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
type = "ascii",
|
type = "ascii",
|
||||||
@ -122,6 +125,7 @@ local WRENCH_MENU = {
|
|||||||
label = S("Number") .. " 4",
|
label = S("Number") .. " 4",
|
||||||
tooltip = S("Destination block number"),
|
tooltip = S("Destination block number"),
|
||||||
default = "",
|
default = "",
|
||||||
|
check = techage.check_numbers,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
type = "ascii",
|
type = "ascii",
|
||||||
|
@ -467,7 +467,7 @@ Das Terminal dient zur Ein-/Ausgabe für den Lua Controller.
|
|||||||
|
|
||||||
### TA4 Taster/Schalter / Button/Switch
|
### 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]
|
[ta4_button|image]
|
||||||
|
|
||||||
|
@ -459,7 +459,7 @@ The terminal is used for input / output for the Lua controller.
|
|||||||
|
|
||||||
### TA4 Button/Switch
|
### 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]
|
[ta4_button|image]
|
||||||
|
|
||||||
|
@ -46,7 +46,7 @@ local WRENCH_MENU = {
|
|||||||
|
|
||||||
local function formspec(nvm, meta)
|
local function formspec(nvm, meta)
|
||||||
local status = meta:get_string("status")
|
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"
|
meta:contains("path") and meta:get_string("path") or "0,3,0"
|
||||||
return "size[8,6.7]" ..
|
return "size[8,6.7]" ..
|
||||||
"style_type[textarea;font=mono;textcolor=#FFFFFF;border=true]" ..
|
"style_type[textarea;font=mono;textcolor=#FFFFFF;border=true]" ..
|
||||||
|
@ -40,6 +40,7 @@ local WRENCH_MENU = {
|
|||||||
label = S("Handover to B"),
|
label = S("Handover to B"),
|
||||||
tooltip = S("Number of the next movecontroller"),
|
tooltip = S("Number of the next movecontroller"),
|
||||||
default = "",
|
default = "",
|
||||||
|
check = techage.check_numbers,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
type = "number",
|
type = "number",
|
||||||
@ -47,6 +48,7 @@ local WRENCH_MENU = {
|
|||||||
label = S("Handover to A"),
|
label = S("Handover to A"),
|
||||||
tooltip = S("Number of the previous movecontroller"),
|
tooltip = S("Number of the previous movecontroller"),
|
||||||
default = "",
|
default = "",
|
||||||
|
check = techage.check_numbers,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
type = "float",
|
type = "float",
|
||||||
|
Loading…
Reference in New Issue
Block a user