TA4 chest/tank: Add 'public' checkbox to allow public access

master
Joachim Stolberg 2020-10-30 20:46:58 +01:00
parent b5bc1751b5
commit 90e1af7e85
7 changed files with 96 additions and 19 deletions

View File

@ -178,7 +178,7 @@ techage.register_node({"techage:chest_ta2", "techage:chest_ta3"}, {
local function formspec4(pos) local function formspec4(pos)
return "size[10,9]".. return "size[10,9]"..
"tabheader[0,0;tab;"..S("Inventory,Configuration")..";1;;true]".. "tabheader[0,0;tab;"..S("Inventory,Pre-Assignment,Config")..";1;;true]"..
default.gui_bg.. default.gui_bg..
default.gui_bg_img.. default.gui_bg_img..
default.gui_slots.. default.gui_slots..
@ -189,9 +189,9 @@ local function formspec4(pos)
"listring[current_player;main]" "listring[current_player;main]"
end end
local function formspec4_cfg(pos) local function formspec4_pre(pos)
return "size[10,9]".. return "size[10,9]"..
"tabheader[0,0;tab;"..S("Inventory,Configuration")..";2;;true]".. "tabheader[0,0;tab;"..S("Inventory,Pre-Assignment,Config")..";2;;true]"..
default.gui_bg.. default.gui_bg..
default.gui_bg_img.. default.gui_bg_img..
default.gui_slots.. default.gui_slots..
@ -201,8 +201,23 @@ local function formspec4_cfg(pos)
"listring[current_player;main]" "listring[current_player;main]"
end end
local function formspec4_cfg(pos)
local meta = minetest.get_meta(pos)
local label = meta:get_string("label") or ""
local public = dump((meta:get_int("public") or 0) == 1)
return "size[10,5]"..
"tabheader[0,0;tab;"..S("Inventory,Pre-Assignment,Config")..";3;;true]"..
default.gui_bg..
default.gui_bg_img..
default.gui_slots..
"field[0.5,1;9,1;label;"..S("Node label:")..";"..label.."]" ..
"checkbox[1,2;public;"..S("Allow public access to the chest")..";"..public.."]"..
"button_exit[3.5,4;3,1;exit;"..S("Save").."]"
end
local function ta4_allow_metadata_inventory_put(pos, listname, index, stack, player) local function ta4_allow_metadata_inventory_put(pos, listname, index, stack, player)
if minetest.is_protected(pos, player:get_player_name()) then local public = M(pos):get_int("public") == 1
if not public and minetest.is_protected(pos, player:get_player_name()) then
return 0 return 0
end end
@ -214,7 +229,8 @@ local function ta4_allow_metadata_inventory_put(pos, listname, index, stack, pla
end end
local function ta4_allow_metadata_inventory_take(pos, listname, index, stack, player) local function ta4_allow_metadata_inventory_take(pos, listname, index, stack, player)
if minetest.is_protected(pos, player:get_player_name()) then local public = M(pos):get_int("public") == 1
if not public and minetest.is_protected(pos, player:get_player_name()) then
return 0 return 0
end end
@ -226,7 +242,8 @@ local function ta4_allow_metadata_inventory_take(pos, listname, index, stack, pl
end end
local function ta4_allow_metadata_inventory_move(pos, from_list, from_index, to_list, to_index, count, player) local function ta4_allow_metadata_inventory_move(pos, from_list, from_index, to_list, to_index, count, player)
if minetest.is_protected(pos, player:get_player_name()) then local public = M(pos):get_int("public") == 1
if not public and minetest.is_protected(pos, player:get_player_name()) then
return 0 return 0
end end
@ -276,10 +293,25 @@ minetest.register_node("techage:chest_ta4", {
mem.filter = nil mem.filter = nil
meta:set_string("formspec", formspec4(pos)) meta:set_string("formspec", formspec4(pos))
elseif fields.tab == "2" then elseif fields.tab == "2" then
meta:set_string("formspec", formspec4_pre(pos))
elseif fields.tab == "3" then
meta:set_string("formspec", formspec4_cfg(pos)) meta:set_string("formspec", formspec4_cfg(pos))
elseif fields.quit == "true" then elseif fields.quit == "true" then
mem.filter = nil mem.filter = nil
end end
if fields.public then
meta:set_int("public", fields.public == "true" and 1 or 0)
end
if fields.exit then
local number = meta:get_string("node_number")
if fields.label ~= "" then
meta:set_string("infotext", minetest.formspec_escape(fields.label).." #"..number)
else
meta:set_string("infotext", S("TA4 Protected Chest").." "..number)
end
meta:set_string("label", fields.label)
meta:set_string("formspec", formspec4_cfg(pos))
end
end, end,
techage_set_numbers = function(pos, numbers, player_name) techage_set_numbers = function(pos, numbers, player_name)

View File

@ -36,14 +36,28 @@ function techage.liquid.formspec(pos, nvm)
if nvm.liquid and nvm.liquid.amount and nvm.liquid.amount > 0 and nvm.liquid.name then if nvm.liquid and nvm.liquid.amount and nvm.liquid.amount > 0 and nvm.liquid.name then
itemname = nvm.liquid.name.." "..nvm.liquid.amount itemname = nvm.liquid.name.." "..nvm.liquid.amount
end end
return "size[4,2]".. local name = minetest.get_node(pos).name
default.gui_bg.. if name == "techage:ta4_tank" then
default.gui_bg_img.. local public = dump((M(pos):get_int("public") or 0) == 1)
default.gui_slots.. return "size[5,3]"..
"box[0,-0.1;3.8,0.5;#c6e8ff]".. default.gui_bg..
"label[1,-0.1;"..minetest.colorize("#000000", title).."]".. default.gui_bg_img..
help(3.4, -0.1).. default.gui_slots..
techage.item_image(1.5, 1, itemname) "box[0,-0.1;4.8,0.5;#c6e8ff]"..
"label[1.5,-0.1;"..minetest.colorize("#000000", title).."]"..
help(4.4, -0.1)..
techage.item_image(2, 1, itemname)..
"checkbox[0.1,2.5;public;"..S("Allow public access to the tank")..";"..public.."]"
else
return "size[4,2]"..
default.gui_bg..
default.gui_bg_img..
default.gui_slots..
"box[0,-0.1;3.8,0.5;#c6e8ff]"..
"label[1,-0.1;"..minetest.colorize("#000000", title).."]"..
help(3.4, -0.1)..
techage.item_image(1.5, 1, itemname)
end
end end
function techage.liquid.is_empty(pos) function techage.liquid.is_empty(pos)
@ -205,7 +219,8 @@ local function empty_on_punch(pos, nvm, full_container, item_count)
end end
function techage.liquid.on_punch(pos, node, puncher, pointed_thing) function techage.liquid.on_punch(pos, node, puncher, pointed_thing)
if minetest.is_protected(pos, puncher:get_player_name()) then local public = M(pos):get_int("public") == 1
if not public and minetest.is_protected(pos, puncher:get_player_name()) then
return return
end end

View File

@ -41,7 +41,7 @@ function techage.valid_place_for_windturbine(pos, player_name, num_turbines)
if data then if data then
local name = minetest.get_biome_name(data.biome) local name = minetest.get_biome_name(data.biome)
if not string.find(name, "ocean") then if not string.find(name, "ocean") then
chat_message(player_name, S("This is a "..name.." biome and no ocean!")) chat_message(player_name, S("This is a").." "..name.." "..S("biome and no ocean!"))
return false return false
end end
end end

View File

@ -217,6 +217,14 @@ minetest.register_node("techage:ta4_tank", {
tubelib2_on_update2 = function(pos, outdir, tlib2, node) tubelib2_on_update2 = function(pos, outdir, tlib2, node)
liquid.update_network(pos, outdir) liquid.update_network(pos, outdir)
end, end,
on_receive_fields = function(pos, formname, fields, player)
if minetest.is_protected(pos, player:get_player_name()) then
return
end
if fields.public then
M(pos):set_int("public", fields.public == "true" and 1 or 0)
end
end,
on_timer = node_timer, on_timer = node_timer,
on_punch = liquid.on_punch, on_punch = liquid.on_punch,
after_dig_node = function(pos, oldnode, oldmetadata, digger) after_dig_node = function(pos, oldnode, oldmetadata, digger)

View File

@ -4,6 +4,8 @@
Accu Box=Akkublock Accu Box=Akkublock
Active:=Aktiv: Active:=Aktiv:
All nodes:=Alle Blöcke: All nodes:=Alle Blöcke:
Allow public access to the chest=Erlaube öffentlichen Zugriff auf die Kiste
Allow public access to the tank=Erlaube öffentlichen Zugriff auf den Tank
Allow public chest access=Erlaube öffentlichen Zugriff Allow public chest access=Erlaube öffentlichen Zugriff
Allow to dig/place Techage power lines nearby power poles=Erlaubt TODO Allow to dig/place Techage power lines nearby power poles=Erlaubt TODO
Aluminum=Aluminium Aluminum=Aluminium
@ -85,6 +87,8 @@ Grinder=Mühle
Grinding=Mahlen Grinding=Mahlen
Heat=Hitze Heat=Hitze
Heat Exchanger=Wärmetauscher Heat Exchanger=Wärmetauscher
Here is not enough water (41x41 m)!=Hier ist nicht genug Wasser (41x41 m)!
Here is not enough wind (A free air space of 41x41x21 m is necessary)!=Hier ist nicht genug Wind (Ein freier Luftraum von 41x41x21 m ist notwendig)!
High Performance Distributor=Hochleistungs-Verteiler High Performance Distributor=Hochleistungs-Verteiler
Hole size=Lochgröße Hole size=Lochgröße
Hydrogen Cylinder Large=Wasserstoffflasche groß Hydrogen Cylinder Large=Wasserstoffflasche groß
@ -95,7 +99,7 @@ Input=Einspeisung
Insert destination node number(s)=Gebe Zielnummer(n) ein Insert destination node number(s)=Gebe Zielnummer(n) ein
Insert door/gate block number(s)=Gebe Tür-/Tornummer(n) ein Insert door/gate block number(s)=Gebe Tür-/Tornummer(n) ein
Intake=Stromaufnahme Intake=Stromaufnahme
Inventory,Configuration=Inventar,Konfiguration Inventory,Pre-Assignment,Config=Inventar,Vorbelegung,Konfiguration
Inverter=Wechselrichter Inverter=Wechselrichter
Iron Powder=Eisen Pulver Iron Powder=Eisen Pulver
Leave Powder=Laub Pulver Leave Powder=Laub Pulver
@ -128,6 +132,7 @@ No network or active generator available!=Kein Stromnetz oder aktiver Generator
No plan available=Kein Plan verfügar No plan available=Kein Plan verfügar
No power grid or running generator!=Kein Stromnetz oder Generator verfügbar! No power grid or running generator!=Kein Stromnetz oder Generator verfügbar!
No wind at this altitude!=Kein Wind auf dieser Höhe No wind at this altitude!=Kein Wind auf dieser Höhe
Node label:= Blockbeschriftung:
Node number to send the events to=Knotennummer zum Senden der Events Node number to send the events to=Knotennummer zum Senden der Events
Node numbers to read the states from=Knotennummern zum Lesen der Zustände Node numbers to read the states from=Knotennummern zum Lesen der Zustände
Node owner=Blockbesitzer Node owner=Blockbesitzer
@ -379,8 +384,12 @@ Techage Forceload Block=Techage Forceload Block
Techage Forceload Tile=Techage Forceload Kachel Techage Forceload Tile=Techage Forceload Kachel
The network is overloaded!=Das Stromnetz ist überlastet! The network is overloaded!=Das Stromnetz ist überlastet!
The network load is almost at the limit!=Das Stromnetz ist ziemlich am Limit! The network load is almost at the limit!=Das Stromnetz ist ziemlich am Limit!
The next wind turbines is too close!= Die nächste Windkraftanlagen iat zu nahe!
The wind turbines are too close together!=Die Windkraftanlagen stehen zu eng beisammen! The wind turbines are too close together!=Die Windkraftanlagen stehen zu eng beisammen!
Thermal=Wärme Thermal=Wärme
This is a=Dies ist ein
This is no ocean water!= Dies ist kein Meerwasser!
This is not the surface of the ocean!=Das ist nicht die Meeresoberfläche!
Time=Zeit Time=Zeit
Tiny Generator=Kleingenerator Tiny Generator=Kleingenerator
Tiny generator=Kleingenerator Tiny generator=Kleingenerator
@ -420,6 +429,7 @@ accept=akzeptieren
added=hinzugefügt wird added=hinzugefügt wird
added or removed=hinzugefügt oder entfernt wird added or removed=hinzugefügt oder entfernt wird
area is protected=Bereich ist geschützt area is protected=Bereich ist geschützt
biome and no ocean!=Biom und keine Meer (ocean)!
blocking mode=Blockiert blocking mode=Blockiert
catalyst missing=Katalysator fehlt catalyst missing=Katalysator fehlt
commands like: help=Kommandos wie: help commands like: help=Kommandos wie: help
@ -431,6 +441,7 @@ finished=fertig
full=voll full=voll
inlet/pipe error=Einlass/Röhrenfehler inlet/pipe error=Einlass/Röhrenfehler
inventory full=Inventar ist voll inventory full=Inventar ist voll
is a suitable place for a wind turbine!=ist ein geeigneter Ort für eine Windkraftanlage!
item output blocked=Ausgang blockiert item output blocked=Ausgang blockiert
keep assignment=Zuordnung beibehalten keep assignment=Zuordnung beibehalten
ku is needed=ku wird benötigt ku is needed=ku wird benötigt

View File

@ -2,6 +2,8 @@
Accu Box= Accu Box=
Active:= Active:=
All nodes:= All nodes:=
Allow public access to the chest=
Allow public access to the tank=
Allow public chest access= Allow public chest access=
Allow to dig/place Techage power lines nearby power poles= Allow to dig/place Techage power lines nearby power poles=
Aluminum= Aluminum=
@ -83,6 +85,8 @@ Grinder=
Grinding= Grinding=
Heat= Heat=
Heat Exchanger= Heat Exchanger=
Here is not enough water (41x41 m)!=
Here is not enough wind (A free air space of 41x41x21 m is necessary)!=
High Performance Distributor= High Performance Distributor=
Hole size= Hole size=
Hydrogen Cylinder Large= Hydrogen Cylinder Large=
@ -93,7 +97,7 @@ Input=
Insert destination node number(s)= Insert destination node number(s)=
Insert door/gate block number(s)= Insert door/gate block number(s)=
Intake= Intake=
Inventory,Configuration= Inventory,Pre-Assignment,Config=
Inverter= Inverter=
Iron Powder= Iron Powder=
Leave Powder= Leave Powder=
@ -126,6 +130,7 @@ No network or active generator available!=
No plan available= No plan available=
No power grid or running generator!= No power grid or running generator!=
No wind at this altitude!= No wind at this altitude!=
Node label:=
Node number to send the events to= Node number to send the events to=
Node numbers to read the states from= Node numbers to read the states from=
Node owner= Node owner=
@ -377,8 +382,12 @@ Techage Forceload Block=
Techage Forceload Tile= Techage Forceload Tile=
The network is overloaded!= The network is overloaded!=
The network load is almost at the limit!= The network load is almost at the limit!=
The next wind turbines is too close!=
The wind turbines are too close together!= The wind turbines are too close together!=
Thermal= Thermal=
This is a=
This is no ocean water!=
This is not the surface of the ocean!=
Time= Time=
Tiny Generator= Tiny Generator=
Tiny generator= Tiny generator=
@ -418,6 +427,7 @@ accept=
added= added=
added or removed= added or removed=
area is protected= area is protected=
biome and no ocean!=
blocking mode= blocking mode=
catalyst missing= catalyst missing=
commands like: help= commands like: help=
@ -429,6 +439,7 @@ finished=
full= full=
inlet/pipe error= inlet/pipe error=
inventory full= inventory full=
is a suitable place for a wind turbine!=
item output blocked= item output blocked=
keep assignment= keep assignment=
ku is needed= ku is needed=

View File

@ -579,7 +579,7 @@ The TA4 8x2000 chest does not have a normal inventory like other chest, but has
If the chest is filled with a pusher, all stores fill from left to right. If all 8 stores are full and no further items can be added, further items are rejected. If the chest is filled with a pusher, all stores fill from left to right. If all 8 stores are full and no further items can be added, further items are rejected.
** Row function ** **Row function**
Several TA4 8x2000 chests can be connected to a large chest with more content. To do this, the chests must be placed in a row one after the other. Several TA4 8x2000 chests can be connected to a large chest with more content. To do this, the chests must be placed in a row one after the other.