Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions filter-injector.lua
Original file line number Diff line number Diff line change
Expand Up @@ -439,6 +439,9 @@ for _, data in ipairs({
return count
end,
tube = {connect_sides = {right = 1}},
_update_formspec = function(pos)
set_filter_formspec(data, core.get_meta(pos))
end,
}

if data.digiline then
Expand Down
22 changes: 21 additions & 1 deletion fs_helpers.lua
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ local insert = table.insert
local has_mcl = core.get_modpath("mcl_formspec")
local has_i3 = core.get_modpath("i3")

local fs_helpers = {}
local fs_helpers = {version = 2}
pipeworks.fs_helpers = fs_helpers

-- Pipeworks formspec standard:
Expand Down Expand Up @@ -152,6 +152,26 @@ function fs_helpers.inv_list(x, y, w, h, list, desc)
return table.concat(fs)
end

core.register_on_mods_loaded(function()
local nodenames = {}
local update_functions = {}
for name, def in pairs(core.registered_nodes) do
if type(def._update_formspec) == "function" then
insert(nodenames, name)
update_functions[name] = def._update_formspec
end
end
core.register_lbm({
label = "Pipeworks Formspec Update",
name = ":pipeworks:fs_update_v"..fs_helpers.version,
nodenames = nodenames,
run_at_every_load = false,
action = function(pos, node)
update_functions[node.name](pos)
end,
})
end)

-- Deprecated, but kept for compatibility
pipeworks.button_off = {
text = "",
Expand Down
18 changes: 11 additions & 7 deletions trashcan.lua
Original file line number Diff line number Diff line change
@@ -1,6 +1,13 @@
local S = core.get_translator("pipeworks")
local fs_helpers = pipeworks.fs_helpers

local formspec = table.concat({
fs_helpers.prepends(10.25, 8.5),
fs_helpers.node_label("pipeworks:trashcan", S("Trash Can")),
fs_helpers.inv_list(4.625, 1.25, 1, 1, "trash"),
fs_helpers.player_inv(0.25, 3.5),
})

core.register_node("pipeworks:trashcan", {
description = S("Trash Can"),
drawtype = "normal",
Expand All @@ -24,13 +31,7 @@ core.register_node("pipeworks:trashcan", {
},
on_construct = function(pos)
local meta = core.get_meta(pos)
local fs = table.concat({
fs_helpers.prepends(10.25, 8.5),
fs_helpers.node_label("pipeworks:trashcan"),
fs_helpers.inv_list(4.625, 1.25, 1, 1, "trash"),
fs_helpers.player_inv(0.25, 3.5),
})
meta:set_string("formspec", fs)
meta:set_string("formspec", formspec)
meta:set_string("infotext", S("Trash Can"))
meta:get_inventory():set_size("trash", 1)
end,
Expand All @@ -39,5 +40,8 @@ core.register_node("pipeworks:trashcan", {
on_metadata_inventory_put = function(pos, listname, index, stack, player)
core.get_meta(pos):get_inventory():set_stack(listname, index, ItemStack(""))
end,
_update_formspec = function(pos)
core.get_meta(pos):set_string("formspec", formspec)
end,
})
pipeworks.ui_cat_tube_list[#pipeworks.ui_cat_tube_list+1] = "pipeworks:trashcan"
3 changes: 3 additions & 0 deletions tubes/signal.lua
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,9 @@ if digiline_enabled and pipeworks.enable_digiline_detector_tube then
rules = pipeworks.digilines_rules
},
},
_update_formspec = function(pos)
core.get_meta(pos):set_string("formspec", formspec)
end,
},
})

Expand Down
1 change: 1 addition & 0 deletions tubes/sorting.lua
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,7 @@ if pipeworks.enable_mese_tube then
return 0
end
end,
_update_formspec = update_formspec,
},
})
end
1 change: 1 addition & 0 deletions tubes/tags.lua
Original file line number Diff line number Diff line change
Expand Up @@ -120,5 +120,6 @@ pipeworks.register_tube("pipeworks:tag_tube", {
can_dig = function(pos, player)
return true
end,
_update_formspec = update_formspec,
},
})
3 changes: 3 additions & 0 deletions tubes/teleport.lua
Original file line number Diff line number Diff line change
Expand Up @@ -321,6 +321,9 @@ local def = {
end,
on_receive_fields = receive_fields,
on_destruct = remove_tube,
_update_formspec = function(pos)
update_meta(core.get_meta(pos))
end,
}

if has_digilines then
Expand Down
3 changes: 3 additions & 0 deletions tubes/vacuum.lua
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,9 @@ if pipeworks.enable_mese_sand_tube then
meta:set_string("infotext", S("Adjustable Vacuuming Tube (@1m)", dist))
end,
on_punch = has_vislib and show_area or nil,
_update_formspec = function(pos)
core.get_meta(pos):set_string("formspec", formspec)
end,
},
})
end
Expand Down
3 changes: 3 additions & 0 deletions wielder.lua
Original file line number Diff line number Diff line change
Expand Up @@ -215,6 +215,9 @@ function pipeworks.register_wielder(def)
end
core.get_meta(pos):set_string("channel", fields.channel)
end,
_update_formspec = function(pos)
set_wielder_formspec(def, core.get_meta(pos))
end,
})
end
table.insert(pipeworks.ui_cat_tube_list, def.name.."_off")
Expand Down