12 Commits

Author SHA1 Message Date
7ee74133e1 Merge remote-tracking branch 'upstream/master' 2021-06-20 17:21:30 +02:00
cec6049dd1 Merge branch 'tptube-cache-v2' into 'master'
add caching layer to teleport tube

See merge request VanessaE/pipeworks!46
2021-06-01 17:17:34 +00:00
047718b3c3 add caching layer to teleport tube 2021-06-01 18:57:59 +02:00
01f4ea066c Merge branch 'master' into 'master'
Fix autocrafter to match formspec changes and fix setting of channel

See merge request VanessaE/pipeworks!45
2021-05-29 12:22:42 +00:00
7ba685344c fix autocrafter 2021-05-29 17:37:10 +10:00
c39d40e940 Merge branch 'fix_undeclared' into 'master'
Fix Undeclared Global Variable "unified_inventory"

See merge request VanessaE/pipeworks!44
2021-05-14 04:08:02 +00:00
48b082e014 Fix Undeclared global variable "unified_inventory" 2021-05-13 10:57:58 -07:00
c01bd7b888 Merge remote-tracking branch 'upstream/master' 2021-05-09 21:42:46 +02:00
2670fd88a9 Merge branch 'lua-tube-mono' into 'master'
Make the LUA tube editor textarea and error label use monospaced font

See merge request VanessaE/pipeworks!43
2021-05-06 18:21:59 +00:00
3536004667 Merge branch 'fix-protection-check' into 'master'
Skip protection check on formspec close (where not already done)

See merge request VanessaE/pipeworks!42
2021-05-06 18:21:42 +00:00
b53a1ee477 Make LUA editor and error label use mono font 2021-05-06 18:28:47 +02:00
29bac67d3a Skip protection check on formspec close
Prevents protector flip/player being hurt/protection violation if the
player closes the formspec without attempting any changes (sorting tube
and autocrafter).
2021-05-06 18:02:19 +02:00
5 changed files with 39 additions and 7 deletions

View File

@ -193,8 +193,9 @@ local function update_meta(meta, enabled)
"listring[context;dst]" ..
"listring[current_player;main]"
if minetest.get_modpath("digilines") then
fs = fs.."field[1,3.5;4,1;channel;"..S("Channel")..";${channel}]"
fs = fs.."button_exit[5,3.2;2,1;save;"..S("Save").."]"
fs = fs.."field[0.3,3.5;4.5,1;channel;"..S("Channel")..";${channel}]"..
"button[4.5,3.2;1.5,1;set_channel;"..S("Set").."]"..
"button_exit[6,3.2;2,1;close;"..S("Close").."]"
end
meta:set_string("formspec",fs)
@ -279,7 +280,10 @@ minetest.register_node("pipeworks:autocrafter", {
update_meta(meta, false)
end,
on_receive_fields = function(pos, formname, fields, sender)
if not pipeworks.may_configure(pos, sender) then return end
if not fields.channel or (fields.quit and not fields.key_enter_field)
or not pipeworks.may_configure(pos, sender) then
return
end
local meta = minetest.get_meta(pos)
if fields.on then
update_meta(meta, false)
@ -288,8 +292,9 @@ minetest.register_node("pipeworks:autocrafter", {
if update_meta(meta, true) then
start_crafter(pos)
end
elseif fields.save then
meta:set_string("channel",fields.channel)
end
if fields.channel then
meta:set_string("channel", fields.channel)
end
end,
can_dig = function(pos, player)

View File

@ -151,7 +151,7 @@ minetest.register_alias("pipeworks:pipe", "pipeworks:pipe_110000_empty")
-- Unified Inventory categories integration
if unified_inventory and unified_inventory.registered_categories then
if minetest.global_exists("unified_inventory") and unified_inventory.registered_categories then
if not unified_inventory.registered_categories["automation"] then
unified_inventory.register_category("automation", {
symbol = "pipeworks:lua_tube000000",

View File

@ -666,6 +666,7 @@ local function reset_formspec(meta, code, errmsg)
code = minetest.formspec_escape(code or "")
errmsg = minetest.formspec_escape(tostring(errmsg or ""))
meta:set_string("formspec", "size[12,10]"
.."style_type[label,textarea;font=mono]"
.."background[-0.2,-0.25;12.4,10.75;jeija_luac_background.png]"
.."label[0.1,8.3;"..errmsg.."]"
.."textarea[0.2,0.2;12.2,9.5;code;;"..code.."]"

View File

@ -110,9 +110,22 @@ if pipeworks.enable_mese_tube then
update_formspec(pos)
meta:set_string("infotext", S("Sorting pneumatic tube"))
end,
after_place_node = function(pos, placer, itemstack, pointed_thing)
if placer and placer:is_player() and placer:get_player_control().aux1 then
local meta = minetest.get_meta(pos)
for i = 1, 6 do
meta:set_int("l"..tostring(i).."s", 0)
end
update_formspec(pos)
end
return pipeworks.after_place(pos, placer, itemstack, pointed_thing)
end,
on_punch = update_formspec,
on_receive_fields = function(pos, formname, fields, sender)
if not pipeworks.may_configure(pos, sender) then return end
if (fields.quit and not fields.key_enter_field)
or not pipeworks.may_configure(pos, sender) then
return
end
fs_helpers.on_receive_fields(pos, fields)
update_formspec(pos)
end,

View File

@ -4,6 +4,9 @@ local filename=minetest.get_worldpath() .. "/teleport_tubes"
local tp_tube_db = nil -- nil forces a read
local tp_tube_db_version = 2.0
-- cached rceiver list: hash(pos) => {receivers}
local cache = {}
local function hash(pos)
return string.format("%.30g", minetest.hash_node_position(pos))
end
@ -18,6 +21,8 @@ local function save_tube_db()
else
error(err)
end
-- reset tp-tube cache
cache = {}
end
local function migrate_tube_db()
@ -101,6 +106,12 @@ local function read_node_with_vm(pos)
end
local function get_receivers(pos, channel)
local hash = minetest.hash_node_position(pos)
if cache[hash] then
-- re-use cached result
return cache[hash]
end
local tubes = tp_tube_db or read_tube_db()
local receivers = {}
local dirty = false
@ -121,6 +132,8 @@ local function get_receivers(pos, channel)
if dirty then
save_tube_db()
end
-- cache the result for next time
cache[hash] = receivers
return receivers
end