mirror of
https://github.com/mt-mods/pipeworks.git
synced 2025-06-30 07:10:45 +02:00
Compare commits
32 Commits
2021-04-14
...
7ee74133e1
Author | SHA1 | Date | |
---|---|---|---|
7ee74133e1 | |||
cec6049dd1 | |||
047718b3c3 | |||
01f4ea066c | |||
7ba685344c | |||
c39d40e940 | |||
48b082e014 | |||
c01bd7b888 | |||
2670fd88a9 | |||
3536004667 | |||
b53a1ee477 | |||
29bac67d3a | |||
e2fdcc4fb2 | |||
e4db1e885e | |||
f7839444cd | |||
93f5fb3d87 | |||
a535bebd2e | |||
be2776fc46 | |||
ee03959a65 | |||
4dd30df37a | |||
946da11206 | |||
77c8026400 | |||
70b521c721 | |||
6d795b7d34 | |||
92249b7941 | |||
e04fb691ad | |||
ac80224371 | |||
34262ed8d5 | |||
5cfe8d893f | |||
975e20f704 | |||
2693e2ecbb | |||
c93df73a5c |
@ -67,8 +67,11 @@ local function run_autocrafter(pos, elapsed)
|
|||||||
local inventory = meta:get_inventory()
|
local inventory = meta:get_inventory()
|
||||||
local craft = get_craft(pos, inventory)
|
local craft = get_craft(pos, inventory)
|
||||||
local output_item = craft.output.item
|
local output_item = craft.output.item
|
||||||
|
-- NALC: existence de limitgroup ?
|
||||||
|
local limitcraft = minetest.get_item_group(output_item:get_name(), "limitcraft") or 0
|
||||||
-- only use crafts that have an actual result
|
-- only use crafts that have an actual result
|
||||||
if output_item:is_empty() then
|
-- NALC: ou si l'item n'est pas dans le group limitcraft
|
||||||
|
if output_item:is_empty() or limitcraft > 0 then
|
||||||
meta:set_string("infotext", S("unconfigured Autocrafter: unknown recipe"))
|
meta:set_string("infotext", S("unconfigured Autocrafter: unknown recipe"))
|
||||||
return false
|
return false
|
||||||
end
|
end
|
||||||
@ -190,8 +193,9 @@ local function update_meta(meta, enabled)
|
|||||||
"listring[context;dst]" ..
|
"listring[context;dst]" ..
|
||||||
"listring[current_player;main]"
|
"listring[current_player;main]"
|
||||||
if minetest.get_modpath("digilines") then
|
if minetest.get_modpath("digilines") then
|
||||||
fs = fs.."field[1,3.5;4,1;channel;"..S("Channel")..";${channel}]"
|
fs = fs.."field[0.3,3.5;4.5,1;channel;"..S("Channel")..";${channel}]"..
|
||||||
fs = fs.."button_exit[5,3.2;2,1;save;"..S("Save").."]"
|
"button[4.5,3.2;1.5,1;set_channel;"..S("Set").."]"..
|
||||||
|
"button_exit[6,3.2;2,1;close;"..S("Close").."]"
|
||||||
end
|
end
|
||||||
meta:set_string("formspec",fs)
|
meta:set_string("formspec",fs)
|
||||||
|
|
||||||
@ -276,7 +280,10 @@ minetest.register_node("pipeworks:autocrafter", {
|
|||||||
update_meta(meta, false)
|
update_meta(meta, false)
|
||||||
end,
|
end,
|
||||||
on_receive_fields = function(pos, formname, fields, sender)
|
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)
|
local meta = minetest.get_meta(pos)
|
||||||
if fields.on then
|
if fields.on then
|
||||||
update_meta(meta, false)
|
update_meta(meta, false)
|
||||||
@ -285,8 +292,9 @@ minetest.register_node("pipeworks:autocrafter", {
|
|||||||
if update_meta(meta, true) then
|
if update_meta(meta, true) then
|
||||||
start_crafter(pos)
|
start_crafter(pos)
|
||||||
end
|
end
|
||||||
elseif fields.save then
|
end
|
||||||
meta:set_string("channel",fields.channel)
|
if fields.channel then
|
||||||
|
meta:set_string("channel", fields.channel)
|
||||||
end
|
end
|
||||||
end,
|
end,
|
||||||
can_dig = function(pos, player)
|
can_dig = function(pos, player)
|
||||||
|
2
init.lua
2
init.lua
@ -151,7 +151,7 @@ minetest.register_alias("pipeworks:pipe", "pipeworks:pipe_110000_empty")
|
|||||||
|
|
||||||
-- Unified Inventory categories integration
|
-- 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
|
if not unified_inventory.registered_categories["automation"] then
|
||||||
unified_inventory.register_category("automation", {
|
unified_inventory.register_category("automation", {
|
||||||
symbol = "pipeworks:lua_tube000000",
|
symbol = "pipeworks:lua_tube000000",
|
||||||
|
@ -666,6 +666,7 @@ local function reset_formspec(meta, code, errmsg)
|
|||||||
code = minetest.formspec_escape(code or "")
|
code = minetest.formspec_escape(code or "")
|
||||||
errmsg = minetest.formspec_escape(tostring(errmsg or ""))
|
errmsg = minetest.formspec_escape(tostring(errmsg or ""))
|
||||||
meta:set_string("formspec", "size[12,10]"
|
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]"
|
.."background[-0.2,-0.25;12.4,10.75;jeija_luac_background.png]"
|
||||||
.."label[0.1,8.3;"..errmsg.."]"
|
.."label[0.1,8.3;"..errmsg.."]"
|
||||||
.."textarea[0.2,0.2;12.2,9.5;code;;"..code.."]"
|
.."textarea[0.2,0.2;12.2,9.5;code;;"..code.."]"
|
||||||
|
@ -110,9 +110,22 @@ if pipeworks.enable_mese_tube then
|
|||||||
update_formspec(pos)
|
update_formspec(pos)
|
||||||
meta:set_string("infotext", S("Sorting pneumatic tube"))
|
meta:set_string("infotext", S("Sorting pneumatic tube"))
|
||||||
end,
|
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_punch = update_formspec,
|
||||||
on_receive_fields = function(pos, formname, fields, sender)
|
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)
|
fs_helpers.on_receive_fields(pos, fields)
|
||||||
update_formspec(pos)
|
update_formspec(pos)
|
||||||
end,
|
end,
|
||||||
|
@ -4,6 +4,9 @@ local filename=minetest.get_worldpath() .. "/teleport_tubes"
|
|||||||
local tp_tube_db = nil -- nil forces a read
|
local tp_tube_db = nil -- nil forces a read
|
||||||
local tp_tube_db_version = 2.0
|
local tp_tube_db_version = 2.0
|
||||||
|
|
||||||
|
-- cached rceiver list: hash(pos) => {receivers}
|
||||||
|
local cache = {}
|
||||||
|
|
||||||
local function hash(pos)
|
local function hash(pos)
|
||||||
return string.format("%.30g", minetest.hash_node_position(pos))
|
return string.format("%.30g", minetest.hash_node_position(pos))
|
||||||
end
|
end
|
||||||
@ -18,6 +21,8 @@ local function save_tube_db()
|
|||||||
else
|
else
|
||||||
error(err)
|
error(err)
|
||||||
end
|
end
|
||||||
|
-- reset tp-tube cache
|
||||||
|
cache = {}
|
||||||
end
|
end
|
||||||
|
|
||||||
local function migrate_tube_db()
|
local function migrate_tube_db()
|
||||||
@ -101,6 +106,12 @@ local function read_node_with_vm(pos)
|
|||||||
end
|
end
|
||||||
|
|
||||||
local function get_receivers(pos, channel)
|
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 tubes = tp_tube_db or read_tube_db()
|
||||||
local receivers = {}
|
local receivers = {}
|
||||||
local dirty = false
|
local dirty = false
|
||||||
@ -121,6 +132,8 @@ local function get_receivers(pos, channel)
|
|||||||
if dirty then
|
if dirty then
|
||||||
save_tube_db()
|
save_tube_db()
|
||||||
end
|
end
|
||||||
|
-- cache the result for next time
|
||||||
|
cache[hash] = receivers
|
||||||
return receivers
|
return receivers
|
||||||
end
|
end
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user