mirror of
https://github.com/mt-mods/pipeworks.git
synced 2025-06-29 06:40:37 +02:00
Compare commits
1 Commits
master
...
chest-dupe
Author | SHA1 | Date | |
---|---|---|---|
3a01f3f8ca |
2
.github/workflows/luacheck.yml
vendored
2
.github/workflows/luacheck.yml
vendored
@ -7,4 +7,4 @@ jobs:
|
||||
- name: Checkout
|
||||
uses: actions/checkout@master
|
||||
- name: Luacheck
|
||||
uses: lunarmodules/luacheck@master
|
||||
uses: lunarmodules/luacheck@master
|
2
.gitignore
vendored
2
.gitignore
vendored
@ -1,4 +1,4 @@
|
||||
## Files related to luanti development cycle
|
||||
## Files related to minetest development cycle
|
||||
/*.patch
|
||||
# GNU Patch reject file
|
||||
*.rej
|
||||
|
17
.luacheckrc
17
.luacheckrc
@ -1,7 +1,6 @@
|
||||
unused_args = false
|
||||
max_line_length= 240
|
||||
redefined = false
|
||||
std = "minetest+max"
|
||||
|
||||
globals = {
|
||||
"pipeworks",
|
||||
@ -9,11 +8,19 @@ globals = {
|
||||
}
|
||||
|
||||
read_globals = {
|
||||
-- remove after luacheck release: https://github.com/lunarmodules/luacheck/issues/121
|
||||
"core",
|
||||
-- Stdlib
|
||||
string = {fields = {"split"}},
|
||||
table = {fields = {"copy", "getn"}},
|
||||
|
||||
-- Minetest
|
||||
"vector", "ItemStack",
|
||||
"dump", "minetest",
|
||||
"VoxelManip", "VoxelArea",
|
||||
|
||||
-- mods
|
||||
"default", "mesecon", "digilines",
|
||||
"default", "mesecon", "digiline",
|
||||
"screwdriver", "unified_inventory",
|
||||
"i3", "mcl_experience", "awards",
|
||||
"xcompat", "fakelib", "vizlib"
|
||||
"xcompat",
|
||||
|
||||
}
|
||||
|
@ -1,6 +1,6 @@
|
||||
local S = core.get_translator("pipeworks")
|
||||
local S = minetest.get_translator("pipeworks")
|
||||
-- cache some recipe data to avoid calling the slow function
|
||||
-- core.get_craft_result() every second
|
||||
-- minetest.get_craft_result() every second
|
||||
local autocrafterCache = {}
|
||||
|
||||
local craft_time = 1
|
||||
@ -20,7 +20,7 @@ end
|
||||
|
||||
local function get_item_info(stack)
|
||||
local name = stack:get_name()
|
||||
local def = core.registered_items[name]
|
||||
local def = minetest.registered_items[name]
|
||||
local description = def and def.description or S("Unknown item")
|
||||
return description, name
|
||||
end
|
||||
@ -28,7 +28,7 @@ end
|
||||
-- Get best matching recipe for what user has put in crafting grid.
|
||||
-- This function does not consider crafting method (mix vs craft)
|
||||
local function get_matching_craft(output_name, example_recipe)
|
||||
local recipes = core.get_all_craft_recipes(output_name)
|
||||
local recipes = minetest.get_all_craft_recipes(output_name)
|
||||
if not recipes then
|
||||
return example_recipe
|
||||
end
|
||||
@ -49,7 +49,7 @@ local function get_matching_craft(output_name, example_recipe)
|
||||
elseif recipe_item_name:sub(1, 6) == "group:" then
|
||||
group = recipe_item_name:sub(7)
|
||||
for example_item_name, _ in pairs(index_example) do
|
||||
if core.get_item_group(
|
||||
if minetest.get_item_group(
|
||||
example_item_name, group) ~= 0
|
||||
then
|
||||
score = score + 1
|
||||
@ -68,12 +68,12 @@ local function get_matching_craft(output_name, example_recipe)
|
||||
end
|
||||
|
||||
local function get_craft(pos, inventory, hash)
|
||||
local hash = hash or core.hash_node_position(pos)
|
||||
local hash = hash or minetest.hash_node_position(pos)
|
||||
local craft = autocrafterCache[hash]
|
||||
if craft then return craft end
|
||||
|
||||
local example_recipe = inventory:get_list("recipe")
|
||||
local output, decremented_input = core.get_craft_result({
|
||||
local output, decremented_input = minetest.get_craft_result({
|
||||
method = "normal", width = 3, items = example_recipe
|
||||
})
|
||||
|
||||
@ -132,7 +132,7 @@ local function calculate_consumption(inv_index, consumption_with_groups)
|
||||
local found = 0
|
||||
local count_ingredient_groups = #ingredient_groups
|
||||
for i = 1, count_ingredient_groups do
|
||||
if core.get_item_group(name,
|
||||
if minetest.get_item_group(name,
|
||||
ingredient_groups[i]) ~= 0
|
||||
then
|
||||
found = found + 1
|
||||
@ -241,7 +241,7 @@ local function autocraft(inventory, craft)
|
||||
for i = 1, 9 do
|
||||
leftover = inventory:add_item("dst", craft.decremented_input[i])
|
||||
if leftover and not leftover:is_empty() then
|
||||
core.log("warning", "[pipeworks] autocrafter didn't " ..
|
||||
minetest.log("warning", "[pipeworks] autocrafter didn't " ..
|
||||
"calculate output space correctly.")
|
||||
end
|
||||
end
|
||||
@ -252,7 +252,7 @@ end
|
||||
-- is started only from start_autocrafter(pos) after sanity checks and
|
||||
-- recipe is cached
|
||||
local function run_autocrafter(pos, elapsed)
|
||||
local meta = core.get_meta(pos)
|
||||
local meta = minetest.get_meta(pos)
|
||||
local inventory = meta:get_inventory()
|
||||
local craft = get_craft(pos, inventory)
|
||||
local output_item = craft.output.item
|
||||
@ -270,9 +270,9 @@ local function run_autocrafter(pos, elapsed)
|
||||
end
|
||||
|
||||
local function start_crafter(pos)
|
||||
local meta = core.get_meta(pos)
|
||||
local meta = minetest.get_meta(pos)
|
||||
if meta:get_int("enabled") == 1 then
|
||||
local timer = core.get_node_timer(pos)
|
||||
local timer = minetest.get_node_timer(pos)
|
||||
if not timer:is_started() then
|
||||
timer:start(craft_time)
|
||||
end
|
||||
@ -286,12 +286,12 @@ end
|
||||
-- note, that this function assumes allready being updated to virtual items
|
||||
-- and doesn't handle recipes with stacksizes > 1
|
||||
local function after_recipe_change(pos, inventory)
|
||||
local hash = core.hash_node_position(pos)
|
||||
local meta = core.get_meta(pos)
|
||||
local hash = minetest.hash_node_position(pos)
|
||||
local meta = minetest.get_meta(pos)
|
||||
autocrafterCache[hash] = nil
|
||||
-- if we emptied the grid, there's no point in keeping it running or cached
|
||||
if inventory:is_empty("recipe") then
|
||||
core.get_node_timer(pos):stop()
|
||||
minetest.get_node_timer(pos):stop()
|
||||
meta:set_string("infotext", S("unconfigured Autocrafter"))
|
||||
inventory:set_stack("output", 1, "")
|
||||
return
|
||||
@ -307,12 +307,12 @@ end
|
||||
|
||||
-- clean out unknown items and groups, which would be handled like unknown
|
||||
-- items in the crafting grid
|
||||
-- if Luanti supports query by group one day, this might replace them
|
||||
-- if minetest supports query by group one day, this might replace them
|
||||
-- with a canonical version instead
|
||||
local function normalize(item_list)
|
||||
for i = 1, #item_list do
|
||||
local name = item_list[i]
|
||||
if not core.registered_items[name] then
|
||||
if not minetest.registered_items[name] then
|
||||
item_list[i] = ""
|
||||
end
|
||||
end
|
||||
@ -324,7 +324,7 @@ local function on_output_change(pos, inventory, stack)
|
||||
inventory:set_list("output", {})
|
||||
inventory:set_list("recipe", {})
|
||||
else
|
||||
local input = core.get_craft_recipe(stack:get_name())
|
||||
local input = minetest.get_craft_recipe(stack:get_name())
|
||||
if not input.items or input.type ~= "normal" then return end
|
||||
local items, width = normalize(input.items), input.width
|
||||
local item_idx, width_idx = 1, 1
|
||||
@ -349,7 +349,7 @@ local function update_meta(meta, enabled)
|
||||
local state = enabled and "on" or "off"
|
||||
meta:set_int("enabled", enabled and 1 or 0)
|
||||
local list_backgrounds = ""
|
||||
if core.get_modpath("i3") or core.get_modpath("mcl_formspec") then
|
||||
if minetest.get_modpath("i3") or minetest.get_modpath("mcl_formspec") then
|
||||
list_backgrounds = "style_type[box;colors=#666]"
|
||||
for i = 0, 2 do
|
||||
for j = 0, 2 do
|
||||
@ -389,7 +389,7 @@ local function update_meta(meta, enabled)
|
||||
"listring[current_player;main]" ..
|
||||
"listring[context;dst]" ..
|
||||
"listring[current_player;main]"
|
||||
if core.get_modpath("digilines") then
|
||||
if minetest.get_modpath("digilines") then
|
||||
fs = fs .. "field[0.22,4.1;4.5,0.75;channel;" .. S("Channel") ..
|
||||
";${channel}]" ..
|
||||
"button[5,4.1;1.5,0.75;set_channel;" .. S("Set") .. "]" ..
|
||||
@ -422,7 +422,7 @@ end
|
||||
-- so we work out way backwards on this history and update each single case
|
||||
-- to the newest version
|
||||
local function upgrade_autocrafter(pos, meta)
|
||||
local meta = meta or core.get_meta(pos)
|
||||
local meta = meta or minetest.get_meta(pos)
|
||||
local inv = meta:get_inventory()
|
||||
|
||||
if inv:get_size("output") == 0 then -- we are version 2 or 1
|
||||
@ -439,7 +439,7 @@ local function upgrade_autocrafter(pos, meta)
|
||||
if not recipe then return end
|
||||
for idx, stack in ipairs(recipe) do
|
||||
if not stack:is_empty() then
|
||||
core.add_item(pos, stack)
|
||||
minetest.add_item(pos, stack)
|
||||
stack:set_count(1)
|
||||
stack:set_wear(0)
|
||||
inv:set_stack("recipe", idx, stack)
|
||||
@ -448,12 +448,12 @@ local function upgrade_autocrafter(pos, meta)
|
||||
end
|
||||
|
||||
-- update the recipe, cache, and start the crafter
|
||||
autocrafterCache[core.hash_node_position(pos)] = nil
|
||||
autocrafterCache[minetest.hash_node_position(pos)] = nil
|
||||
after_recipe_change(pos, inv)
|
||||
end
|
||||
end
|
||||
|
||||
core.register_node("pipeworks:autocrafter", {
|
||||
minetest.register_node("pipeworks:autocrafter", {
|
||||
description = S("Autocrafter"),
|
||||
drawtype = "normal",
|
||||
tiles = {"pipeworks_autocrafter.png"},
|
||||
@ -461,14 +461,14 @@ core.register_node("pipeworks:autocrafter", {
|
||||
is_ground_content = false,
|
||||
_mcl_hardness=0.8,
|
||||
tube = {insert_object = function(pos, node, stack, direction)
|
||||
local meta = core.get_meta(pos)
|
||||
local meta = minetest.get_meta(pos)
|
||||
local inv = meta:get_inventory()
|
||||
local added = inv:add_item("src", stack)
|
||||
after_inventory_change(pos)
|
||||
return added
|
||||
end,
|
||||
can_insert = function(pos, node, stack, direction)
|
||||
local meta = core.get_meta(pos)
|
||||
local meta = minetest.get_meta(pos)
|
||||
local inv = meta:get_inventory()
|
||||
return inv:room_for_item("src", stack)
|
||||
end,
|
||||
@ -478,7 +478,7 @@ core.register_node("pipeworks:autocrafter", {
|
||||
}
|
||||
},
|
||||
on_construct = function(pos)
|
||||
local meta = core.get_meta(pos)
|
||||
local meta = minetest.get_meta(pos)
|
||||
local inv = meta:get_inventory()
|
||||
inv:set_size("src", 3 * 8)
|
||||
inv:set_size("recipe", 3 * 3)
|
||||
@ -492,10 +492,10 @@ core.register_node("pipeworks:autocrafter", {
|
||||
then
|
||||
return
|
||||
end
|
||||
local meta = core.get_meta(pos)
|
||||
local meta = minetest.get_meta(pos)
|
||||
if fields.on then
|
||||
update_meta(meta, false)
|
||||
core.get_node_timer(pos):stop()
|
||||
minetest.get_node_timer(pos):stop()
|
||||
elseif fields.off then
|
||||
if update_meta(meta, true) then
|
||||
start_crafter(pos)
|
||||
@ -507,7 +507,7 @@ core.register_node("pipeworks:autocrafter", {
|
||||
end,
|
||||
can_dig = function(pos, player)
|
||||
upgrade_autocrafter(pos)
|
||||
local meta = core.get_meta(pos)
|
||||
local meta = minetest.get_meta(pos)
|
||||
local inv = meta:get_inventory()
|
||||
return (inv:is_empty("src") and inv:is_empty("dst"))
|
||||
end,
|
||||
@ -516,12 +516,12 @@ core.register_node("pipeworks:autocrafter", {
|
||||
pipeworks.scan_for_tube_objects(pos)
|
||||
end,
|
||||
on_destruct = function(pos)
|
||||
autocrafterCache[core.hash_node_position(pos)] = nil
|
||||
autocrafterCache[minetest.hash_node_position(pos)] = nil
|
||||
end,
|
||||
allow_metadata_inventory_put = function(pos, listname, index, stack, player)
|
||||
if not pipeworks.may_configure(pos, player) then return 0 end
|
||||
upgrade_autocrafter(pos)
|
||||
local inv = core.get_meta(pos):get_inventory()
|
||||
local inv = minetest.get_meta(pos):get_inventory()
|
||||
if listname == "recipe" then
|
||||
stack:set_count(1)
|
||||
inv:set_stack(listname, index, stack)
|
||||
@ -536,13 +536,13 @@ core.register_node("pipeworks:autocrafter", {
|
||||
end,
|
||||
allow_metadata_inventory_take = function(pos, listname, index, stack, player)
|
||||
if not pipeworks.may_configure(pos, player) then
|
||||
core.log("action", string.format("%s attempted to take from " ..
|
||||
minetest.log("action", string.format("%s attempted to take from " ..
|
||||
"autocrafter at %s",
|
||||
player:get_player_name(), core.pos_to_string(pos)))
|
||||
player:get_player_name(), minetest.pos_to_string(pos)))
|
||||
return 0
|
||||
end
|
||||
upgrade_autocrafter(pos)
|
||||
local inv = core.get_meta(pos):get_inventory()
|
||||
local inv = minetest.get_meta(pos):get_inventory()
|
||||
if listname == "recipe" then
|
||||
inv:set_stack(listname, index, ItemStack(""))
|
||||
after_recipe_change(pos, inv)
|
||||
@ -559,7 +559,7 @@ core.register_node("pipeworks:autocrafter", {
|
||||
|
||||
if not pipeworks.may_configure(pos, player) then return 0 end
|
||||
upgrade_autocrafter(pos)
|
||||
local inv = core.get_meta(pos):get_inventory()
|
||||
local inv = minetest.get_meta(pos):get_inventory()
|
||||
local stack = inv:get_stack(from_list, from_index)
|
||||
|
||||
if to_list == "output" then
|
||||
@ -588,22 +588,21 @@ core.register_node("pipeworks:autocrafter", {
|
||||
return count
|
||||
end,
|
||||
on_timer = run_autocrafter,
|
||||
digilines = {
|
||||
digiline = {
|
||||
receptor = {},
|
||||
effector = {
|
||||
action = function(pos,node,channel,msg)
|
||||
local meta = core.get_meta(pos)
|
||||
local meta = minetest.get_meta(pos)
|
||||
if channel ~= meta:get_string("channel") then return end
|
||||
if type(msg) == "table" then
|
||||
if #msg < 3 then return end
|
||||
local inv = meta:get_inventory()
|
||||
for y = 0, 2, 1 do
|
||||
local row = msg[y + 1]
|
||||
for x = 1, 3, 1 do
|
||||
local slot = y * 3 + x
|
||||
if type(row) == "table" and core.registered_items[row[x]] then
|
||||
if minetest.registered_items[msg[y + 1][x]] then
|
||||
inv:set_stack("recipe", slot, ItemStack(
|
||||
row[x]))
|
||||
msg[y + 1][x]))
|
||||
else
|
||||
inv:set_stack("recipe", slot, ItemStack(""))
|
||||
end
|
||||
@ -611,7 +610,7 @@ core.register_node("pipeworks:autocrafter", {
|
||||
end
|
||||
after_recipe_change(pos,inv)
|
||||
elseif msg == "get_recipe" then
|
||||
local meta = core.get_meta(pos)
|
||||
local meta = minetest.get_meta(pos)
|
||||
local inv = meta:get_inventory()
|
||||
local recipe = {}
|
||||
for y = 0, 2, 1 do
|
||||
@ -625,7 +624,7 @@ core.register_node("pipeworks:autocrafter", {
|
||||
end
|
||||
local setchan = meta:get_string("channel")
|
||||
local output = inv:get_stack("output", 1)
|
||||
digilines.receptor_send(pos, digilines.rules.default, setchan, {
|
||||
digiline:receptor_send(pos, digiline.rules.default, setchan, {
|
||||
recipe = recipe,
|
||||
result = {
|
||||
name = output:get_name(),
|
||||
@ -634,7 +633,7 @@ core.register_node("pipeworks:autocrafter", {
|
||||
})
|
||||
elseif msg == "off" then
|
||||
update_meta(meta, false)
|
||||
core.get_node_timer(pos):stop()
|
||||
minetest.get_node_timer(pos):stop()
|
||||
elseif msg == "on" then
|
||||
if update_meta(meta, true) then
|
||||
start_crafter(pos)
|
||||
|
@ -1,7 +1,7 @@
|
||||
-- enable finite liquid in the presence of dynamic liquid to preserve water volume.
|
||||
local enable = false
|
||||
|
||||
if core.get_modpath("dynamic_liquid") then
|
||||
if minetest.get_modpath("dynamic_liquid") then
|
||||
pipeworks.logger("detected mod dynamic_liquid, enabling finite liquid flag")
|
||||
enable = true
|
||||
end
|
||||
|
@ -31,32 +31,32 @@ function pipeworks.get_axis_dir(nodetable, pattern)
|
||||
local pxm,pxp,pym,pyp,pzm,pzp
|
||||
|
||||
if string.find(nodetable.nxm.name, pattern)
|
||||
and core.facedir_to_dir(nodetable.nxm.param2).x ~= 0 then
|
||||
and minetest.facedir_to_dir(nodetable.nxm.param2).x ~= 0 then
|
||||
pxm=1
|
||||
end
|
||||
|
||||
if string.find(nodetable.nxp.name, pattern)
|
||||
and core.facedir_to_dir(nodetable.nxp.param2).x ~= 0 then
|
||||
and minetest.facedir_to_dir(nodetable.nxp.param2).x ~= 0 then
|
||||
pxp=1
|
||||
end
|
||||
|
||||
if string.find(nodetable.nzm.name, pattern)
|
||||
and core.facedir_to_dir(nodetable.nzm.param2).z ~= 0 then
|
||||
and minetest.facedir_to_dir(nodetable.nzm.param2).z ~= 0 then
|
||||
pzm=1
|
||||
end
|
||||
|
||||
if string.find(nodetable.nzp.name, pattern)
|
||||
and core.facedir_to_dir(nodetable.nzp.param2).z ~= 0 then
|
||||
and minetest.facedir_to_dir(nodetable.nzp.param2).z ~= 0 then
|
||||
pzp=1
|
||||
end
|
||||
|
||||
if string.find(nodetable.nym.name, pattern)
|
||||
and core.facedir_to_dir(nodetable.nym.param2).y ~= 0 then
|
||||
and minetest.facedir_to_dir(nodetable.nym.param2).y ~= 0 then
|
||||
pym=1
|
||||
end
|
||||
|
||||
if string.find(nodetable.nyp.name, pattern)
|
||||
and core.facedir_to_dir(nodetable.nyp.param2).y ~= 0 then
|
||||
and minetest.facedir_to_dir(nodetable.nyp.param2).y ~= 0 then
|
||||
pyp=1
|
||||
end
|
||||
local match = pxm or pxp or pym or pyp or pzm or pzp
|
||||
@ -67,14 +67,14 @@ local tube_table = {[0] = 1, 2, 2, 4, 2, 4, 4, 5, 2, 3, 4, 6, 4, 6, 5, 7, 2, 4,
|
||||
local tube_table_facedirs = {[0] = 0, 0, 5, 0, 3, 4, 3, 0, 2, 0, 2, 0, 6, 4, 3, 0, 7, 12, 5, 12, 7, 4, 5, 5, 18, 20, 16, 0, 7, 4, 7, 0, 1, 8, 1, 1, 1, 13, 1, 1, 10, 8, 2, 2, 17, 4, 3, 6, 9, 9, 9, 9, 21, 13, 1, 1, 10, 10, 11, 2, 19, 4, 3, 0}
|
||||
|
||||
local function autoroute_pipes(pos)
|
||||
local nctr = core.get_node(pos)
|
||||
local nctr = minetest.get_node(pos)
|
||||
local state = "_empty"
|
||||
if (string.find(nctr.name, "pipeworks:pipe_") == nil) then return end
|
||||
if (string.find(nctr.name, "_loaded") ~= nil) then state = "_loaded" end
|
||||
local nsurround = pipeworks.scan_pipe_surroundings(pos)
|
||||
|
||||
if nsurround == 0 then nsurround = 9 end
|
||||
core.swap_node(pos, {name = "pipeworks:pipe_"..tube_table[nsurround]..state,
|
||||
minetest.swap_node(pos, {name = "pipeworks:pipe_"..tube_table[nsurround]..state,
|
||||
param2 = tube_table_facedirs[nsurround]})
|
||||
end
|
||||
|
||||
@ -98,12 +98,12 @@ function pipeworks.scan_pipe_surroundings(pos)
|
||||
local pzm=0
|
||||
local pzp=0
|
||||
|
||||
local nxm = core.get_node({ x=pos.x-1, y=pos.y , z=pos.z })
|
||||
local nxp = core.get_node({ x=pos.x+1, y=pos.y , z=pos.z })
|
||||
local nym = core.get_node({ x=pos.x , y=pos.y-1, z=pos.z })
|
||||
local nyp = core.get_node({ x=pos.x , y=pos.y+1, z=pos.z })
|
||||
local nzm = core.get_node({ x=pos.x , y=pos.y , z=pos.z-1 })
|
||||
local nzp = core.get_node({ x=pos.x , y=pos.y , z=pos.z+1 })
|
||||
local nxm = minetest.get_node({ x=pos.x-1, y=pos.y , z=pos.z })
|
||||
local nxp = minetest.get_node({ x=pos.x+1, y=pos.y , z=pos.z })
|
||||
local nym = minetest.get_node({ x=pos.x , y=pos.y-1, z=pos.z })
|
||||
local nyp = minetest.get_node({ x=pos.x , y=pos.y+1, z=pos.z })
|
||||
local nzm = minetest.get_node({ x=pos.x , y=pos.y , z=pos.z-1 })
|
||||
local nzp = minetest.get_node({ x=pos.x , y=pos.y , z=pos.z+1 })
|
||||
|
||||
local nodetable = {
|
||||
nxm = nxm,
|
||||
@ -173,12 +173,12 @@ function pipeworks.scan_pipe_surroundings(pos)
|
||||
|
||||
-- ... other nodes
|
||||
|
||||
local def_left = core.registered_nodes[nxp.name] -- the node that {pos} is to the left of (not the
|
||||
local def_right = core.registered_nodes[nxm.name] -- ...note that is AT the left!), etc.
|
||||
local def_bottom = core.registered_nodes[nyp.name]
|
||||
local def_top = core.registered_nodes[nym.name]
|
||||
local def_front = core.registered_nodes[nzp.name]
|
||||
local def_back = core.registered_nodes[nzm.name]
|
||||
local def_left = minetest.registered_nodes[nxp.name] -- the node that {pos} is to the left of (not the
|
||||
local def_right = minetest.registered_nodes[nxm.name] -- ...note that is AT the left!), etc.
|
||||
local def_bottom = minetest.registered_nodes[nyp.name]
|
||||
local def_top = minetest.registered_nodes[nym.name]
|
||||
local def_front = minetest.registered_nodes[nzp.name]
|
||||
local def_back = minetest.registered_nodes[nzm.name]
|
||||
|
||||
if def_left and def_left.pipe_connections and def_left.pipe_connections.left
|
||||
and (not def_left.pipe_connections.pattern or string.find(nxp.name, def_left.pipe_connections.pattern))
|
||||
@ -211,16 +211,16 @@ function pipeworks.scan_pipe_surroundings(pos)
|
||||
pzm = 1
|
||||
end
|
||||
|
||||
core.log("info", "stage 2 returns "..pxm+8*pxp+2*pym+16*pyp+4*pzm+32*pzp..
|
||||
" for nodes surrounding "..core.get_node(pos).name.." at "..core.pos_to_string(pos))
|
||||
print("stage 2 returns "..pxm+8*pxp+2*pym+16*pyp+4*pzm+32*pzp..
|
||||
" for nodes surrounding "..minetest.get_node(pos).name.." at "..minetest.pos_to_string(pos))
|
||||
return pxm+8*pxp+2*pym+16*pyp+4*pzm+32*pzp
|
||||
end
|
||||
|
||||
function pipeworks.look_for_stackable_tanks(pos)
|
||||
local tym = core.get_node({ x=pos.x , y=pos.y-1, z=pos.z })
|
||||
local tym = minetest.get_node({ x=pos.x , y=pos.y-1, z=pos.z })
|
||||
|
||||
if string.find(tym.name, "pipeworks:storage_tank_") ~= nil or
|
||||
string.find(tym.name, "pipeworks:expansion_tank_") ~= nil then
|
||||
core.add_node(pos, { name = "pipeworks:expansion_tank_0", param2 = tym.param2})
|
||||
minetest.add_node(pos, { name = "pipeworks:expansion_tank_0", param2 = tym.param2})
|
||||
end
|
||||
end
|
||||
|
@ -10,8 +10,8 @@ local function nodeside(node, tubedir)
|
||||
node.param2 = 0
|
||||
end
|
||||
|
||||
local backdir = core.facedir_to_dir(node.param2)
|
||||
local back = vector.dot(backdir, tubedir)
|
||||
local backdir = minetest.facedir_to_dir(node.param2)
|
||||
local back = pipeworks.vector_dot(backdir, tubedir)
|
||||
if back == 1 then
|
||||
return "back"
|
||||
elseif back == -1 then
|
||||
@ -19,7 +19,7 @@ local function nodeside(node, tubedir)
|
||||
end
|
||||
|
||||
local topdir = pipeworks.facedir_to_top_dir(node.param2)
|
||||
local top = vector.dot(topdir, tubedir)
|
||||
local top = pipeworks.vector_dot(topdir, tubedir)
|
||||
if top == 1 then
|
||||
return "top"
|
||||
elseif top == -1 then
|
||||
@ -27,7 +27,7 @@ local function nodeside(node, tubedir)
|
||||
end
|
||||
|
||||
local rightdir = pipeworks.facedir_to_right_dir(node.param2)
|
||||
local right = vector.dot(rightdir, tubedir)
|
||||
local right = pipeworks.vector_dot(rightdir, tubedir)
|
||||
if right == 1 then
|
||||
return "right"
|
||||
else
|
||||
@ -40,7 +40,7 @@ local tube_table = {[0] = 1, 2, 2, 4, 2, 4, 4, 5, 2, 3, 4, 6, 4, 6, 5, 7, 2, 4,
|
||||
local tube_table_facedirs = {[0] = 0, 0, 5, 0, 3, 4, 3, 0, 2, 0, 2, 0, 6, 4, 3, 0, 7, 12, 5, 12, 7, 4, 5, 5, 18, 20, 16, 0, 7, 4, 7, 0, 1, 8, 1, 1, 1, 13, 1, 1, 10, 8, 2, 2, 17, 4, 3, 6, 9, 9, 9, 9, 21, 13, 1, 1, 10, 10, 11, 2, 19, 4, 3, 0}
|
||||
local function tube_autoroute(pos)
|
||||
local active = {0, 0, 0, 0, 0, 0}
|
||||
local nctr = core.get_node(pos)
|
||||
local nctr = minetest.get_node(pos)
|
||||
if not is_tube(nctr.name) then return end
|
||||
|
||||
local adjustments = {
|
||||
@ -57,9 +57,9 @@ local function tube_autoroute(pos)
|
||||
|
||||
for i, adj in ipairs(adjustments) do
|
||||
local position = vector.add(pos, adj)
|
||||
local node = core.get_node(position)
|
||||
local node = minetest.get_node(position)
|
||||
|
||||
local idef = core.registered_nodes[node.name]
|
||||
local idef = minetest.registered_nodes[node.name]
|
||||
-- handle the tubes themselves
|
||||
if is_tube(node.name) then
|
||||
active[i] = 1
|
||||
@ -73,11 +73,11 @@ local function tube_autoroute(pos)
|
||||
end
|
||||
end
|
||||
|
||||
core.get_meta(pos):set_string("adjlist", core.serialize(adjlist))
|
||||
minetest.get_meta(pos):set_string("adjlist", minetest.serialize(adjlist))
|
||||
|
||||
-- all sides checked, now figure which tube to use.
|
||||
|
||||
local nodedef = core.registered_nodes[nctr.name]
|
||||
local nodedef = minetest.registered_nodes[nctr.name]
|
||||
local basename = nodedef.basename
|
||||
if nodedef.style == "old" then
|
||||
local nsurround = ""
|
||||
@ -95,7 +95,7 @@ local function tube_autoroute(pos)
|
||||
nctr.name = basename.."_"..tube_table[s]
|
||||
nctr.param2 = tube_table_facedirs[s]
|
||||
end
|
||||
core.swap_node(pos, nctr)
|
||||
minetest.swap_node(pos, nctr)
|
||||
end
|
||||
|
||||
function pipeworks.scan_for_tube_objects(pos)
|
||||
@ -123,12 +123,12 @@ end
|
||||
-- when they are updated.
|
||||
function pipeworks.on_rotate(pos, node, user, mode, new_param2)
|
||||
node.param2 = new_param2
|
||||
core.swap_node(pos, node)
|
||||
minetest.swap_node(pos, node)
|
||||
pipeworks.scan_for_tube_objects(pos)
|
||||
return true
|
||||
end
|
||||
|
||||
if core.get_modpath("mesecons_mvps") then
|
||||
if minetest.get_modpath("mesecons_mvps") then
|
||||
mesecon.register_on_mvps_move(function(moved_nodes)
|
||||
for _, n in ipairs(moved_nodes) do
|
||||
pipeworks.scan_for_tube_objects(n.pos)
|
||||
|
90
chests.lua
90
chests.lua
@ -1,90 +0,0 @@
|
||||
pipeworks.chests = {}
|
||||
|
||||
-- register a chest to connect with pipeworks tubes.
|
||||
-- will autoconnect to tubes and add tube inlets to the textures
|
||||
-- it is highly recommended to allow the user to change the "splitstacks" int (1 to enable) in the node meta
|
||||
-- but that can't be done by this function
|
||||
|
||||
-- @param override: additional overrides, such as stuff to modify the node formspec
|
||||
-- @param connect_sides: which directions the chests shall connect to
|
||||
function pipeworks.override_chest(chestname, override, connect_sides)
|
||||
local old_def = core.registered_nodes[chestname]
|
||||
|
||||
local tube_entry = "^pipeworks_tube_connection_wooden.png"
|
||||
override.tiles = override.tiles or old_def.tiles
|
||||
-- expand the tiles table if it has been shortened
|
||||
if #override.tiles < 6 then
|
||||
for i = #override.tiles, 6 do
|
||||
override.tiles[i] = override.tiles[#override.tiles]
|
||||
end
|
||||
end
|
||||
-- add inlets to the sides that connect to tubes
|
||||
local tile_directions = {"top", "bottom", "right", "left", "back", "front"}
|
||||
for i, direction in ipairs(tile_directions) do
|
||||
if connect_sides[direction] then
|
||||
if type(override.tiles[i]) == "string" then
|
||||
override.tiles[i] = override.tiles[i] .. tube_entry
|
||||
elseif type(override.tiles[i]) == "table" and not override.tiles[i].animation then
|
||||
override.tiles[i].name = override.tiles[i].name .. tube_entry
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
local old_after_place_node = override.after_place_node or old_def.after_place_node or function() end
|
||||
override.after_place_node = function(pos, placer, itemstack, pointed_thing)
|
||||
old_after_place_node(pos, placer, itemstack, pointed_thing)
|
||||
pipeworks.after_place(pos)
|
||||
end
|
||||
|
||||
local old_after_dig = override.after_dig or old_def.after_dig_node or function() end
|
||||
override.after_dig_node = function(pos, oldnode, oldmetadata, digger)
|
||||
old_after_dig(pos, oldnode, oldmetadata, digger)
|
||||
pipeworks.after_dig(pos, oldnode, oldmetadata, digger)
|
||||
end
|
||||
|
||||
local old_on_rotate
|
||||
if override.on_rotate ~= nil then
|
||||
old_on_rotate = override.on_rotate
|
||||
elseif old_def.on_rotate ~= nil then
|
||||
old_on_rotate = old_def.on_rotate
|
||||
else
|
||||
old_on_rotate = function() end
|
||||
end
|
||||
-- on_rotate = false -> rotation disabled, no need to update tubes
|
||||
-- everything else: undefined by the most common screwdriver mods
|
||||
if type(old_on_rotate) == "function" then
|
||||
override.on_rotate = function(pos, node, user, mode, new_param2)
|
||||
if old_on_rotate(pos, node, user, mode, new_param2) ~= false then
|
||||
return pipeworks.on_rotate(pos, node, user, mode, new_param2)
|
||||
else
|
||||
return false
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
override.tube = {
|
||||
insert_object = function(pos, node, stack, direction)
|
||||
local meta = core.get_meta(pos)
|
||||
local inv = meta:get_inventory()
|
||||
return inv:add_item("main", stack)
|
||||
end,
|
||||
can_insert = function(pos, node, stack, direction)
|
||||
local meta = core.get_meta(pos)
|
||||
local inv = meta:get_inventory()
|
||||
if meta:get_int("splitstacks") == 1 then
|
||||
stack = stack:peek_item(1)
|
||||
end
|
||||
return inv:room_for_item("main", stack)
|
||||
end,
|
||||
input_inventory = "main",
|
||||
connect_sides = connect_sides
|
||||
}
|
||||
|
||||
-- Add the extra groups
|
||||
override.groups = override.groups or old_def.groups or {}
|
||||
override.groups.tubedevice = 1
|
||||
override.groups.tubedevice_receiver = 1
|
||||
|
||||
core.override_item(chestname, override)
|
||||
pipeworks.chests[chestname] = true
|
||||
end
|
358
common.lua
358
common.lua
@ -1,9 +1,9 @@
|
||||
local S = core.get_translator("pipeworks")
|
||||
local S = minetest.get_translator("pipeworks")
|
||||
|
||||
-- Random variables
|
||||
|
||||
pipeworks.expect_infinite_stacks = true
|
||||
if core.get_modpath("unified_inventory") or not core.settings:get_bool("creative_mode") then
|
||||
if minetest.get_modpath("unified_inventory") or not minetest.settings:get_bool("creative_mode") then
|
||||
pipeworks.expect_infinite_stacks = false
|
||||
end
|
||||
|
||||
@ -15,19 +15,9 @@ pipeworks.rules_all = {{x=0, y=0, z=1},{x=0, y=0, z=-1},{x=1, y=0, z=0},{x=-1, y
|
||||
{x=0, y=1, z=0}, {x=0, y=-1, z=0}}
|
||||
|
||||
pipeworks.mesecons_rules={{x=0,y=0,z=1},{x=0,y=0,z=-1},{x=1,y=0,z=0},{x=-1,y=0,z=0},{x=0,y=1,z=0},{x=0,y=-1,z=0}}
|
||||
pipeworks.digilines_rules={{x=0,y=0,z=1},{x=0,y=0,z=-1},{x=1,y=0,z=0},{x=-1,y=0,z=0},{x=0,y=1,z=0},{x=0,y=-1,z=0}}
|
||||
|
||||
local digilines_enabled = core.get_modpath("digilines") ~= nil
|
||||
if digilines_enabled and pipeworks.enable_vertical_digilines_connectivity then
|
||||
pipeworks.digilines_rules=digilines.rules.default
|
||||
else
|
||||
-- These rules break vertical connectivity to deployers, node breakers, dispensers, and digiline filter injectors
|
||||
-- via digiline conducting tubes. Changing them may break some builds on some servers, so the setting was added
|
||||
-- for server admins to be able to revert to the old "broken" behavior as some builds may use it as a "feature".
|
||||
-- See https://github.com/mt-mods/pipeworks/issues/64
|
||||
pipeworks.digilines_rules={{x=0,y=0,z=1},{x=0,y=0,z=-1},{x=1,y=0,z=0},{x=-1,y=0,z=0},{x=0,y=1,z=0},{x=0,y=-1,z=0}}
|
||||
end
|
||||
|
||||
pipeworks.liquid_texture = core.registered_nodes[pipeworks.liquids.water.flowing].tiles[1]
|
||||
pipeworks.liquid_texture = minetest.registered_nodes[pipeworks.liquids.water.flowing].tiles[1]
|
||||
if type(pipeworks.liquid_texture) == "table" then pipeworks.liquid_texture = pipeworks.liquid_texture.name end
|
||||
|
||||
pipeworks.button_off = {text="", texture="pipeworks_button_off.png", addopts="false;false;pipeworks_button_interm.png"}
|
||||
@ -60,7 +50,7 @@ function pipeworks.make_tube_tile(tile)
|
||||
tile = table.copy(tile)
|
||||
if tile.color then
|
||||
-- Won't work 100% of the time, but good enough.
|
||||
tile.name = tile.name .. "^[multiply:" .. core.colorspec_to_colorstring(tile.color)
|
||||
tile.name = tile.name .. "^[multiply:" .. minetest.colorspec_to_colorstring(tile.color)
|
||||
tile.color = nil
|
||||
end
|
||||
tile.name = overlay_tube_texture(tile.name)
|
||||
@ -78,13 +68,13 @@ end
|
||||
|
||||
function pipeworks.may_configure(pos, player)
|
||||
local name = player:get_player_name()
|
||||
local meta = core.get_meta(pos)
|
||||
local meta = minetest.get_meta(pos)
|
||||
local owner = meta:get_string("owner")
|
||||
|
||||
if owner ~= "" and owner == name then -- wielders and filters
|
||||
return true
|
||||
end
|
||||
return not core.is_protected(pos, name)
|
||||
return not minetest.is_protected(pos, name)
|
||||
end
|
||||
|
||||
function pipeworks.replace_name(tbl,tr,name)
|
||||
@ -101,6 +91,22 @@ function pipeworks.replace_name(tbl,tr,name)
|
||||
return ntbl
|
||||
end
|
||||
|
||||
----------------------
|
||||
-- Vector functions --
|
||||
----------------------
|
||||
|
||||
function pipeworks.vector_cross(a, b)
|
||||
return {
|
||||
x = a.y * b.z - a.z * b.y,
|
||||
y = a.z * b.x - a.x * b.z,
|
||||
z = a.x * b.y - a.y * b.x
|
||||
}
|
||||
end
|
||||
|
||||
function pipeworks.vector_dot(a, b)
|
||||
return a.x * b.x + a.y * b.y + a.z * b.z
|
||||
end
|
||||
|
||||
-----------------------
|
||||
-- Facedir functions --
|
||||
-----------------------
|
||||
@ -116,9 +122,9 @@ function pipeworks.facedir_to_top_dir(facedir)
|
||||
end
|
||||
|
||||
function pipeworks.facedir_to_right_dir(facedir)
|
||||
return vector.cross(
|
||||
return pipeworks.vector_cross(
|
||||
pipeworks.facedir_to_top_dir(facedir),
|
||||
core.facedir_to_dir(facedir)
|
||||
minetest.facedir_to_dir(facedir)
|
||||
)
|
||||
end
|
||||
|
||||
@ -136,10 +142,29 @@ function directions.side_to_dir(side)
|
||||
end
|
||||
|
||||
function directions.dir_to_side(dir)
|
||||
local c = vector.dot(dir, vector.new(1, 2, 3)) + 4
|
||||
local c = pipeworks.vector_dot(dir, vector.new(1, 2, 3)) + 4
|
||||
return ({6, 2, 4, 0, 3, 1, 5})[c]
|
||||
end
|
||||
|
||||
----------------------
|
||||
-- String functions --
|
||||
----------------------
|
||||
|
||||
--[[function pipeworks.string_split(str, sep)
|
||||
local fields = {}
|
||||
local index = 1
|
||||
local expr = "([^"..sep.."])+"
|
||||
string.gsub(str, expr, function(substring)
|
||||
fields[index] = substring
|
||||
index = index + 1
|
||||
end)
|
||||
return fields
|
||||
end]]
|
||||
|
||||
function pipeworks.string_startswith(str, substr)
|
||||
return str:sub(1, substr:len()) == substr
|
||||
end
|
||||
|
||||
---------------------
|
||||
-- Table functions --
|
||||
---------------------
|
||||
@ -181,9 +206,9 @@ end
|
||||
local fs_helpers = {}
|
||||
pipeworks.fs_helpers = fs_helpers
|
||||
function fs_helpers.on_receive_fields(pos, fields)
|
||||
local meta = core.get_meta(pos)
|
||||
local meta = minetest.get_meta(pos)
|
||||
for field in pairs(fields) do
|
||||
if field:match("^fs_helpers_cycling:") then
|
||||
if pipeworks.string_startswith(field, "fs_helpers_cycling:") then
|
||||
local l = field:split(":")
|
||||
local new_value = tonumber(l[2])
|
||||
local meta_name = l[3]
|
||||
@ -208,12 +233,12 @@ function fs_helpers.cycling_button(meta, base, meta_name, values)
|
||||
text = val
|
||||
end
|
||||
local field = "fs_helpers_cycling:"..new_value..":"..meta_name
|
||||
return base..";"..(texture_name and texture_name..";" or "")..field..";"..core.formspec_escape(text)..(addopts and ";"..addopts or "").."]"
|
||||
return base..";"..(texture_name and texture_name..";" or "")..field..";"..minetest.formspec_escape(text)..(addopts and ";"..addopts or "").."]"
|
||||
end
|
||||
|
||||
function fs_helpers.get_inv(y)
|
||||
local fs = {}
|
||||
if core.get_modpath("i3") then
|
||||
if minetest.get_modpath("i3") then
|
||||
local inv_x = i3.settings.legacy_inventory and 0.75 or 0.22
|
||||
local inv_y = (y + 0.4) or 6.9
|
||||
local size, spacing = 1, 0.1
|
||||
@ -238,7 +263,7 @@ function fs_helpers.get_inv(y)
|
||||
|
||||
table.insert(fs, "style_type[list;size="..size..";spacing="..spacing.."]")
|
||||
table.insert(fs, "list[current_player;main;"..inv_x..","..(inv_y + 1.15)..";"..hotbar_len..","..(inv_size / hotbar_len)..";"..hotbar_len.."]")
|
||||
elseif core.get_modpath("mcl_formspec") then
|
||||
elseif minetest.get_modpath("mcl_formspec") then
|
||||
local inv_x = 0.22
|
||||
local inv_y = (y + 0.4) or 6.9
|
||||
local size, spacing = 1, 0.1
|
||||
@ -273,7 +298,7 @@ end
|
||||
function fs_helpers.get_prepends(size)
|
||||
local prepend = {}
|
||||
|
||||
if core.get_modpath("i3") then
|
||||
if minetest.get_modpath("i3") then
|
||||
prepend = {
|
||||
"no_prepend[]",
|
||||
"bgcolor[black;neither]",
|
||||
@ -293,12 +318,285 @@ end
|
||||
function pipeworks.load_position(pos)
|
||||
if pos.x < -30912 or pos.y < -30912 or pos.z < -30912 or
|
||||
pos.x > 30927 or pos.y > 30927 or pos.z > 30927 then return end
|
||||
if core.get_node_or_nil(pos) then
|
||||
if minetest.get_node_or_nil(pos) then
|
||||
return
|
||||
end
|
||||
local vm = core.get_voxel_manip()
|
||||
local vm = minetest.get_voxel_manip()
|
||||
vm:read_from_map(pos, pos)
|
||||
end
|
||||
|
||||
-- Kept for compatibility with old mods
|
||||
pipeworks.create_fake_player = fakelib.create_player
|
||||
local function delay(...)
|
||||
local args = {...}
|
||||
return (function() return unpack(args) end)
|
||||
end
|
||||
|
||||
local function get_set_wrap(name, is_dynamic)
|
||||
return (function(self)
|
||||
return self["_" .. name]
|
||||
end), (function(self, value)
|
||||
if is_dynamic then
|
||||
self["_" .. name] = type(value) == "table"
|
||||
and table.copy(value) or value
|
||||
end
|
||||
end)
|
||||
end
|
||||
|
||||
local fake_player_metatable = {
|
||||
is_player = delay(true),
|
||||
is_fake_player = true,
|
||||
|
||||
-- dummy implementation of the rest of the player API:
|
||||
add_player_velocity = delay(), -- deprecated
|
||||
add_velocity = delay(),
|
||||
get_acceleration = delay(), -- no-op for players
|
||||
get_animation = delay({x = 0, y = 0}, 0, 0, false),
|
||||
get_armor_groups = delay({}),
|
||||
get_attach = delay(),
|
||||
get_attribute = delay(), -- deprecated
|
||||
get_bone_position = delay(vector.zero(), vector.zero()),
|
||||
get_children = delay({}),
|
||||
get_clouds = delay({
|
||||
ambient = { r = 0, b = 0, g = 0, a = 0 },
|
||||
color = { r = 0, b = 0, g = 0, a = 0 },
|
||||
density = 0,
|
||||
height = 120,
|
||||
thickness = 10,
|
||||
speed = vector.zero(),
|
||||
}),
|
||||
get_day_night_ratio = delay(),
|
||||
get_entity_name = delay(),
|
||||
get_formspec_prepend = delay(""),
|
||||
get_fov = delay(0, false, 0),
|
||||
get_lighting = delay({
|
||||
exposure = {
|
||||
center_weight_power = 1,
|
||||
exposure_correction = 0,
|
||||
luminance_max = -3,
|
||||
luminance_min = -3,
|
||||
speed_bright_dark = 1000,
|
||||
speed_dark_bright = 1000,
|
||||
},
|
||||
saturation = 1,
|
||||
shadows = {
|
||||
intensity = .6212,
|
||||
},
|
||||
}),
|
||||
get_local_animation = delay({x = 0, y = 0}, {x = 0, y = 0}, {x = 0, y = 0}, {x = 0, y = 0}, 30),
|
||||
get_luaentity = delay(),
|
||||
get_meta = delay({
|
||||
contains = delay(false),
|
||||
get = delay(),
|
||||
set_string = delay(),
|
||||
get_string = delay(""),
|
||||
set_int = delay(),
|
||||
get_int = delay(0),
|
||||
set_float = delay(),
|
||||
get_float = delay(0),
|
||||
get_keys = delay({}),
|
||||
to_table = delay({fields = {}}),
|
||||
from_table = delay(false),
|
||||
equals = delay(false),
|
||||
}),
|
||||
get_moon = delay({
|
||||
scale = 1,
|
||||
texture = "",
|
||||
tonemap = "",
|
||||
visible = false,
|
||||
}),
|
||||
get_physics_override = delay({
|
||||
acceleration_air = 1,
|
||||
acceleration_default = 1,
|
||||
gravity = 1,
|
||||
jump = 1,
|
||||
liquid_fluidity = 1,
|
||||
liquid_fluidity_smooth = 1,
|
||||
liquid_sink = 1,
|
||||
new_move = true,
|
||||
sneak = true,
|
||||
sneak_glitch = false,
|
||||
speed = 1,
|
||||
speed_climb = 1,
|
||||
speed_crouch = 1,
|
||||
}),
|
||||
get_player_velocity = vector.zero, -- deprecated
|
||||
get_rotation = delay(), -- no-op for players
|
||||
get_sky = delay({ r = 0, g = 0, b = 0, a = 0 }, "regular", {}, true),
|
||||
get_sky_color = delay({
|
||||
dawn_horizon = { r = 0, g = 0, b = 0, a = 0 },
|
||||
dawn_sky = { r = 0, g = 0, b = 0, a = 0 },
|
||||
day_horizon = { r = 0, g = 0, b = 0, a = 0 },
|
||||
day_sky = { r = 0, g = 0, b = 0, a = 0 },
|
||||
fog_moon_tint = { r = 0, g = 0, b = 0, a = 0 },
|
||||
fog_sun_tint = { r = 0, g = 0, b = 0, a = 0 },
|
||||
fog_tint_type = "default",
|
||||
indoors = { r = 0, g = 0, b = 0, a = 0 },
|
||||
night_horizon = { r = 0, g = 0, b = 0, a = 0 },
|
||||
night_sky = { r = 0, g = 0, b = 0, a = 0 },
|
||||
}),
|
||||
get_stars = delay({
|
||||
count = 1000,
|
||||
day_opacity = 0,
|
||||
scale = 1,
|
||||
star_color = { r = 0, g = 0, b = 0, a = 0 },
|
||||
visible = true,
|
||||
}),
|
||||
get_sun = delay({
|
||||
scale = 1,
|
||||
sunrise = "",
|
||||
sunrise_visible = true,
|
||||
texture = "",
|
||||
tonemap = "",
|
||||
visible = true,
|
||||
}),
|
||||
get_texture_mod = delay(), -- no-op for players
|
||||
get_velocity = vector.zero,
|
||||
get_yaw = delay(), -- no-op for players
|
||||
getacceleration = delay(), -- backward compatibility
|
||||
getvelocity = vector.zero, -- backward compatibility
|
||||
getyaw = delay(), -- backward compatibility
|
||||
hud_add = delay(),
|
||||
hud_change = delay(),
|
||||
hud_get = delay(),
|
||||
hud_get_flags = delay({
|
||||
basic_debug = false,
|
||||
breathbar = false,
|
||||
chat = false,
|
||||
crosshair = false,
|
||||
healthbar = false,
|
||||
hotbar = false,
|
||||
minimap = false,
|
||||
minimap_radar = false,
|
||||
wielditem = false,
|
||||
}),
|
||||
hud_get_hotbar_image = delay(""),
|
||||
hud_get_hotbar_itemcount = delay(1),
|
||||
hud_get_hotbar_selected_image = delay(""),
|
||||
hud_remove = delay(),
|
||||
hud_set_flags = delay(),
|
||||
hud_set_hotbar_image = delay(),
|
||||
hud_set_hotbar_itemcount = delay(),
|
||||
hud_set_hotbar_selected_image = delay(),
|
||||
override_day_night_ratio = delay(),
|
||||
punch = delay(),
|
||||
remove = delay(),
|
||||
respawn = delay(),
|
||||
right_click = delay(),
|
||||
send_mapblock = delay(),
|
||||
set_acceleration = delay(),
|
||||
set_animation = delay(),
|
||||
set_animation_frame_speed = delay(),
|
||||
set_armor_groups = delay(),
|
||||
set_attach = delay(),
|
||||
set_attribute = delay(), -- deprecated
|
||||
set_bone_position = delay(),
|
||||
set_clouds = delay(),
|
||||
set_detach = delay(),
|
||||
set_formspec_prepend = delay(),
|
||||
set_fov = delay(),
|
||||
set_lighting = delay(),
|
||||
set_local_animation = delay(),
|
||||
set_look_horizontal = delay(),
|
||||
set_look_pitch = delay(),
|
||||
set_look_vertical = delay(),
|
||||
set_look_yaw = delay(),
|
||||
set_minimap_modes = delay(),
|
||||
set_moon = delay(),
|
||||
set_nametag_attributes = delay(),
|
||||
set_physics_override = delay(),
|
||||
set_rotation = delay(), -- no-op for players
|
||||
set_sky = delay(),
|
||||
set_sprite = delay(), -- no-op for players
|
||||
set_stars = delay(),
|
||||
set_sun = delay(),
|
||||
set_texture_mod = delay(), -- no-op for players
|
||||
set_velocity = delay(), -- no-op for players
|
||||
set_yaw = delay(), -- no-op for players
|
||||
setacceleration = delay(), -- backward compatibility
|
||||
setsprite = delay(), -- backward compatibility
|
||||
settexturemod = delay(), -- backward compatibility
|
||||
setvelocity = delay(), -- backward compatibility
|
||||
setyaw = delay(), -- backward compatibility
|
||||
}
|
||||
|
||||
function pipeworks.create_fake_player(def, is_dynamic)
|
||||
local wielded_item = ItemStack("")
|
||||
if def.inventory and def.wield_list then
|
||||
wielded_item = def.inventory:get_stack(def.wield_list, def.wield_index or 1)
|
||||
end
|
||||
local p = {
|
||||
get_player_name = delay(def.name),
|
||||
|
||||
_formspec = def.formspec or "",
|
||||
_hp = def.hp or 20,
|
||||
_breath = 11,
|
||||
_pos = def.position and table.copy(def.position) or vector.new(),
|
||||
_properties = def.properties or { eye_height = def.eye_height or 1.47 },
|
||||
_inventory = def.inventory,
|
||||
_wield_index = def.wield_index or 1,
|
||||
_wielded_item = wielded_item,
|
||||
|
||||
-- Model and view
|
||||
_eye_offset1 = vector.new(),
|
||||
_eye_offset3 = vector.new(),
|
||||
set_eye_offset = function(self, first, third)
|
||||
self._eye_offset1 = table.copy(first)
|
||||
self._eye_offset3 = table.copy(third)
|
||||
end,
|
||||
get_eye_offset = function(self)
|
||||
return self._eye_offset1, self._eye_offset3
|
||||
end,
|
||||
get_look_dir = delay(def.look_dir or vector.new()),
|
||||
get_look_pitch = delay(def.look_pitch or 0),
|
||||
get_look_yaw = delay(def.look_yaw or 0),
|
||||
get_look_horizontal = delay(def.look_yaw or 0),
|
||||
get_look_vertical = delay(-(def.look_pitch or 0)),
|
||||
|
||||
-- Controls
|
||||
get_player_control = delay({
|
||||
jump=false, right=false, left=false, LMB=false, RMB=false,
|
||||
sneak=def.sneak, aux1=false, down=false, up=false
|
||||
}),
|
||||
get_player_control_bits = delay(def.sneak and 64 or 0),
|
||||
|
||||
-- Inventory and ItemStacks
|
||||
get_inventory = delay(def.inventory),
|
||||
set_wielded_item = function(self, item)
|
||||
if self._inventory and def.wield_list then
|
||||
return self._inventory:set_stack(def.wield_list,
|
||||
self._wield_index, item)
|
||||
end
|
||||
self._wielded_item = ItemStack(item)
|
||||
end,
|
||||
get_wielded_item = function(self, item)
|
||||
if self._inventory and def.wield_list then
|
||||
return self._inventory:get_stack(def.wield_list,
|
||||
self._wield_index)
|
||||
end
|
||||
return ItemStack(self._wielded_item)
|
||||
end,
|
||||
get_wield_list = delay(def.wield_list),
|
||||
get_nametag_attributes = delay({
|
||||
bgcolor = false,
|
||||
color = { r = 0, g = 0, b = 0, a = 0 },
|
||||
text = def.name,
|
||||
}),
|
||||
}
|
||||
-- Getter & setter functions
|
||||
p.get_inventory_formspec, p.set_inventory_formspec
|
||||
= get_set_wrap("formspec", is_dynamic)
|
||||
p.get_breath, p.set_breath = get_set_wrap("breath", is_dynamic)
|
||||
p.get_hp, p.set_hp = get_set_wrap("hp", is_dynamic)
|
||||
p.get_pos, p.set_pos = get_set_wrap("pos", is_dynamic)
|
||||
p.get_wield_index, p.set_wield_index = get_set_wrap("wield_index", true)
|
||||
p.get_properties, p.set_properties = get_set_wrap("properties", false)
|
||||
|
||||
-- For players, move_to and get_pos do the same
|
||||
p.move_to = p.get_pos
|
||||
|
||||
-- Backwards compatibility
|
||||
p.getpos = p.get_pos
|
||||
p.setpos = p.set_pos
|
||||
p.moveto = p.move_to
|
||||
setmetatable(p, { __index = fake_player_metatable })
|
||||
return p
|
||||
end
|
||||
|
@ -1,14 +1,37 @@
|
||||
-- this bit of code overrides the default chests from common games (mtg, hades, minclone*) to be
|
||||
-- compatible with pipeworks. Where possible, it overrides their formspec to add a splitstacks switch
|
||||
-- this bit of code modifies the default chests and furnaces to be compatible
|
||||
-- with pipeworks.
|
||||
--
|
||||
-- the formspecs found here are basically copies of the ones from minetest_game
|
||||
-- plus bits from pipeworks' sorting tubes
|
||||
|
||||
-- Pipeworks Specific
|
||||
local fs_helpers = pipeworks.fs_helpers
|
||||
local tube_entry = "^pipeworks_tube_connection_wooden.png"
|
||||
|
||||
-- formspec helper to add the splitstacks switch
|
||||
local function add_pipeworks_switch(formspec, pos)
|
||||
-- based on the sorting tubes
|
||||
formspec = formspec ..
|
||||
-- Chest Locals
|
||||
local open_chests = {}
|
||||
|
||||
local get_chest_formspec
|
||||
|
||||
if minetest.get_modpath("default") then
|
||||
function get_chest_formspec(pos)
|
||||
local spos = pos.x .. "," .. pos.y .. "," .. pos.z
|
||||
local formspec =
|
||||
"size[8,9]" ..
|
||||
default.gui_bg ..
|
||||
default.gui_bg_img ..
|
||||
default.gui_slots ..
|
||||
"list[nodemeta:" .. spos .. ";main;0,0.3;8,4;]" ..
|
||||
"list[current_player;main;0,4.85;8,1;]" ..
|
||||
"list[current_player;main;0,6.08;8,3;8]" ..
|
||||
"listring[nodemeta:" .. spos .. ";main]" ..
|
||||
"listring[current_player;main]" ..
|
||||
default.get_hotbar_bg(0,4.85)
|
||||
|
||||
-- Pipeworks Switch
|
||||
formspec = formspec ..
|
||||
fs_helpers.cycling_button(
|
||||
core.get_meta(pos),
|
||||
minetest.get_meta(pos),
|
||||
pipeworks.button_base,
|
||||
"splitstacks",
|
||||
{
|
||||
@ -16,169 +39,271 @@ local function add_pipeworks_switch(formspec, pos)
|
||||
pipeworks.button_on
|
||||
}
|
||||
)..pipeworks.button_label
|
||||
return formspec
|
||||
end
|
||||
|
||||
-- helper to add the splitstacks switch to a node-formspec
|
||||
local function update_node_formspec(pos)
|
||||
local meta = core.get_meta(pos)
|
||||
local old_fs = meta:get_string("formspec")
|
||||
local new_fs = add_pipeworks_switch(old_fs, pos)
|
||||
meta:set_string("formspec", new_fs)
|
||||
end
|
||||
|
||||
|
||||
if core.get_modpath("default") then
|
||||
-- add the pipeworks switch into the default chest formspec
|
||||
local old_get_chest_formspec = default.chest.get_chest_formspec
|
||||
-- luacheck: ignore 122
|
||||
default.chest.get_chest_formspec = function(pos)
|
||||
local old_fs = old_get_chest_formspec(pos)
|
||||
local node = core.get_node(pos)
|
||||
-- not all chests using this formspec necessary connect to pipeworks
|
||||
if pipeworks.chests[node.name] then
|
||||
local new_fs = add_pipeworks_switch(old_fs, pos)
|
||||
return new_fs
|
||||
else
|
||||
return old_fs
|
||||
return formspec
|
||||
end
|
||||
else
|
||||
local function get_hotbar_bg(x,y)
|
||||
local out = ""
|
||||
for i=0,7,1 do
|
||||
out = out .."image["..x+i..","..y..";1,1;gui_hb_bg.png]"
|
||||
end
|
||||
return out
|
||||
end
|
||||
|
||||
-- get the fields from the chest formspec, we can do this bc. newest functions are called first
|
||||
-- https://github.com/luanti-org/luanti/blob/d4b10db998ebeb689b3d27368e30952a42169d03/doc/lua_api.md?plain=1#L5840
|
||||
core.register_on_player_receive_fields(function(player, formname, fields)
|
||||
if fields.quit or formname ~= "default:chest" then
|
||||
return
|
||||
end
|
||||
local pn = player:get_player_name()
|
||||
local chest_open = default.chest.open_chests[pn]
|
||||
if not chest_open or not chest_open.pos then
|
||||
-- chest already closed before formspec
|
||||
return
|
||||
end
|
||||
local pos = chest_open.pos
|
||||
local node = core.get_node(pos)
|
||||
if pipeworks.chests[node.name] and pipeworks.may_configure(pos, player) then
|
||||
-- Pipeworks Switch
|
||||
fs_helpers.on_receive_fields(pos, fields)
|
||||
core.show_formspec(pn,
|
||||
"default:chest",
|
||||
default.chest.get_chest_formspec(pos))
|
||||
end
|
||||
-- Do NOT return true here, the callback from default still needs to run
|
||||
function get_chest_formspec(pos)
|
||||
local spos = pos.x .. "," .. pos.y .. "," .. pos.z
|
||||
local formspec =
|
||||
"size[10,9]" ..
|
||||
"background9[8,8;8,9;hades_chests_chestui.png;true;8]"..
|
||||
"list[nodemeta:" .. spos .. ";main;0,0.3;10,4;]" ..
|
||||
"list[current_player;main;0,4.85;10,1;]" ..
|
||||
"list[current_player;main;0,6.08;10,3;10]" ..
|
||||
"listring[nodemeta:" .. spos .. ";main]" ..
|
||||
"listring[current_player;main]" ..
|
||||
get_hotbar_bg(0,4.85)
|
||||
|
||||
-- Pipeworks Switch
|
||||
formspec = formspec ..
|
||||
fs_helpers.cycling_button(
|
||||
minetest.get_meta(pos),
|
||||
pipeworks.button_base,
|
||||
"splitstacks",
|
||||
{
|
||||
pipeworks.button_off,
|
||||
pipeworks.button_on
|
||||
}
|
||||
)..pipeworks.button_label
|
||||
|
||||
return formspec
|
||||
end
|
||||
end
|
||||
|
||||
local function chest_lid_obstructed(pos)
|
||||
local above = { x = pos.x, y = pos.y + 1, z = pos.z }
|
||||
local def = minetest.registered_nodes[minetest.get_node(above).name]
|
||||
-- allow ladders, signs, wallmounted things and torches to not obstruct
|
||||
if not def then return true end
|
||||
if def.drawtype == "airlike" or
|
||||
def.drawtype == "signlike" or
|
||||
def.drawtype == "torchlike" or
|
||||
(def.drawtype == "nodebox" and def.paramtype2 == "wallmounted") then
|
||||
return false
|
||||
end)
|
||||
end
|
||||
return true
|
||||
end
|
||||
|
||||
local connect_sides = {left = 1, right = 1, back = 1, bottom = 1, top = 1}
|
||||
local connect_sides_open = {left = 1, right = 1, back = 1, bottom = 1}
|
||||
minetest.register_on_player_receive_fields(function(player, formname, fields)
|
||||
if formname == "pipeworks:chest_formspec" and player then
|
||||
local pn = player:get_player_name()
|
||||
if open_chests[pn] then
|
||||
local pos = open_chests[pn].pos
|
||||
if fields.quit then
|
||||
local sound = open_chests[pn].sound
|
||||
local swap = open_chests[pn].swap
|
||||
local node = minetest.get_node(pos)
|
||||
|
||||
pipeworks.override_chest("default:chest", {}, connect_sides)
|
||||
pipeworks.override_chest("default:chest_open", {}, connect_sides_open)
|
||||
pipeworks.override_chest("default:chest_locked", {}, connect_sides)
|
||||
pipeworks.override_chest("default:chest_locked_open", {}, connect_sides_open)
|
||||
elseif core.get_modpath("hades_chests") then
|
||||
local chest_colors = {"", "white", "grey", "dark_grey", "black", "blue", "cyan", "dark_green", "green", "magenta",
|
||||
"orange", "pink", "red", "violet", "yellow"}
|
||||
for _, color in ipairs(chest_colors) do
|
||||
local chestname = (color == "" and "hades_chests:chest")
|
||||
or "hades_chests:chest_" .. color
|
||||
local chestname_protected = (color == "" and "hades_chests:chest_locked")
|
||||
or "hades_chests:chest_" .. color .. "_locked"
|
||||
local old_def = core.registered_nodes[chestname]
|
||||
|
||||
-- chest formspec-creation functions are local, we need to find other ways
|
||||
-- normal chests use node formspecs, we can hack into these
|
||||
local old_on_construct = old_def.on_construct
|
||||
local override = {
|
||||
on_construct = function(pos)
|
||||
old_on_construct(pos)
|
||||
update_node_formspec(pos)
|
||||
end,
|
||||
on_receive_fields = function(pos, formname, fields, player)
|
||||
if not fields.quit and pipeworks.may_configure(pos, player) then
|
||||
-- Pipeworks Switch
|
||||
fs_helpers.on_receive_fields(pos, fields)
|
||||
update_node_formspec(pos)
|
||||
open_chests[pn] = nil
|
||||
for _, v in pairs(open_chests) do
|
||||
if v.pos.x == pos.x and v.pos.y == pos.y and v.pos.z == pos.z then
|
||||
return true
|
||||
end
|
||||
end
|
||||
end,
|
||||
-- chest's on_rotate is "simple", but we assumed the api from the mtg screwdriver mod
|
||||
-- this will keep the same behavior, but supports the code above
|
||||
on_rotate = screwdriver.rotate_simple
|
||||
}
|
||||
minetest.after(0.2, function()
|
||||
if minetest.get_modpath("default") then
|
||||
local current_node = minetest.get_node(pos)
|
||||
if current_node.name ~= "default:" .. swap .. "_open" then
|
||||
-- the chest has already been replaced, don't try to replace what's there.
|
||||
-- see: https://github.com/minetest/minetest_game/pull/3046
|
||||
return
|
||||
end
|
||||
minetest.swap_node(pos, { name = "default:" .. swap, param2 = node.param2 })
|
||||
end
|
||||
|
||||
-- locked chests uses local functions to create their formspec - we need to copy these
|
||||
-- https://codeberg.org/Wuzzy/Hades_Revisited/src/branch/master/mods/hades_chests/init.lua
|
||||
local function get_locked_chest_formspec(pos)
|
||||
local spos = pos.x .. "," .. pos.y .. "," ..pos.z
|
||||
local formspec =
|
||||
"size[10,9]"..
|
||||
"list[nodemeta:".. spos .. ";main;0,0;10,4;]"..
|
||||
"list[current_player;main;0,5;10,4;]"..
|
||||
"listring[]"..
|
||||
"background9[8,8;10,9;hades_chests_chestui.png;true;8]"
|
||||
|
||||
-- change from pipeworks
|
||||
local new_fs = add_pipeworks_switch(formspec, pos)
|
||||
return new_fs
|
||||
end
|
||||
|
||||
local function has_locked_chest_privilege(meta, player)
|
||||
local name = player:get_player_name()
|
||||
if name ~= meta:get_string("owner") and not core.check_player_privs(name, "protection_bypass") then
|
||||
return false
|
||||
-- Pipeworks notification
|
||||
pipeworks.after_place(pos)
|
||||
end)
|
||||
minetest.sound_play(sound, {gain = 0.3, pos = pos, max_hear_distance = 10})
|
||||
elseif pipeworks.may_configure(pos, player) then
|
||||
-- Pipeworks Switch
|
||||
fs_helpers.on_receive_fields(pos, fields)
|
||||
minetest.show_formspec(player:get_player_name(), "pipeworks:chest_formspec", get_chest_formspec(pos))
|
||||
end
|
||||
return true
|
||||
end
|
||||
|
||||
-- store, which chest a formspec submission belongs to
|
||||
-- {player1 = pos1, player2 = pos2, ...}
|
||||
local open_chests = {}
|
||||
core.register_on_leaveplayer(function(player)
|
||||
open_chests[player:get_player_name()] = nil
|
||||
end)
|
||||
|
||||
local override_protected = {
|
||||
on_rightclick = function(pos, node, clicker)
|
||||
local meta = core.get_meta(pos)
|
||||
if has_locked_chest_privilege(meta, clicker) then
|
||||
core.show_formspec(
|
||||
clicker:get_player_name(),
|
||||
"hades_chests:chest_locked",
|
||||
get_locked_chest_formspec(pos)
|
||||
)
|
||||
open_chests[clicker:get_player_name()] = pos
|
||||
else
|
||||
core.sound_play({ name = "hades_chests_locked", gain = 0.3 }, { max_hear_distance = 10 }, true)
|
||||
end
|
||||
end,
|
||||
on_rotate = screwdriver.rotate_simple
|
||||
}
|
||||
|
||||
-- get the fields from the chest formspec, we can do this bc. newest functions are called first
|
||||
-- https://github.com/luanti-org/luanti/blob/d4b10db998ebeb689b3d27368e30952a42169d03/doc/lua_api.md?plain=1#L5840
|
||||
core.register_on_player_receive_fields(function(player, formname, fields)
|
||||
if fields.quit or formname ~= "hades_chests:chest_locked" then
|
||||
return
|
||||
end
|
||||
local pn = player:get_player_name()
|
||||
local pos = open_chests[pn]
|
||||
if pos and pipeworks.may_configure(pos, player) then
|
||||
-- Pipeworks Switch
|
||||
fs_helpers.on_receive_fields(pos, fields)
|
||||
core.show_formspec(pn, "hades_chests:chest_locked", get_locked_chest_formspec(pos))
|
||||
end
|
||||
-- Do NOT return true here, the callback from hades still needs to run (if they add one)
|
||||
return false
|
||||
end)
|
||||
|
||||
local connect_sides = {left = 1, right = 1, back = 1, bottom = 1, top = 1}
|
||||
pipeworks.override_chest(chestname, override, connect_sides)
|
||||
pipeworks.override_chest(chestname_protected, override_protected, connect_sides)
|
||||
end
|
||||
elseif core.get_modpath("mcl_barrels") then
|
||||
-- TODO: bring splitstacks switch in the formspec
|
||||
-- with the current implementation of mcl_barrels this would mean to duplicate a lot of code from there...
|
||||
local connect_sides = {left = 1, right = 1, back = 1, front = 1, bottom = 1}
|
||||
pipeworks.override_chest("mcl_barrels:barrel_closed", {}, connect_sides)
|
||||
pipeworks.override_chest("mcl_barrels:barrel_open", {}, connect_sides)
|
||||
end)
|
||||
|
||||
-- Original Definitions
|
||||
local old_chest_def, old_chest_open_def, old_chest_locked_def, old_chest_locked_open_def
|
||||
if minetest.get_modpath("default") then
|
||||
old_chest_def = table.copy(minetest.registered_items["default:chest"])
|
||||
old_chest_open_def = table.copy(minetest.registered_items["default:chest_open"])
|
||||
old_chest_locked_def = table.copy(minetest.registered_items["default:chest_locked"])
|
||||
old_chest_locked_open_def = table.copy(minetest.registered_items["default:chest_locked_open"])
|
||||
elseif minetest.get_modpath("hades_chests") then
|
||||
old_chest_def = table.copy(minetest.registered_items["hades_chests:chest"])
|
||||
old_chest_open_def = table.copy(minetest.registered_items["hades_chests:chest"])
|
||||
old_chest_locked_def = table.copy(minetest.registered_items["hades_chests:chest_locked"])
|
||||
old_chest_locked_open_def = table.copy(minetest.registered_items["hades_chests:chest_locked"])
|
||||
end
|
||||
|
||||
-- Override Construction
|
||||
local override_protected, override, override_open, override_protected_open
|
||||
override_protected = {
|
||||
tiles = {
|
||||
"default_chest_top.png"..tube_entry,
|
||||
"default_chest_top.png"..tube_entry,
|
||||
"default_chest_side.png"..tube_entry,
|
||||
"default_chest_side.png"..tube_entry,
|
||||
"default_chest_lock.png",
|
||||
"default_chest_inside.png"
|
||||
},
|
||||
after_place_node = function(pos, placer)
|
||||
old_chest_locked_def.after_place_node(pos, placer)
|
||||
pipeworks.after_place(pos)
|
||||
end,
|
||||
on_rightclick = function(pos, node, clicker, itemstack, pointed_thing)
|
||||
if not default.can_interact_with_node(clicker, pos) then
|
||||
return itemstack
|
||||
end
|
||||
|
||||
minetest.sound_play(old_chest_locked_def.sound_open, {gain = 0.3,
|
||||
pos = pos, max_hear_distance = 10})
|
||||
if not chest_lid_obstructed(pos) then
|
||||
if minetest.get_modpath("default") then
|
||||
minetest.swap_node(pos,
|
||||
{ name = "default:" .. "chest_locked" .. "_open",
|
||||
param2 = node.param2 })
|
||||
end
|
||||
end
|
||||
minetest.after(0.2, minetest.show_formspec,
|
||||
clicker:get_player_name(),
|
||||
"pipeworks:chest_formspec", get_chest_formspec(pos))
|
||||
open_chests[clicker:get_player_name()] = { pos = pos,
|
||||
sound = old_chest_locked_def.sound_close, swap = "chest_locked" }
|
||||
end,
|
||||
groups = table.copy(old_chest_locked_def.groups),
|
||||
tube = {
|
||||
insert_object = function(pos, node, stack, direction)
|
||||
local meta = minetest.get_meta(pos)
|
||||
local inv = meta:get_inventory()
|
||||
return inv:add_item("main", stack)
|
||||
end,
|
||||
can_insert = function(pos, node, stack, direction)
|
||||
local meta = minetest.get_meta(pos)
|
||||
local inv = meta:get_inventory()
|
||||
if meta:get_int("splitstacks") == 1 then
|
||||
stack = stack:peek_item(1)
|
||||
end
|
||||
return inv:room_for_item("main", stack)
|
||||
end,
|
||||
input_inventory = "main",
|
||||
connect_sides = {left = 1, right = 1, back = 1, bottom = 1, top = 1}
|
||||
},
|
||||
after_dig_node = pipeworks.after_dig,
|
||||
on_rotate = pipeworks.on_rotate
|
||||
}
|
||||
override = {
|
||||
tiles = {
|
||||
"default_chest_top.png"..tube_entry,
|
||||
"default_chest_top.png"..tube_entry,
|
||||
"default_chest_side.png"..tube_entry,
|
||||
"default_chest_side.png"..tube_entry,
|
||||
"default_chest_front.png",
|
||||
"default_chest_inside.png"
|
||||
},
|
||||
on_rightclick = function(pos, node, clicker)
|
||||
minetest.sound_play(old_chest_def.sound_open, {gain = 0.3, pos = pos,
|
||||
max_hear_distance = 10})
|
||||
if not chest_lid_obstructed(pos) then
|
||||
if minetest.get_modpath("default") then
|
||||
minetest.swap_node(pos, {
|
||||
name = "default:" .. "chest" .. "_open",
|
||||
param2 = node.param2 })
|
||||
end
|
||||
end
|
||||
minetest.after(0.2, minetest.show_formspec,
|
||||
clicker:get_player_name(),
|
||||
"pipeworks:chest_formspec", get_chest_formspec(pos))
|
||||
open_chests[clicker:get_player_name()] = { pos = pos,
|
||||
sound = old_chest_def.sound_close, swap = "chest" }
|
||||
end,
|
||||
groups = table.copy(old_chest_def.groups),
|
||||
tube = {
|
||||
insert_object = function(pos, node, stack, direction)
|
||||
local meta = minetest.get_meta(pos)
|
||||
local inv = meta:get_inventory()
|
||||
return inv:add_item("main", stack)
|
||||
end,
|
||||
can_insert = function(pos, node, stack, direction)
|
||||
local meta = minetest.get_meta(pos)
|
||||
local inv = meta:get_inventory()
|
||||
if meta:get_int("splitstacks") == 1 then
|
||||
stack = stack:peek_item(1)
|
||||
end
|
||||
return inv:room_for_item("main", stack)
|
||||
end,
|
||||
input_inventory = "main",
|
||||
connect_sides = {left = 1, right = 1, back = 1, bottom = 1, top = 1}
|
||||
},
|
||||
after_place_node = pipeworks.after_place,
|
||||
after_dig_node = pipeworks.after_dig,
|
||||
on_rotate = pipeworks.on_rotate
|
||||
}
|
||||
--[[local override_common = {
|
||||
|
||||
}
|
||||
for k,v in pairs(override_common) do
|
||||
override_protected[k] = v
|
||||
override[k] = v
|
||||
end]]
|
||||
|
||||
override_open = table.copy(override)
|
||||
override_open.groups = table.copy(old_chest_open_def.groups)
|
||||
override_open.tube = table.copy(override.tube)
|
||||
override_open.tube.connect_sides = table.copy(override.tube.connect_sides)
|
||||
override_open.tube.connect_sides.top = nil
|
||||
|
||||
override_protected_open = table.copy(override_protected)
|
||||
override_protected_open.groups = table.copy(old_chest_locked_open_def.groups)
|
||||
override_protected_open.tube = table.copy(override_protected.tube)
|
||||
override_protected_open.tube.connect_sides = table.copy(override_protected.tube.connect_sides)
|
||||
override_protected_open.tube.connect_sides.top = nil
|
||||
|
||||
override_protected.tiles = { -- Rearranged according to the chest registration in Minetest_Game.
|
||||
"default_chest_top.png"..tube_entry,
|
||||
"default_chest_top.png"..tube_entry,
|
||||
"default_chest_side.png"..tube_entry.."^[transformFX",
|
||||
"default_chest_side.png"..tube_entry,
|
||||
"default_chest_side.png"..tube_entry,
|
||||
"default_chest_lock.png",
|
||||
}
|
||||
override.tiles = {
|
||||
"default_chest_top.png"..tube_entry,
|
||||
"default_chest_top.png"..tube_entry,
|
||||
"default_chest_side.png"..tube_entry.."^[transformFX",
|
||||
"default_chest_side.png"..tube_entry,
|
||||
"default_chest_side.png"..tube_entry,
|
||||
"default_chest_front.png",
|
||||
}
|
||||
|
||||
-- Add the extra groups
|
||||
for _,v in ipairs({override_protected, override, override_open, override_protected_open}) do
|
||||
v.groups.tubedevice = 1
|
||||
v.groups.tubedevice_receiver = 1
|
||||
end
|
||||
|
||||
-- Override with the new modifications.
|
||||
if minetest.get_modpath("default") then
|
||||
minetest.override_item("default:chest", override)
|
||||
minetest.override_item("default:chest_open", override_open)
|
||||
minetest.override_item("default:chest_locked", override_protected)
|
||||
minetest.override_item("default:chest_locked_open", override_protected_open)
|
||||
elseif minetest.get_modpath("hades_chests") then
|
||||
minetest.override_item("hades_chests:chest", override)
|
||||
--minetest.override_item("hades_chests:chest_open", override_open)
|
||||
minetest.override_item("hades_chests:chest_locked", override_protected)
|
||||
--minetest.override_item("hades_chests:chest_locked_open", override_protected_open)
|
||||
end
|
||||
|
||||
|
@ -2,12 +2,12 @@
|
||||
-- minetest_game/mods/default/furnaces.lua
|
||||
|
||||
local def--, def_active
|
||||
if core.get_modpath("default") then
|
||||
def = table.copy(core.registered_nodes["default:furnace"])
|
||||
--def_active = table.copy(core.registered_nodes["default:furnace_active"])
|
||||
elseif core.get_modpath("hades_furnaces") then
|
||||
def = table.copy(core.registered_nodes["hades_furnaces:furnace"])
|
||||
--def_active = table.copy(core.registered_nodes["hades_furnaces:furnace_active"])
|
||||
if minetest.get_modpath("default") then
|
||||
def = table.copy(minetest.registered_nodes["default:furnace"])
|
||||
--def_active = table.copy(minetest.registered_nodes["default:furnace_active"])
|
||||
elseif minetest.get_modpath("hades_furnaces") then
|
||||
def = table.copy(minetest.registered_nodes["hades_furnaces:furnace"])
|
||||
--def_active = table.copy(minetest.registered_nodes["hades_furnaces:furnace_active"])
|
||||
end
|
||||
|
||||
local tube_entry = "^pipeworks_tube_connection_stony.png"
|
||||
@ -34,9 +34,9 @@ local override = {
|
||||
groups = groups,
|
||||
tube = {
|
||||
insert_object = function(pos, node, stack, direction)
|
||||
local meta = core.get_meta(pos)
|
||||
local meta = minetest.get_meta(pos)
|
||||
local inv = meta:get_inventory()
|
||||
local timer = core.get_node_timer(pos)
|
||||
local timer = minetest.get_node_timer(pos)
|
||||
if not timer:is_started() then
|
||||
timer:start(1.0)
|
||||
end
|
||||
@ -47,7 +47,7 @@ local override = {
|
||||
end
|
||||
end,
|
||||
can_insert = function(pos,node,stack,direction)
|
||||
local meta = core.get_meta(pos)
|
||||
local meta = minetest.get_meta(pos)
|
||||
local inv = meta:get_inventory()
|
||||
if direction.y == 1 then
|
||||
return inv:room_for_item("fuel", stack)
|
||||
@ -88,9 +88,9 @@ local override_active = {
|
||||
groups = groups_active,
|
||||
tube = {
|
||||
insert_object = function(pos,node,stack,direction)
|
||||
local meta = core.get_meta(pos)
|
||||
local meta = minetest.get_meta(pos)
|
||||
local inv = meta:get_inventory()
|
||||
local timer = core.get_node_timer(pos)
|
||||
local timer = minetest.get_node_timer(pos)
|
||||
if not timer:is_started() then
|
||||
timer:start(1.0)
|
||||
end
|
||||
@ -101,7 +101,7 @@ local override_active = {
|
||||
end
|
||||
end,
|
||||
can_insert = function(pos, node, stack, direction)
|
||||
local meta = core.get_meta(pos)
|
||||
local meta = minetest.get_meta(pos)
|
||||
local inv = meta:get_inventory()
|
||||
if direction.y == 1 then
|
||||
return inv:room_for_item("fuel", stack)
|
||||
@ -118,11 +118,11 @@ local override_active = {
|
||||
on_rotate = pipeworks.on_rotate
|
||||
}
|
||||
|
||||
if core.get_modpath("default") then
|
||||
core.override_item("default:furnace", override)
|
||||
core.override_item("default:furnace_active", override_active)
|
||||
elseif core.get_modpath("hades_furnaces") then
|
||||
core.override_item("hades_furnaces:furnace", override)
|
||||
core.override_item("hades_furnaces:furnace_active", override_active)
|
||||
if minetest.get_modpath("default") then
|
||||
minetest.override_item("default:furnace", override)
|
||||
minetest.override_item("default:furnace_active", override_active)
|
||||
elseif minetest.get_modpath("hades_furnaces") then
|
||||
minetest.override_item("hades_furnaces:furnace", override)
|
||||
minetest.override_item("hades_furnaces:furnace_active", override_active)
|
||||
end
|
||||
|
||||
|
66
crafts.lua
66
crafts.lua
@ -1,7 +1,7 @@
|
||||
-- Crafting recipes for pipes
|
||||
local materials = xcompat.materials
|
||||
|
||||
core.register_craft( {
|
||||
minetest.register_craft( {
|
||||
output = "pipeworks:pipe_1_empty 12",
|
||||
recipe = {
|
||||
{ materials.steel_ingot, materials.steel_ingot, materials.steel_ingot },
|
||||
@ -10,14 +10,14 @@ core.register_craft( {
|
||||
},
|
||||
})
|
||||
|
||||
core.register_craft( {
|
||||
minetest.register_craft( {
|
||||
output = "pipeworks:straight_pipe_empty 3",
|
||||
recipe = {
|
||||
{ "pipeworks:pipe_1_empty", "pipeworks:pipe_1_empty", "pipeworks:pipe_1_empty" },
|
||||
},
|
||||
})
|
||||
|
||||
core.register_craft( {
|
||||
minetest.register_craft( {
|
||||
output = "pipeworks:spigot 3",
|
||||
recipe = {
|
||||
{ "pipeworks:pipe_1_empty", "" },
|
||||
@ -25,7 +25,7 @@ core.register_craft( {
|
||||
},
|
||||
})
|
||||
|
||||
core.register_craft( {
|
||||
minetest.register_craft( {
|
||||
output = "pipeworks:entry_panel_empty 2",
|
||||
recipe = {
|
||||
{ "", materials.steel_ingot, "" },
|
||||
@ -36,7 +36,7 @@ recipe = {
|
||||
|
||||
-- Various ancillary pipe devices
|
||||
|
||||
core.register_craft( {
|
||||
minetest.register_craft( {
|
||||
output = "pipeworks:pump_off 2",
|
||||
recipe = {
|
||||
{ materials.stone, materials.steel_ingot, materials.stone },
|
||||
@ -45,7 +45,7 @@ core.register_craft( {
|
||||
},
|
||||
})
|
||||
|
||||
core.register_craft( {
|
||||
minetest.register_craft( {
|
||||
output = "pipeworks:valve_off_empty 2",
|
||||
recipe = {
|
||||
{ "", "group:stick", "" },
|
||||
@ -54,7 +54,7 @@ core.register_craft( {
|
||||
},
|
||||
})
|
||||
|
||||
core.register_craft( {
|
||||
minetest.register_craft( {
|
||||
output = "pipeworks:storage_tank_0 2",
|
||||
recipe = {
|
||||
{ "", materials.steel_ingot, materials.steel_ingot },
|
||||
@ -63,7 +63,7 @@ core.register_craft( {
|
||||
},
|
||||
})
|
||||
|
||||
core.register_craft( {
|
||||
minetest.register_craft( {
|
||||
output = "pipeworks:grating 2",
|
||||
recipe = {
|
||||
{ materials.steel_ingot, "", materials.steel_ingot },
|
||||
@ -72,14 +72,14 @@ core.register_craft( {
|
||||
},
|
||||
})
|
||||
|
||||
core.register_craft( {
|
||||
minetest.register_craft( {
|
||||
output = "pipeworks:flow_sensor_empty 2",
|
||||
recipe = {
|
||||
{ "pipeworks:pipe_1_empty", "mesecons:mesecon", "pipeworks:pipe_1_empty" },
|
||||
},
|
||||
})
|
||||
|
||||
core.register_craft( {
|
||||
minetest.register_craft( {
|
||||
output = "pipeworks:fountainhead 2",
|
||||
recipe = {
|
||||
{ "pipeworks:pipe_1_empty" },
|
||||
@ -89,7 +89,7 @@ core.register_craft( {
|
||||
|
||||
-- injectors
|
||||
|
||||
core.register_craft( {
|
||||
minetest.register_craft( {
|
||||
output = "pipeworks:filter 2",
|
||||
recipe = {
|
||||
{ materials.steel_ingot, materials.steel_ingot, "basic_materials:plastic_sheet" },
|
||||
@ -98,7 +98,7 @@ core.register_craft( {
|
||||
},
|
||||
})
|
||||
|
||||
core.register_craft( {
|
||||
minetest.register_craft( {
|
||||
output = "pipeworks:mese_filter 2",
|
||||
recipe = {
|
||||
{ materials.steel_ingot, materials.steel_ingot, "basic_materials:plastic_sheet" },
|
||||
@ -107,8 +107,8 @@ core.register_craft( {
|
||||
},
|
||||
})
|
||||
|
||||
if core.get_modpath("digilines") then
|
||||
core.register_craft( {
|
||||
if minetest.get_modpath("digilines") then
|
||||
minetest.register_craft( {
|
||||
output = "pipeworks:digiline_filter 2",
|
||||
recipe = {
|
||||
{ materials.steel_ingot, materials.steel_ingot, "basic_materials:plastic_sheet" },
|
||||
@ -120,7 +120,7 @@ end
|
||||
|
||||
-- other
|
||||
|
||||
core.register_craft( {
|
||||
minetest.register_craft( {
|
||||
output = "pipeworks:autocrafter 2",
|
||||
recipe = {
|
||||
{ materials.steel_ingot, materials.mese_crystal, materials.steel_ingot },
|
||||
@ -129,7 +129,7 @@ core.register_craft( {
|
||||
},
|
||||
})
|
||||
|
||||
core.register_craft( {
|
||||
minetest.register_craft( {
|
||||
output = "pipeworks:steel_pane_embedded_tube 1",
|
||||
recipe = {
|
||||
{ "", materials.steel_ingot, "" },
|
||||
@ -138,7 +138,7 @@ core.register_craft( {
|
||||
},
|
||||
})
|
||||
|
||||
core.register_craft({
|
||||
minetest.register_craft({
|
||||
output = "pipeworks:trashcan",
|
||||
recipe = {
|
||||
{ "basic_materials:plastic_sheet", "basic_materials:plastic_sheet", "basic_materials:plastic_sheet" },
|
||||
@ -147,7 +147,7 @@ core.register_craft({
|
||||
},
|
||||
})
|
||||
|
||||
core.register_craft( {
|
||||
minetest.register_craft( {
|
||||
output = "pipeworks:teleport_tube_1 2",
|
||||
recipe = {
|
||||
{ "basic_materials:plastic_sheet", "basic_materials:plastic_sheet", "basic_materials:plastic_sheet" },
|
||||
@ -157,7 +157,7 @@ core.register_craft( {
|
||||
})
|
||||
|
||||
if pipeworks.enable_priority_tube then
|
||||
core.register_craft( {
|
||||
minetest.register_craft( {
|
||||
output = "pipeworks:priority_tube_1 6",
|
||||
recipe = {
|
||||
{ "basic_materials:plastic_sheet", "basic_materials:plastic_sheet", "basic_materials:plastic_sheet" },
|
||||
@ -168,7 +168,7 @@ if pipeworks.enable_priority_tube then
|
||||
end
|
||||
|
||||
if pipeworks.enable_accelerator_tube then
|
||||
core.register_craft( {
|
||||
minetest.register_craft( {
|
||||
output = "pipeworks:accelerator_tube_1 2",
|
||||
recipe = {
|
||||
{ "basic_materials:plastic_sheet", "basic_materials:plastic_sheet", "basic_materials:plastic_sheet" },
|
||||
@ -179,7 +179,7 @@ if pipeworks.enable_accelerator_tube then
|
||||
end
|
||||
|
||||
if pipeworks.enable_crossing_tube then
|
||||
core.register_craft( {
|
||||
minetest.register_craft( {
|
||||
output = "pipeworks:crossing_tube_1 5",
|
||||
recipe = {
|
||||
{ "", "pipeworks:tube_1", "" },
|
||||
@ -190,7 +190,7 @@ if pipeworks.enable_crossing_tube then
|
||||
end
|
||||
|
||||
if pipeworks.enable_one_way_tube then
|
||||
core.register_craft({
|
||||
minetest.register_craft({
|
||||
output = "pipeworks:one_way_tube 2",
|
||||
recipe = {
|
||||
{ "basic_materials:plastic_sheet", "basic_materials:plastic_sheet", "basic_materials:plastic_sheet" },
|
||||
@ -201,7 +201,7 @@ if pipeworks.enable_one_way_tube then
|
||||
end
|
||||
|
||||
if pipeworks.enable_mese_tube then
|
||||
core.register_craft( {
|
||||
minetest.register_craft( {
|
||||
output = "pipeworks:mese_tube_000000 2",
|
||||
recipe = {
|
||||
{ "basic_materials:plastic_sheet", "basic_materials:plastic_sheet", "basic_materials:plastic_sheet" },
|
||||
@ -210,7 +210,7 @@ if pipeworks.enable_mese_tube then
|
||||
},
|
||||
})
|
||||
|
||||
core.register_craft( {
|
||||
minetest.register_craft( {
|
||||
type = "shapeless",
|
||||
output = "pipeworks:mese_tube_000000",
|
||||
recipe = {
|
||||
@ -224,7 +224,7 @@ if pipeworks.enable_mese_tube then
|
||||
end
|
||||
|
||||
if pipeworks.enable_item_tags and pipeworks.enable_tag_tube then
|
||||
core.register_craft( {
|
||||
minetest.register_craft( {
|
||||
output = "pipeworks:tag_tube_000000 2",
|
||||
recipe = {
|
||||
{ "basic_materials:plastic_sheet", "basic_materials:plastic_sheet", "basic_materials:plastic_sheet" },
|
||||
@ -233,7 +233,7 @@ if pipeworks.enable_item_tags and pipeworks.enable_tag_tube then
|
||||
},
|
||||
})
|
||||
|
||||
core.register_craft( {
|
||||
minetest.register_craft( {
|
||||
type = "shapeless",
|
||||
output = "pipeworks:tag_tube_000000",
|
||||
recipe = {
|
||||
@ -244,7 +244,7 @@ if pipeworks.enable_item_tags and pipeworks.enable_tag_tube then
|
||||
end
|
||||
|
||||
if pipeworks.enable_sand_tube then
|
||||
core.register_craft( {
|
||||
minetest.register_craft( {
|
||||
output = "pipeworks:sand_tube_1 2",
|
||||
recipe = {
|
||||
{"basic_materials:plastic_sheet", "basic_materials:plastic_sheet", "basic_materials:plastic_sheet"},
|
||||
@ -253,7 +253,7 @@ if pipeworks.enable_sand_tube then
|
||||
},
|
||||
})
|
||||
|
||||
core.register_craft( {
|
||||
minetest.register_craft( {
|
||||
output = "pipeworks:sand_tube_1",
|
||||
recipe = {
|
||||
{"group:sand", "pipeworks:tube_1", "group:sand"},
|
||||
@ -262,7 +262,7 @@ if pipeworks.enable_sand_tube then
|
||||
end
|
||||
|
||||
if pipeworks.enable_mese_sand_tube then
|
||||
core.register_craft( {
|
||||
minetest.register_craft( {
|
||||
output = "pipeworks:mese_sand_tube_1 2",
|
||||
recipe = {
|
||||
{"basic_materials:plastic_sheet", "basic_materials:plastic_sheet", "basic_materials:plastic_sheet" },
|
||||
@ -271,7 +271,7 @@ if pipeworks.enable_mese_sand_tube then
|
||||
},
|
||||
})
|
||||
|
||||
core.register_craft( {
|
||||
minetest.register_craft( {
|
||||
type = "shapeless",
|
||||
output = "pipeworks:mese_sand_tube_1",
|
||||
recipe = {
|
||||
@ -285,7 +285,7 @@ if pipeworks.enable_mese_sand_tube then
|
||||
end
|
||||
|
||||
if pipeworks.enable_deployer then
|
||||
core.register_craft({
|
||||
minetest.register_craft({
|
||||
output = "pipeworks:deployer_off",
|
||||
recipe = {
|
||||
{ "group:wood", materials.chest, "group:wood" },
|
||||
@ -296,7 +296,7 @@ if pipeworks.enable_deployer then
|
||||
end
|
||||
|
||||
if pipeworks.enable_dispenser then
|
||||
core.register_craft({
|
||||
minetest.register_craft({
|
||||
output = "pipeworks:dispenser_off",
|
||||
recipe = {
|
||||
{ materials.desert_sand, materials.chest, materials.desert_sand },
|
||||
@ -307,7 +307,7 @@ if pipeworks.enable_dispenser then
|
||||
end
|
||||
|
||||
if pipeworks.enable_node_breaker then
|
||||
core.register_craft({
|
||||
minetest.register_craft({
|
||||
output = "pipeworks:nodebreaker_off",
|
||||
recipe = {
|
||||
{ "basic_materials:gear_steel", "basic_materials:gear_steel", "basic_materials:gear_steel" },
|
||||
|
@ -31,7 +31,6 @@ local settings = {
|
||||
delete_item_on_clearobject = true,
|
||||
use_real_entities = true,
|
||||
entity_update_interval = 0,
|
||||
enable_vertical_digilines_connectivity = false,
|
||||
}
|
||||
|
||||
pipeworks.toggles = {}
|
||||
@ -67,9 +66,9 @@ pipeworks.toggles.finite_water = nil
|
||||
for name, value in pairs(settings) do
|
||||
local setting_type = type(value)
|
||||
if setting_type == "boolean" then
|
||||
pipeworks[name] = core.settings:get_bool(prefix..name, value)
|
||||
pipeworks[name] = minetest.settings:get_bool(prefix..name, value)
|
||||
elseif setting_type == "number" then
|
||||
pipeworks[name] = tonumber(core.settings:get(prefix..name) or value)
|
||||
pipeworks[name] = tonumber(minetest.settings:get(prefix..name) or value)
|
||||
else
|
||||
pipeworks[name] = value
|
||||
end
|
||||
|
96
devices.lua
96
devices.lua
@ -1,7 +1,7 @@
|
||||
local S = core.get_translator("pipeworks")
|
||||
local S = minetest.get_translator("pipeworks")
|
||||
local new_flow_logic_register = pipeworks.flowables.register
|
||||
|
||||
local texture_alpha_mode = core.features.use_texture_alpha_string_modes
|
||||
local texture_alpha_mode = minetest.features.use_texture_alpha_string_modes
|
||||
|
||||
local polys = ""
|
||||
if pipeworks.enable_lowpoly then polys = "_lowpoly" end
|
||||
@ -13,7 +13,7 @@ function pipeworks.fix_after_rotation(pos, node, user, mode, new_param2)
|
||||
if string.find(node.name, "spigot") then new_param2 = new_param2 % 4 end
|
||||
|
||||
local newnode = string.gsub(node.name, "_on", "_off")
|
||||
core.swap_node(pos, { name = newnode, param2 = new_param2 })
|
||||
minetest.swap_node(pos, { name = newnode, param2 = new_param2 })
|
||||
pipeworks.scan_for_pipe_objects(pos)
|
||||
|
||||
return true
|
||||
@ -22,15 +22,15 @@ end
|
||||
function pipeworks.rotate_on_place(itemstack, placer, pointed_thing)
|
||||
|
||||
local playername = placer:get_player_name()
|
||||
if not core.is_protected(pointed_thing.under, playername)
|
||||
and not core.is_protected(pointed_thing.above, playername) then
|
||||
if not minetest.is_protected(pointed_thing.under, playername)
|
||||
and not minetest.is_protected(pointed_thing.above, playername) then
|
||||
|
||||
local node = core.get_node(pointed_thing.under)
|
||||
local node = minetest.get_node(pointed_thing.under)
|
||||
|
||||
if (not placer:get_player_control().sneak)
|
||||
and core.registered_nodes[node.name]
|
||||
and core.registered_nodes[node.name].on_rightclick then
|
||||
core.registered_nodes[node.name].on_rightclick(pointed_thing.under,
|
||||
and minetest.registered_nodes[node.name]
|
||||
and minetest.registered_nodes[node.name].on_rightclick then
|
||||
minetest.registered_nodes[node.name].on_rightclick(pointed_thing.under,
|
||||
node, placer, itemstack, pointed_thing)
|
||||
|
||||
else
|
||||
@ -38,8 +38,8 @@ function pipeworks.rotate_on_place(itemstack, placer, pointed_thing)
|
||||
local pitch = -placer:get_look_vertical()
|
||||
local above = pointed_thing.above
|
||||
local under = pointed_thing.under
|
||||
local fdir = core.dir_to_facedir(placer:get_look_dir())
|
||||
local undernode = core.get_node(under)
|
||||
local fdir = minetest.dir_to_facedir(placer:get_look_dir())
|
||||
local undernode = minetest.get_node(under)
|
||||
local uname = undernode.name
|
||||
local isabove = (above.x == under.x) and (above.z == under.z) and (pitch > 0)
|
||||
local pos1 = above
|
||||
@ -58,24 +58,24 @@ function pipeworks.rotate_on_place(itemstack, placer, pointed_thing)
|
||||
( string.find(uname, "pipeworks:valve")
|
||||
or string.find(uname, "pipeworks:entry_panel")
|
||||
or string.find(uname, "pipeworks:flow_sensor") )
|
||||
and core.facedir_to_dir(undernode.param2).y ~= 0 )
|
||||
and minetest.facedir_to_dir(undernode.param2).y ~= 0 )
|
||||
)
|
||||
then
|
||||
fdir = 17
|
||||
end
|
||||
|
||||
if core.registered_nodes[uname]
|
||||
and core.registered_nodes[uname]["buildable_to"] then
|
||||
if minetest.registered_nodes[uname]
|
||||
and minetest.registered_nodes[uname]["buildable_to"] then
|
||||
pos1 = under
|
||||
end
|
||||
|
||||
if core.registered_nodes[core.get_node(pos1).name]
|
||||
and not core.registered_nodes[core.get_node(pos1).name]["buildable_to"] then return end
|
||||
if minetest.registered_nodes[minetest.get_node(pos1).name]
|
||||
and not minetest.registered_nodes[minetest.get_node(pos1).name]["buildable_to"] then return end
|
||||
|
||||
local placednode = string.gsub(itemstack:get_name(), "_loaded", "_empty")
|
||||
placednode = string.gsub(placednode, "_on", "_off")
|
||||
|
||||
core.swap_node(pos1, {name = placednode, param2 = fdir })
|
||||
minetest.swap_node(pos1, {name = placednode, param2 = fdir })
|
||||
pipeworks.scan_for_pipe_objects(pos1)
|
||||
|
||||
if not pipeworks.expect_infinite_stacks then
|
||||
@ -91,7 +91,7 @@ end
|
||||
local pipereceptor_on = nil
|
||||
local pipereceptor_off = nil
|
||||
|
||||
if core.get_modpath("mesecons") then
|
||||
if minetest.get_modpath("mesecons") then
|
||||
pipereceptor_on = {
|
||||
receptor = {
|
||||
state = mesecon.state.on,
|
||||
@ -139,7 +139,7 @@ for s in ipairs(states) do
|
||||
end
|
||||
|
||||
local pumpname = "pipeworks:pump_"..states[s]
|
||||
core.register_node(pumpname, {
|
||||
minetest.register_node(pumpname, {
|
||||
description = S("Pump/Intake Module"),
|
||||
drawtype = "mesh",
|
||||
mesh = "pipeworks_pump"..polys..".obj",
|
||||
@ -164,15 +164,15 @@ for s in ipairs(states) do
|
||||
drop = "pipeworks:pump_off",
|
||||
mesecons = {effector = {
|
||||
action_on = function (pos, node)
|
||||
core.swap_node(pos,{name="pipeworks:pump_on", param2 = node.param2})
|
||||
minetest.swap_node(pos,{name="pipeworks:pump_on", param2 = node.param2})
|
||||
end,
|
||||
action_off = function (pos, node)
|
||||
core.swap_node(pos,{name="pipeworks:pump_off", param2 = node.param2})
|
||||
minetest.swap_node(pos,{name="pipeworks:pump_off", param2 = node.param2})
|
||||
end
|
||||
}},
|
||||
on_rightclick = function(pos, node, clicker, itemstack, pointed_thing)
|
||||
local fdir = node.param2
|
||||
core.swap_node(pos, { name = "pipeworks:pump_"..states[3-s], param2 = fdir })
|
||||
minetest.swap_node(pos, { name = "pipeworks:pump_"..states[3-s], param2 = fdir })
|
||||
end,
|
||||
on_rotate = screwdriver and screwdriver.rotate_simple or nil
|
||||
})
|
||||
@ -187,7 +187,7 @@ for s in ipairs(states) do
|
||||
|
||||
|
||||
local nodename_valve_empty = "pipeworks:valve_"..states[s].."_empty"
|
||||
core.register_node(nodename_valve_empty, {
|
||||
minetest.register_node(nodename_valve_empty, {
|
||||
description = S("Valve"),
|
||||
drawtype = "mesh",
|
||||
mesh = "pipeworks_valve_"..states[s]..polys..".obj",
|
||||
@ -217,15 +217,15 @@ for s in ipairs(states) do
|
||||
drop = "pipeworks:valve_off_empty",
|
||||
mesecons = {effector = {
|
||||
action_on = function (pos, node)
|
||||
core.swap_node(pos,{name="pipeworks:valve_on_empty", param2 = node.param2})
|
||||
minetest.swap_node(pos,{name="pipeworks:valve_on_empty", param2 = node.param2})
|
||||
end,
|
||||
action_off = function (pos, node)
|
||||
core.swap_node(pos,{name="pipeworks:valve_off_empty", param2 = node.param2})
|
||||
minetest.swap_node(pos,{name="pipeworks:valve_off_empty", param2 = node.param2})
|
||||
end
|
||||
}},
|
||||
on_rightclick = function(pos, node, clicker, itemstack, pointed_thing)
|
||||
local fdir = node.param2
|
||||
core.swap_node(pos, { name = "pipeworks:valve_"..states[3-s].."_empty", param2 = fdir })
|
||||
minetest.swap_node(pos, { name = "pipeworks:valve_"..states[3-s].."_empty", param2 = fdir })
|
||||
end,
|
||||
on_rotate = pipeworks.fix_after_rotation
|
||||
})
|
||||
@ -239,7 +239,7 @@ pipeworks.ui_cat_tube_list[#pipeworks.ui_cat_tube_list+1] = "pipeworks:pump_off"
|
||||
pipeworks.ui_cat_tube_list[#pipeworks.ui_cat_tube_list+1] = "pipeworks:valve_off_empty"
|
||||
|
||||
local nodename_valve_loaded = "pipeworks:valve_on_loaded"
|
||||
core.register_node(nodename_valve_loaded, {
|
||||
minetest.register_node(nodename_valve_loaded, {
|
||||
description = S("Valve"),
|
||||
drawtype = "mesh",
|
||||
mesh = "pipeworks_valve_on"..polys..".obj",
|
||||
@ -269,15 +269,15 @@ core.register_node(nodename_valve_loaded, {
|
||||
drop = "pipeworks:valve_off_empty",
|
||||
mesecons = {effector = {
|
||||
action_on = function (pos, node)
|
||||
core.swap_node(pos,{name="pipeworks:valve_on_empty", param2 = node.param2})
|
||||
minetest.swap_node(pos,{name="pipeworks:valve_on_empty", param2 = node.param2})
|
||||
end,
|
||||
action_off = function (pos, node)
|
||||
core.swap_node(pos,{name="pipeworks:valve_off_empty", param2 = node.param2})
|
||||
minetest.swap_node(pos,{name="pipeworks:valve_off_empty", param2 = node.param2})
|
||||
end
|
||||
}},
|
||||
on_rightclick = function(pos, node, clicker, itemstack, pointed_thing)
|
||||
local fdir = node.param2
|
||||
core.swap_node(pos, { name = "pipeworks:valve_off_empty", param2 = fdir })
|
||||
minetest.swap_node(pos, { name = "pipeworks:valve_off_empty", param2 = fdir })
|
||||
end,
|
||||
on_rotate = pipeworks.fix_after_rotation
|
||||
})
|
||||
@ -291,7 +291,7 @@ new_flow_logic_register.directional_horizonal_rotate(nodename_valve_loaded, true
|
||||
-- grating
|
||||
|
||||
-- FIXME: should this do anything useful in the new flow logic?
|
||||
core.register_node("pipeworks:grating", {
|
||||
minetest.register_node("pipeworks:grating", {
|
||||
description = S("Decorative grating"),
|
||||
tiles = {
|
||||
"pipeworks_grating_top.png",
|
||||
@ -330,7 +330,7 @@ pipeworks.ui_cat_tube_list[#pipeworks.ui_cat_tube_list+1] = "pipeworks:grating"
|
||||
-- outlet spigot
|
||||
|
||||
local nodename_spigot_empty = "pipeworks:spigot"
|
||||
core.register_node(nodename_spigot_empty, {
|
||||
minetest.register_node(nodename_spigot_empty, {
|
||||
description = S("Spigot outlet"),
|
||||
drawtype = "mesh",
|
||||
mesh = "pipeworks_spigot"..polys..".obj",
|
||||
@ -365,12 +365,12 @@ core.register_node(nodename_spigot_empty, {
|
||||
})
|
||||
|
||||
local nodename_spigot_loaded = "pipeworks:spigot_pouring"
|
||||
core.register_node(nodename_spigot_loaded, {
|
||||
minetest.register_node(nodename_spigot_loaded, {
|
||||
description = S("Spigot outlet"),
|
||||
drawtype = "mesh",
|
||||
mesh = "pipeworks_spigot_pouring"..polys..".obj",
|
||||
tiles = {
|
||||
core.registered_nodes[pipeworks.liquids.water.source].tiles[1],
|
||||
minetest.registered_nodes[pipeworks.liquids.water.source].tiles[1],
|
||||
{ name = "pipeworks_spigot.png" }
|
||||
},
|
||||
use_texture_alpha = texture_alpha_mode and "blend" or true,
|
||||
@ -387,7 +387,7 @@ core.register_node(nodename_spigot_loaded, {
|
||||
pipe_connections = { left=1, right=1, front=1, back=1,
|
||||
left_param2 = 3, right_param2 = 1, front_param2 = 2, back_param2 = 0 },
|
||||
after_place_node = function(pos)
|
||||
core.set_node(pos, { name = "pipeworks:spigot", param2 = core.get_node(pos).param2 })
|
||||
minetest.set_node(pos, { name = "pipeworks:spigot", param2 = minetest.get_node(pos).param2 })
|
||||
pipeworks.scan_for_pipe_objects(pos)
|
||||
end,
|
||||
after_dig_node = function(pos)
|
||||
@ -430,7 +430,7 @@ local panel_cbox = {
|
||||
}
|
||||
|
||||
local nodename_panel_empty = "pipeworks:entry_panel_empty"
|
||||
core.register_node(nodename_panel_empty, {
|
||||
minetest.register_node(nodename_panel_empty, {
|
||||
description = S("Airtight Pipe entry/exit"),
|
||||
drawtype = "mesh",
|
||||
mesh = "pipeworks_entry_panel"..polys..".obj",
|
||||
@ -454,7 +454,7 @@ core.register_node(nodename_panel_empty, {
|
||||
})
|
||||
|
||||
local nodename_panel_loaded = "pipeworks:entry_panel_loaded"
|
||||
core.register_node(nodename_panel_loaded, {
|
||||
minetest.register_node(nodename_panel_loaded, {
|
||||
description = S("Airtight Pipe entry/exit"),
|
||||
drawtype = "mesh",
|
||||
mesh = "pipeworks_entry_panel"..polys..".obj",
|
||||
@ -487,7 +487,7 @@ new_flow_logic_register.directional_horizonal_rotate(nodename_panel_loaded, true
|
||||
|
||||
|
||||
local nodename_sensor_empty = "pipeworks:flow_sensor_empty"
|
||||
core.register_node(nodename_sensor_empty, {
|
||||
minetest.register_node(nodename_sensor_empty, {
|
||||
description = S("Flow Sensor"),
|
||||
drawtype = "mesh",
|
||||
mesh = "pipeworks_flow_sensor"..polys..".obj",
|
||||
@ -530,7 +530,7 @@ core.register_node(nodename_sensor_empty, {
|
||||
})
|
||||
|
||||
local nodename_sensor_loaded = "pipeworks:flow_sensor_loaded"
|
||||
core.register_node(nodename_sensor_loaded, {
|
||||
minetest.register_node(nodename_sensor_loaded, {
|
||||
description = S("Flow sensor (on)"),
|
||||
drawtype = "mesh",
|
||||
mesh = "pipeworks_flow_sensor"..polys..".obj",
|
||||
@ -596,7 +596,7 @@ for fill = 0, 10 do
|
||||
image = "pipeworks_storage_tank_fittings.png"
|
||||
end
|
||||
|
||||
core.register_node("pipeworks:expansion_tank_"..fill, {
|
||||
minetest.register_node("pipeworks:expansion_tank_"..fill, {
|
||||
description = S("Expansion Tank (@1)", filldesc),
|
||||
tiles = {
|
||||
"pipeworks_storage_tank_fittings.png",
|
||||
@ -628,7 +628,7 @@ for fill = 0, 10 do
|
||||
on_rotate = false
|
||||
})
|
||||
|
||||
core.register_node("pipeworks:storage_tank_"..fill, {
|
||||
minetest.register_node("pipeworks:storage_tank_"..fill, {
|
||||
description = S("Fluid Storage Tank (@1)", filldesc),
|
||||
tiles = {
|
||||
"pipeworks_storage_tank_fittings.png",
|
||||
@ -665,7 +665,7 @@ pipeworks.ui_cat_tube_list[#pipeworks.ui_cat_tube_list+1] = "pipeworks:storage_t
|
||||
-- fountainhead
|
||||
|
||||
local nodename_fountain_empty = "pipeworks:fountainhead"
|
||||
core.register_node(nodename_fountain_empty, {
|
||||
minetest.register_node(nodename_fountain_empty, {
|
||||
description = S("Fountainhead"),
|
||||
drawtype = "mesh",
|
||||
mesh = "pipeworks_fountainhead"..polys..".obj",
|
||||
@ -704,7 +704,7 @@ core.register_node(nodename_fountain_empty, {
|
||||
pipeworks.ui_cat_tube_list[#pipeworks.ui_cat_tube_list+1] = "pipeworks:fountainhead"
|
||||
|
||||
local nodename_fountain_loaded = "pipeworks:fountainhead_pouring"
|
||||
core.register_node(nodename_fountain_loaded, {
|
||||
minetest.register_node(nodename_fountain_loaded, {
|
||||
description = S("Fountainhead"),
|
||||
drawtype = "mesh",
|
||||
mesh = "pipeworks_fountainhead"..polys..".obj",
|
||||
@ -720,7 +720,7 @@ core.register_node(nodename_fountain_loaded, {
|
||||
walkable = true,
|
||||
pipe_connections = { bottom = 1 },
|
||||
after_place_node = function(pos)
|
||||
core.set_node(pos, { name = "pipeworks:fountainhead", param2 = core.get_node(pos).param2 })
|
||||
minetest.set_node(pos, { name = "pipeworks:fountainhead", param2 = minetest.get_node(pos).param2 })
|
||||
pipeworks.scan_for_pipe_objects(pos)
|
||||
end,
|
||||
after_dig_node = function(pos)
|
||||
@ -758,7 +758,7 @@ local sp_cbox = {
|
||||
}
|
||||
|
||||
local nodename_sp_empty = "pipeworks:straight_pipe_empty"
|
||||
core.register_node(nodename_sp_empty, {
|
||||
minetest.register_node(nodename_sp_empty, {
|
||||
description = S("Straight-only Pipe"),
|
||||
drawtype = "mesh",
|
||||
mesh = "pipeworks_straight_pipe"..polys..".obj",
|
||||
@ -784,7 +784,7 @@ core.register_node(nodename_sp_empty, {
|
||||
})
|
||||
|
||||
local nodename_sp_loaded = "pipeworks:straight_pipe_loaded"
|
||||
core.register_node(nodename_sp_loaded, {
|
||||
minetest.register_node(nodename_sp_loaded, {
|
||||
description = S("Straight-only Pipe"),
|
||||
drawtype = "mesh",
|
||||
mesh = "pipeworks_straight_pipe"..polys..".obj",
|
||||
@ -816,6 +816,6 @@ new_flow_logic_register.directional_horizonal_rotate(nodename_sp_loaded, true)
|
||||
|
||||
-- Other misc stuff
|
||||
|
||||
core.register_alias("pipeworks:valve_off_loaded", "pipeworks:valve_off_empty")
|
||||
core.register_alias("pipeworks:entry_panel", "pipeworks:entry_panel_empty")
|
||||
minetest.register_alias("pipeworks:valve_off_loaded", "pipeworks:valve_off_empty")
|
||||
minetest.register_alias("pipeworks:entry_panel", "pipeworks:entry_panel_empty")
|
||||
|
||||
|
@ -1,4 +1,4 @@
|
||||
local S = core.get_translator("pipeworks")
|
||||
local S = minetest.get_translator("pipeworks")
|
||||
local fs_helpers = pipeworks.fs_helpers
|
||||
|
||||
local function set_filter_infotext(data, meta)
|
||||
@ -21,7 +21,7 @@ local function set_filter_formspec(data, meta)
|
||||
formspec =
|
||||
("size[8.5,%f]"):format(form_height) ..
|
||||
"item_image[0.2,0;1,1;pipeworks:"..data.name.."]"..
|
||||
"label[1.2,0.2;"..core.formspec_escape(itemname).."]"..
|
||||
"label[1.2,0.2;"..minetest.formspec_escape(itemname).."]"..
|
||||
"field[0.5,1.6;4.6,1;channel;"..S("Channel")..";${channel}]"..
|
||||
"button[4.8,1.3;1.5,1;set_channel;"..S("Set").."]"..
|
||||
fs_helpers.cycling_button(meta, ("button[0.2,%f;4.05,1"):format(form_height - 0.7), "slotseq_mode",
|
||||
@ -47,7 +47,7 @@ local function set_filter_formspec(data, meta)
|
||||
end
|
||||
local size = "10.2,11"
|
||||
local list_backgrounds = ""
|
||||
if core.get_modpath("i3") or core.get_modpath("mcl_formspec") then
|
||||
if minetest.get_modpath("i3") or minetest.get_modpath("mcl_formspec") then
|
||||
list_backgrounds = "style_type[box;colors=#666]"
|
||||
for i=0, 7 do
|
||||
for j=0, 1 do
|
||||
@ -60,7 +60,7 @@ local function set_filter_formspec(data, meta)
|
||||
"size["..size.."]"..
|
||||
pipeworks.fs_helpers.get_prepends(size)..
|
||||
"item_image[0.22,0.22;1,1;pipeworks:"..data.name.."]"..
|
||||
"label[1.22,0.72;"..core.formspec_escape(itemname).."]"..
|
||||
"label[1.22,0.72;"..minetest.formspec_escape(itemname).."]"..
|
||||
"label[0.22,1.5;"..S("Prefer item types:").."]"..
|
||||
list_backgrounds..
|
||||
"list[context;main;0.22,1.75;8,2;]"..
|
||||
@ -81,15 +81,17 @@ local function set_filter_formspec(data, meta)
|
||||
end
|
||||
|
||||
local function punch_filter(data, filtpos, filtnode, msg)
|
||||
local filtmeta = core.get_meta(filtpos)
|
||||
local filtmeta = minetest.get_meta(filtpos)
|
||||
local filtinv = filtmeta:get_inventory()
|
||||
local owner = filtmeta:get_string("owner")
|
||||
local fakeplayer = fakelib.create_player(owner)
|
||||
local fakePlayer = pipeworks.create_fake_player({
|
||||
name = owner
|
||||
})
|
||||
local dir = pipeworks.facedir_to_right_dir(filtnode.param2)
|
||||
local frompos = vector.subtract(filtpos, dir)
|
||||
local fromnode = core.get_node(frompos)
|
||||
local fromnode = minetest.get_node(frompos)
|
||||
if not fromnode then return end
|
||||
local fromdef = core.registered_nodes[fromnode.name]
|
||||
local fromdef = minetest.registered_nodes[fromnode.name]
|
||||
if not fromdef or not fromdef.tube then return end
|
||||
local fromtube = table.copy(fromdef.tube)
|
||||
local input_special_cases = {
|
||||
@ -117,14 +119,15 @@ local function punch_filter(data, filtpos, filtnode, msg)
|
||||
}
|
||||
|
||||
-- make sure there's something appropriate to inject the item into
|
||||
local topos = vector.add(filtpos, dir)
|
||||
local tonode = core.get_node(topos)
|
||||
local todef = core.registered_nodes[tonode.name]
|
||||
local todir = pipeworks.facedir_to_right_dir(filtnode.param2)
|
||||
local topos = vector.add(filtpos, todir)
|
||||
local tonode = minetest.get_node(topos)
|
||||
local todef = minetest.registered_nodes[tonode.name]
|
||||
|
||||
if not todef
|
||||
or not (core.get_item_group(tonode.name, "tube") == 1
|
||||
or core.get_item_group(tonode.name, "tubedevice") == 1
|
||||
or core.get_item_group(tonode.name, "tubedevice_receiver") == 1) then
|
||||
or not (minetest.get_item_group(tonode.name, "tube") == 1
|
||||
or minetest.get_item_group(tonode.name, "tubedevice") == 1
|
||||
or minetest.get_item_group(tonode.name, "tubedevice_receiver") == 1) then
|
||||
return
|
||||
end
|
||||
|
||||
@ -198,12 +201,10 @@ local function punch_filter(data, filtpos, filtnode, msg)
|
||||
set_filter_formspec(data, filtmeta)
|
||||
end
|
||||
|
||||
if pipeworks.enable_item_tags then
|
||||
if type(msg.tags) == "table" or type(msg.tags) == "string" then
|
||||
item_tags = pipeworks.sanitize_tags(msg.tags)
|
||||
elseif type(msg.tag) == "string" then
|
||||
item_tags = pipeworks.sanitize_tags({msg.tag})
|
||||
end
|
||||
if type(msg.tags) == "table" or type(msg.tags) == "string" then
|
||||
item_tags = pipeworks.sanitize_tags(msg.tags)
|
||||
elseif type(msg.tag) == "string" then
|
||||
item_tags = pipeworks.sanitize_tags({msg.tag})
|
||||
end
|
||||
|
||||
if msg.nofire then
|
||||
@ -251,7 +252,7 @@ local function punch_filter(data, filtpos, filtnode, msg)
|
||||
return
|
||||
end
|
||||
else
|
||||
local frommeta = core.get_meta(frompos)
|
||||
local frommeta = minetest.get_meta(frompos)
|
||||
frominv = frommeta:get_inventory()
|
||||
end
|
||||
if fromtube.before_filter then fromtube.before_filter(frompos) end
|
||||
@ -273,7 +274,7 @@ local function punch_filter(data, filtpos, filtnode, msg)
|
||||
|
||||
and (not fgroup -- If there's a group filter,
|
||||
or (type(fgroup) == "string" -- it must be a string
|
||||
and core.get_item_group( -- and it must match.
|
||||
and minetest.get_item_group( -- and it must match.
|
||||
stack:get_name(), fgroup) ~= 0))
|
||||
|
||||
and (not fwear -- If there's a wear filter:
|
||||
@ -313,15 +314,13 @@ local function punch_filter(data, filtpos, filtnode, msg)
|
||||
return a < b
|
||||
end)
|
||||
end
|
||||
local available_items = {}
|
||||
local available_count = 0
|
||||
for _, spos in ipairs(sposes) do
|
||||
local stack = frominv:get_stack(frominvname, spos)
|
||||
local doRemove = stack:get_count()
|
||||
if fromtube.can_remove then
|
||||
doRemove = fromtube.can_remove(frompos, fromnode, stack, dir, frominvname, spos)
|
||||
elseif fromdef.allow_metadata_inventory_take then
|
||||
doRemove = fromdef.allow_metadata_inventory_take(frompos, frominvname, spos, stack, fakeplayer)
|
||||
doRemove = fromdef.allow_metadata_inventory_take(frompos, frominvname,spos, stack, fakePlayer)
|
||||
end
|
||||
-- stupid lack of continue statements grumble
|
||||
if doRemove > 0 then
|
||||
@ -333,63 +332,39 @@ local function punch_filter(data, filtpos, filtnode, msg)
|
||||
filtmeta:set_int("slotseq_index", nextpos)
|
||||
set_filter_infotext(data, filtmeta)
|
||||
end
|
||||
local item
|
||||
local count
|
||||
if data.stackwise then
|
||||
count = math.min(stack:get_count(), doRemove)
|
||||
if filterfor.count and (filterfor.count > 1 or data.digiline) then
|
||||
count = math.min(filterfor.count - available_count, count)
|
||||
end
|
||||
table.insert(available_items, {spos = spos, count = count})
|
||||
available_count = available_count + count
|
||||
if not filterfor.count or available_count >= filterfor.count then
|
||||
break
|
||||
if exmatch_mode ~= 0 and filterfor.count > count then
|
||||
return false -- not enough, fail
|
||||
else
|
||||
-- limit quantity to filter amount
|
||||
count = math.min(filterfor.count, count)
|
||||
end
|
||||
end
|
||||
else
|
||||
table.insert(available_items, {spos = spos, count = 1})
|
||||
available_count = 1
|
||||
break -- only one item allowed so ignore other stacks
|
||||
count = 1
|
||||
end
|
||||
if fromtube.remove_items then
|
||||
-- it could be the entire stack...
|
||||
item = fromtube.remove_items(frompos, fromnode, stack, dir, count, frominvname, spos)
|
||||
else
|
||||
item = stack:take_item(count)
|
||||
frominv:set_stack(frominvname, spos, stack)
|
||||
if fromdef.on_metadata_inventory_take then
|
||||
fromdef.on_metadata_inventory_take(frompos, frominvname, spos, item, fakePlayer)
|
||||
end
|
||||
end
|
||||
local pos = vector.add(frompos, vector.multiply(dir, 1.4))
|
||||
local start_pos = vector.add(frompos, dir)
|
||||
pipeworks.tube_inject_item(pos, start_pos, dir, item,
|
||||
fakePlayer:get_player_name(), item_tags)
|
||||
return true -- only fire one item, please
|
||||
end
|
||||
end
|
||||
if available_count == 0 or (exmatch_mode ~= 0 and filterfor.count and available_count < filterfor.count) then
|
||||
return false -- not enough, fail
|
||||
end
|
||||
local taken_stacks = {}
|
||||
for _,item in ipairs(available_items) do
|
||||
local stack = frominv:get_stack(frominvname, item.spos)
|
||||
local taken
|
||||
if fromtube.remove_items then
|
||||
taken = fromtube.remove_items(frompos, fromnode, stack, dir, item.count, frominvname, item.spos)
|
||||
else
|
||||
taken = stack:take_item(item.count)
|
||||
frominv:set_stack(frominvname, item.spos, stack)
|
||||
if fromdef.on_metadata_inventory_take then
|
||||
fromdef.on_metadata_inventory_take(frompos, frominvname, item.spos, taken, fakeplayer)
|
||||
end
|
||||
end
|
||||
if not taken:is_empty() then
|
||||
table.insert(taken_stacks, taken)
|
||||
end
|
||||
end
|
||||
if #taken_stacks > 1 then
|
||||
-- merge stacks if possible to reduce items in tubes
|
||||
local merged = {}
|
||||
for _,a in ipairs(taken_stacks) do
|
||||
for _,b in ipairs(merged) do
|
||||
a = b:add_item(a)
|
||||
end
|
||||
if not a:is_empty() then
|
||||
table.insert(merged, a)
|
||||
end
|
||||
end
|
||||
taken_stacks = merged
|
||||
end
|
||||
for _,stack in ipairs(taken_stacks) do
|
||||
local pos = vector.add(frompos, vector.multiply(dir, 1.4))
|
||||
local start_pos = vector.add(frompos, dir)
|
||||
pipeworks.tube_inject_item(pos, start_pos, dir, stack, fakeplayer:get_player_name(), item_tags)
|
||||
end
|
||||
return true
|
||||
return false
|
||||
end
|
||||
|
||||
for _, frominvname in ipairs(type(fromtube.input_inventory) == "table" and fromtube.input_inventory or {fromtube.input_inventory}) do
|
||||
@ -442,14 +417,14 @@ for _, data in ipairs({
|
||||
key = "node_sound_wood_defaults",
|
||||
},
|
||||
on_construct = function(pos)
|
||||
local meta = core.get_meta(pos)
|
||||
local meta = minetest.get_meta(pos)
|
||||
set_filter_formspec(data, meta)
|
||||
set_filter_infotext(data, meta)
|
||||
local inv = meta:get_inventory()
|
||||
inv:set_size("main", 8*2)
|
||||
end,
|
||||
after_place_node = function (pos, placer)
|
||||
core.get_meta(pos):set_string("owner", placer:get_player_name())
|
||||
minetest.get_meta(pos):set_string("owner", placer:get_player_name())
|
||||
pipeworks.after_place(pos)
|
||||
end,
|
||||
after_dig_node = pipeworks.after_dig,
|
||||
@ -458,7 +433,7 @@ for _, data in ipairs({
|
||||
if not pipeworks.may_configure(pos, player) then
|
||||
return 0
|
||||
end
|
||||
local inv = core.get_meta(pos):get_inventory()
|
||||
local inv = minetest.get_meta(pos):get_inventory()
|
||||
inv:set_stack("main", index, stack)
|
||||
return 0
|
||||
end,
|
||||
@ -466,7 +441,7 @@ for _, data in ipairs({
|
||||
if not pipeworks.may_configure(pos, player) then
|
||||
return 0
|
||||
end
|
||||
local inv = core.get_meta(pos):get_inventory()
|
||||
local inv = minetest.get_meta(pos):get_inventory()
|
||||
local fake_stack = inv:get_stack("main", index)
|
||||
fake_stack:take_item(stack:get_count())
|
||||
inv:set_stack("main", index, fake_stack)
|
||||
@ -476,12 +451,17 @@ for _, data in ipairs({
|
||||
if not pipeworks.may_configure(pos, player) then return 0 end
|
||||
return count
|
||||
end,
|
||||
can_dig = function(pos, player)
|
||||
local meta = minetest.get_meta(pos)
|
||||
local inv = meta:get_inventory()
|
||||
return inv:is_empty("main")
|
||||
end,
|
||||
tube = {connect_sides = {right = 1}},
|
||||
}
|
||||
|
||||
if data.digiline then
|
||||
node.groups.mesecon = nil
|
||||
if not core.get_modpath("digilines") then
|
||||
if not minetest.get_modpath("digilines") then
|
||||
node.groups.not_in_creative_inventory = 1
|
||||
end
|
||||
|
||||
@ -494,10 +474,10 @@ for _, data in ipairs({
|
||||
fs_helpers.on_receive_fields(pos, fields)
|
||||
|
||||
if fields.channel and (fields.key_enter_field == "channel" or fields.set_channel) then
|
||||
core.get_meta(pos):set_string("channel", fields.channel)
|
||||
minetest.get_meta(pos):set_string("channel", fields.channel)
|
||||
end
|
||||
|
||||
local meta = core.get_meta(pos)
|
||||
local meta = minetest.get_meta(pos)
|
||||
if pipeworks.enable_item_tags and fields.item_tags and (fields.key_enter_field == "item_tags" or fields.set_item_tags) then
|
||||
local tags = pipeworks.sanitize_tags(fields.item_tags)
|
||||
meta:set_string("item_tags", table.concat(tags, ","))
|
||||
@ -506,10 +486,10 @@ for _, data in ipairs({
|
||||
set_filter_formspec(data, meta)
|
||||
set_filter_infotext(data, meta)
|
||||
end
|
||||
node.digilines = {
|
||||
node.digiline = {
|
||||
effector = {
|
||||
action = function(pos, node, channel, msg)
|
||||
local meta = core.get_meta(pos)
|
||||
local meta = minetest.get_meta(pos)
|
||||
local setchan = meta:get_string("channel")
|
||||
if setchan ~= channel then return end
|
||||
|
||||
@ -521,7 +501,7 @@ for _, data in ipairs({
|
||||
node.on_receive_fields = function(pos, formname, fields, sender)
|
||||
if not pipeworks.may_configure(pos, sender) then return end
|
||||
fs_helpers.on_receive_fields(pos, fields)
|
||||
local meta = core.get_meta(pos)
|
||||
local meta = minetest.get_meta(pos)
|
||||
meta:set_int("slotseq_index", 1)
|
||||
if pipeworks.enable_item_tags and fields.item_tags and (fields.key_enter_field == "item_tags" or fields.set_item_tags) then
|
||||
local tags = pipeworks.sanitize_tags(fields.item_tags)
|
||||
@ -544,7 +524,7 @@ for _, data in ipairs({
|
||||
|
||||
|
||||
|
||||
core.register_node("pipeworks:"..data.name, node)
|
||||
minetest.register_node("pipeworks:"..data.name, node)
|
||||
pipeworks.ui_cat_tube_list[#pipeworks.ui_cat_tube_list+1] = "pipeworks:"..data.name
|
||||
end
|
||||
|
||||
@ -556,8 +536,8 @@ dropped.
|
||||
local function put_to_inputinv(pos, node, filtmeta, list)
|
||||
local dir = pipeworks.facedir_to_right_dir(node.param2)
|
||||
local frompos = vector.subtract(pos, dir)
|
||||
local fromnode = core.get_node(frompos)
|
||||
local fromdef = core.registered_nodes[fromnode.name]
|
||||
local fromnode = minetest.get_node(frompos)
|
||||
local fromdef = minetest.registered_nodes[fromnode.name]
|
||||
if not fromdef or not fromdef.tube then
|
||||
return
|
||||
end
|
||||
@ -570,7 +550,7 @@ local function put_to_inputinv(pos, node, filtmeta, list)
|
||||
return
|
||||
end
|
||||
else
|
||||
frominv = core.get_meta(frompos):get_inventory()
|
||||
frominv = minetest.get_meta(frompos):get_inventory()
|
||||
end
|
||||
local listname = type(fromtube.input_inventory) == "table" and
|
||||
fromtube.input_inventory[1] or fromtube.input_inventory
|
||||
@ -582,19 +562,19 @@ local function put_to_inputinv(pos, node, filtmeta, list)
|
||||
if not item:is_empty() then
|
||||
local leftover = frominv:add_item(listname, item)
|
||||
if not leftover:is_empty() then
|
||||
core.add_item(pos, leftover)
|
||||
minetest.add_item(pos, leftover)
|
||||
end
|
||||
end
|
||||
end
|
||||
return true
|
||||
end
|
||||
core.register_lbm({
|
||||
minetest.register_lbm({
|
||||
label = "Give back items of old filters that had real inventories",
|
||||
name = "pipeworks:give_back_old_filter_items",
|
||||
nodenames = {"pipeworks:filter", "pipeworks:mese_filter"},
|
||||
run_at_every_load = false,
|
||||
action = function(pos, node)
|
||||
local meta = core.get_meta(pos)
|
||||
local meta = minetest.get_meta(pos)
|
||||
local list = meta:get_inventory():get_list("main")
|
||||
if put_to_inputinv(pos, node, meta, list) then
|
||||
return
|
||||
@ -603,7 +583,7 @@ core.register_lbm({
|
||||
for i = 1, #list do
|
||||
local item = list[i]
|
||||
if not item:is_empty() then
|
||||
core.add_item(pos, item)
|
||||
minetest.add_item(pos, item)
|
||||
end
|
||||
end
|
||||
end,
|
||||
|
@ -4,7 +4,7 @@
|
||||
-- Contributed by mauvebic, 2013-01-03, rewritten a bit by Vanessa Ezekowitz
|
||||
--
|
||||
|
||||
local finitewater = core.settings:get_bool("liquid_finite")
|
||||
local finitewater = minetest.settings:get_bool("liquid_finite")
|
||||
|
||||
pipeworks.check_for_liquids = function(pos)
|
||||
local coords = {
|
||||
@ -15,9 +15,9 @@ pipeworks.check_for_liquids = function(pos)
|
||||
{x=pos.x,y=pos.y,z=pos.z-1},
|
||||
{x=pos.x,y=pos.y,z=pos.z+1}, }
|
||||
for i =1,6 do
|
||||
local name = core.get_node(coords[i]).name
|
||||
local name = minetest.get_node(coords[i]).name
|
||||
if name and string.find(name,"water") then
|
||||
if finitewater then core.remove_node(coords[i]) end
|
||||
if finitewater then minetest.remove_node(coords[i]) end
|
||||
return true
|
||||
end
|
||||
end
|
||||
@ -37,19 +37,19 @@ pipeworks.check_for_inflows = function(pos,node)
|
||||
local source = false
|
||||
for i = 1, 6 do
|
||||
if newnode then break end
|
||||
local testnode = core.get_node(coords[i])
|
||||
local testnode = minetest.get_node(coords[i])
|
||||
local name = testnode.name
|
||||
if name and (name == "pipeworks:pump_on" and pipeworks.check_for_liquids(coords[i])) or string.find(name,"_loaded") then
|
||||
if string.find(name,"_loaded") then
|
||||
source = core.get_meta(coords[i]):get_string("source")
|
||||
if source == core.pos_to_string(pos) then break end
|
||||
source = minetest.get_meta(coords[i]):get_string("source")
|
||||
if source == minetest.pos_to_string(pos) then break end
|
||||
end
|
||||
if string.find(name, "valve") or string.find(name, "sensor")
|
||||
or string.find(name, "straight_pipe") or string.find(name, "panel") then
|
||||
|
||||
if ((i == 3 or i == 4) and core.facedir_to_dir(testnode.param2).x ~= 0)
|
||||
or ((i == 5 or i == 6) and core.facedir_to_dir(testnode.param2).z ~= 0)
|
||||
or ((i == 1 or i == 2) and core.facedir_to_dir(testnode.param2).y ~= 0) then
|
||||
if ((i == 3 or i == 4) and minetest.facedir_to_dir(testnode.param2).x ~= 0)
|
||||
or ((i == 5 or i == 6) and minetest.facedir_to_dir(testnode.param2).z ~= 0)
|
||||
or ((i == 1 or i == 2) and minetest.facedir_to_dir(testnode.param2).y ~= 0) then
|
||||
|
||||
newnode = string.gsub(node.name,"empty","loaded")
|
||||
source = {x=coords[i].x,y=coords[i].y,z=coords[i].z}
|
||||
@ -61,30 +61,30 @@ pipeworks.check_for_inflows = function(pos,node)
|
||||
end
|
||||
end
|
||||
if newnode then
|
||||
core.add_node(pos,{name=newnode, param2 = node.param2})
|
||||
core.get_meta(pos):set_string("source",core.pos_to_string(source))
|
||||
minetest.add_node(pos,{name=newnode, param2 = node.param2})
|
||||
minetest.get_meta(pos):set_string("source",minetest.pos_to_string(source))
|
||||
end
|
||||
end
|
||||
|
||||
pipeworks.check_sources = function(pos,node)
|
||||
local sourcepos = core.string_to_pos(core.get_meta(pos):get_string("source"))
|
||||
local sourcepos = minetest.string_to_pos(minetest.get_meta(pos):get_string("source"))
|
||||
if not sourcepos then return end
|
||||
local source = core.get_node(sourcepos).name
|
||||
local source = minetest.get_node(sourcepos).name
|
||||
local newnode = false
|
||||
if source and not ((source == "pipeworks:pump_on" and pipeworks.check_for_liquids(sourcepos)) or string.find(source,"_loaded") or source == "ignore" ) then
|
||||
newnode = string.gsub(node.name,"loaded","empty")
|
||||
end
|
||||
|
||||
if newnode then
|
||||
core.add_node(pos,{name=newnode, param2 = node.param2})
|
||||
core.get_meta(pos):set_string("source","")
|
||||
minetest.add_node(pos,{name=newnode, param2 = node.param2})
|
||||
minetest.get_meta(pos):set_string("source","")
|
||||
end
|
||||
end
|
||||
|
||||
pipeworks.spigot_check = function(pos, node)
|
||||
local belowname = core.get_node({x=pos.x,y=pos.y-1,z=pos.z}).name
|
||||
local belowname = minetest.get_node({x=pos.x,y=pos.y-1,z=pos.z}).name
|
||||
if belowname and (belowname == "air" or belowname == pipeworks.liquids.water.flowing or belowname == pipeworks.liquids.water.source) then
|
||||
local spigotname = core.get_node(pos).name
|
||||
local spigotname = minetest.get_node(pos).name
|
||||
local fdir=node.param2 % 4
|
||||
local check = {
|
||||
{x=pos.x,y=pos.y,z=pos.z+1},
|
||||
@ -92,19 +92,19 @@ pipeworks.spigot_check = function(pos, node)
|
||||
{x=pos.x,y=pos.y,z=pos.z-1},
|
||||
{x=pos.x-1,y=pos.y,z=pos.z}
|
||||
}
|
||||
local near_node = core.get_node(check[fdir+1])
|
||||
local near_node = minetest.get_node(check[fdir+1])
|
||||
if near_node and string.find(near_node.name, "_loaded") then
|
||||
if spigotname and spigotname == "pipeworks:spigot" then
|
||||
core.add_node(pos,{name = "pipeworks:spigot_pouring", param2 = fdir})
|
||||
minetest.add_node(pos,{name = "pipeworks:spigot_pouring", param2 = fdir})
|
||||
if finitewater or belowname ~= pipeworks.liquids.water.source then
|
||||
core.add_node({x=pos.x,y=pos.y-1,z=pos.z},{name = pipeworks.liquids.water.source})
|
||||
minetest.add_node({x=pos.x,y=pos.y-1,z=pos.z},{name = pipeworks.liquids.water.source})
|
||||
end
|
||||
end
|
||||
else
|
||||
if spigotname == "pipeworks:spigot_pouring" then
|
||||
core.add_node({x=pos.x,y=pos.y,z=pos.z},{name = "pipeworks:spigot", param2 = fdir})
|
||||
minetest.add_node({x=pos.x,y=pos.y,z=pos.z},{name = "pipeworks:spigot", param2 = fdir})
|
||||
if belowname == pipeworks.liquids.water.source and not finitewater then
|
||||
core.remove_node({x=pos.x,y=pos.y-1,z=pos.z})
|
||||
minetest.remove_node({x=pos.x,y=pos.y-1,z=pos.z})
|
||||
end
|
||||
end
|
||||
end
|
||||
@ -112,22 +112,22 @@ pipeworks.spigot_check = function(pos, node)
|
||||
end
|
||||
|
||||
pipeworks.fountainhead_check = function(pos, node)
|
||||
local abovename = core.get_node({x=pos.x,y=pos.y+1,z=pos.z}).name
|
||||
local abovename = minetest.get_node({x=pos.x,y=pos.y+1,z=pos.z}).name
|
||||
if abovename and (abovename == "air" or abovename == pipeworks.liquids.water.flowing or abovename == pipeworks.liquids.water.source) then
|
||||
local fountainhead_name = core.get_node(pos).name
|
||||
local near_node = core.get_node({x=pos.x,y=pos.y-1,z=pos.z})
|
||||
local fountainhead_name = minetest.get_node(pos).name
|
||||
local near_node = minetest.get_node({x=pos.x,y=pos.y-1,z=pos.z})
|
||||
if near_node and string.find(near_node.name, "_loaded") then
|
||||
if fountainhead_name and fountainhead_name == "pipeworks:fountainhead" then
|
||||
core.add_node(pos,{name = "pipeworks:fountainhead_pouring"})
|
||||
minetest.add_node(pos,{name = "pipeworks:fountainhead_pouring"})
|
||||
if finitewater or abovename ~= pipeworks.liquids.water.source then
|
||||
core.add_node({x=pos.x,y=pos.y+1,z=pos.z},{name = pipeworks.liquids.water.source})
|
||||
minetest.add_node({x=pos.x,y=pos.y+1,z=pos.z},{name = pipeworks.liquids.water.source})
|
||||
end
|
||||
end
|
||||
else
|
||||
if fountainhead_name == "pipeworks:fountainhead_pouring" then
|
||||
core.add_node({x=pos.x,y=pos.y,z=pos.z},{name = "pipeworks:fountainhead"})
|
||||
minetest.add_node({x=pos.x,y=pos.y,z=pos.z},{name = "pipeworks:fountainhead"})
|
||||
if abovename == pipeworks.liquids.water.source and not finitewater then
|
||||
core.remove_node({x=pos.x,y=pos.y+1,z=pos.z})
|
||||
minetest.remove_node({x=pos.x,y=pos.y+1,z=pos.z})
|
||||
end
|
||||
end
|
||||
end
|
||||
|
46
init.lua
46
init.lua
@ -6,16 +6,16 @@
|
||||
|
||||
pipeworks = {
|
||||
ui_cat_tube_list = {},
|
||||
worldpath = core.get_worldpath(),
|
||||
modpath = core.get_modpath("pipeworks"),
|
||||
worldpath = minetest.get_worldpath(),
|
||||
modpath = minetest.get_modpath("pipeworks"),
|
||||
liquids = {
|
||||
water = {
|
||||
source = core.registered_nodes["mapgen_water_source"].name,
|
||||
flowing = core.registered_nodes["mapgen_water_source"].liquid_alternative_flowing
|
||||
source = minetest.registered_nodes["mapgen_water_source"].name,
|
||||
flowing = minetest.registered_nodes["mapgen_water_source"].liquid_alternative_flowing
|
||||
},
|
||||
river_water = {
|
||||
source = core.registered_nodes["mapgen_river_water_source"].name,
|
||||
flowing = core.registered_nodes["mapgen_river_water_source"].liquid_alternative_flowing
|
||||
source = minetest.registered_nodes["mapgen_river_water_source"].name,
|
||||
flowing = minetest.registered_nodes["mapgen_river_water_source"].liquid_alternative_flowing
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -29,14 +29,14 @@ if worldsettingsfile then
|
||||
dofile(worldsettingspath)
|
||||
end
|
||||
if pipeworks.toggles.pipe_mode == "pressure" then
|
||||
core.log("warning", "pipeworks pressure logic mode comes with caveats and differences in behaviour, you have been warned!")
|
||||
minetest.log("warning", "pipeworks pressure logic mode comes with caveats and differences in behaviour, you have been warned!")
|
||||
end
|
||||
if pipeworks.entity_update_interval >= 0.2 and pipeworks.enable_accelerator_tube then
|
||||
core.log("warning", "pipeworks accelerator tubes will not entirely work with an entity update interval 0.2 or above.")
|
||||
minetest.log("warning", "pipeworks accelerator tubes will not entirely work with an entity update interval 0.2 or above.")
|
||||
end
|
||||
|
||||
pipeworks.logger = function(msg)
|
||||
core.log("action", "[pipeworks] "..msg)
|
||||
minetest.log("action", "[pipeworks] "..msg)
|
||||
end
|
||||
|
||||
-------------------------------------------
|
||||
@ -47,7 +47,7 @@ if pipeworks.toggles.finite_water == nil then
|
||||
dofile(pipeworks.modpath.."/autodetect-finite-water.lua")
|
||||
end
|
||||
|
||||
if core.get_modpath("signs_lib") then
|
||||
if minetest.get_modpath("signs_lib") then
|
||||
dofile(pipeworks.modpath.."/signs_compat.lua")
|
||||
end
|
||||
|
||||
@ -59,7 +59,6 @@ dofile(pipeworks.modpath.."/luaentity.lua")
|
||||
dofile(pipeworks.modpath.."/item_transport.lua")
|
||||
dofile(pipeworks.modpath.."/flowing_logic.lua")
|
||||
dofile(pipeworks.modpath.."/filter-injector.lua")
|
||||
dofile(pipeworks.modpath.."/chests.lua")
|
||||
dofile(pipeworks.modpath.."/trashcan.lua")
|
||||
dofile(pipeworks.modpath.."/wielder.lua")
|
||||
dofile(pipeworks.modpath.."/tubes/registration.lua")
|
||||
@ -73,7 +72,7 @@ dofile(pipeworks.modpath.."/tubes/tags.lua")
|
||||
if pipeworks.enable_teleport_tube then
|
||||
dofile(pipeworks.modpath.."/tubes/teleport.lua")
|
||||
end
|
||||
if pipeworks.enable_lua_tube and core.get_modpath("mesecons") then
|
||||
if pipeworks.enable_lua_tube and minetest.get_modpath("mesecons") then
|
||||
dofile(pipeworks.modpath.."/tubes/lua.lua")
|
||||
end
|
||||
if pipeworks.enable_sand_tube or pipeworks.enable_mese_sand_tube then
|
||||
@ -96,13 +95,14 @@ end
|
||||
if pipeworks.enable_pipe_devices then
|
||||
dofile(pipeworks.modpath.."/devices.lua")
|
||||
end
|
||||
if pipeworks.enable_redefines then
|
||||
if pipeworks.enable_redefines and (minetest.get_modpath("default") or minetest.get_modpath("hades_core")) then
|
||||
dofile(pipeworks.modpath.."/compat-chests.lua")
|
||||
end
|
||||
if pipeworks.enable_redefines and (core.get_modpath("default") or core.get_modpath("hades_core")) then
|
||||
dofile(pipeworks.modpath.."/compat-furnaces.lua")
|
||||
end
|
||||
if pipeworks.enable_redefines and core.get_modpath("mcl_furnaces") then
|
||||
if pipeworks.enable_redefines and minetest.get_modpath("mcl_barrels") then
|
||||
dofile(pipeworks.modpath.."/mcl_barrels.lua")
|
||||
end
|
||||
if pipeworks.enable_redefines and minetest.get_modpath("mcl_furnaces") then
|
||||
dofile(pipeworks.modpath.."/mcl_furnaces.lua")
|
||||
end
|
||||
if pipeworks.enable_autocrafter then
|
||||
@ -111,24 +111,18 @@ end
|
||||
|
||||
dofile(pipeworks.modpath.."/crafts.lua")
|
||||
|
||||
core.register_alias("pipeworks:pipe", "pipeworks:pipe_110000_empty")
|
||||
minetest.register_alias("pipeworks:pipe", "pipeworks:pipe_110000_empty")
|
||||
|
||||
-- Unified Inventory categories integration
|
||||
|
||||
if core.get_modpath("unified_inventory") and unified_inventory.registered_categories then
|
||||
if minetest.get_modpath("unified_inventory") and unified_inventory.registered_categories then
|
||||
if not unified_inventory.registered_categories["automation"] then
|
||||
local symbol
|
||||
if pipeworks.enable_lua_tube then
|
||||
symbol = "pipeworks:lua_tube000000"
|
||||
else
|
||||
symbol = "pipeworks:mese_filter" -- fallback when lua tube isn't registered
|
||||
end
|
||||
unified_inventory.register_category("automation", {
|
||||
symbol = symbol,
|
||||
symbol = "pipeworks:lua_tube000000",
|
||||
label = "Automation components"
|
||||
})
|
||||
end
|
||||
unified_inventory.add_category_items("automation", pipeworks.ui_cat_tube_list)
|
||||
end
|
||||
|
||||
core.log("info", "Pipeworks loaded!")
|
||||
minetest.log("info", "Pipeworks loaded!")
|
||||
|
@ -1,11 +1,11 @@
|
||||
local luaentity = pipeworks.luaentity
|
||||
local enable_max_limit = core.settings:get_bool("pipeworks_enable_items_per_tube_limit")
|
||||
local max_tube_limit = tonumber(core.settings:get("pipeworks_max_items_per_tube")) or 30
|
||||
local enable_max_limit = minetest.settings:get_bool("pipeworks_enable_items_per_tube_limit")
|
||||
local max_tube_limit = tonumber(minetest.settings:get("pipeworks_max_items_per_tube")) or 30
|
||||
if enable_max_limit == nil then enable_max_limit = true end
|
||||
|
||||
if pipeworks.enable_item_tags then
|
||||
local max_tag_length = tonumber(core.settings:get("pipeworks_max_item_tag_length")) or 32
|
||||
local max_tags = tonumber(core.settings:get("pipeworks_max_item_tags")) or 16
|
||||
local max_tag_length = tonumber(minetest.settings:get("pipeworks_max_item_tag_length")) or 32
|
||||
local max_tags = tonumber(minetest.settings:get("pipeworks_max_item_tags")) or 16
|
||||
|
||||
function pipeworks.sanitize_tags(tags)
|
||||
if type(tags) == "string" then
|
||||
@ -35,25 +35,14 @@ end
|
||||
function pipeworks.tube_inject_item(pos, start_pos, velocity, item, owner, tags)
|
||||
-- Take item in any format
|
||||
local stack = ItemStack(item)
|
||||
local to_pos = vector.add(pos, velocity)
|
||||
local def = core.registered_nodes[core.get_node(to_pos).name]
|
||||
if not def or not def.groups or not (def.groups.tube
|
||||
or def.groups.tubedevice or def.groups.tubedevice_receiver) then
|
||||
local dropped_item = core.add_item(pos, stack)
|
||||
if dropped_item then
|
||||
dropped_item:set_velocity(vector.multiply(velocity, 5))
|
||||
end
|
||||
return
|
||||
end
|
||||
local obj = luaentity.add_entity(pos, "pipeworks:tubed_item")
|
||||
if obj then
|
||||
obj:set_item(stack:to_string())
|
||||
obj.start_pos = vector.new(start_pos)
|
||||
obj:set_velocity(velocity)
|
||||
obj.owner = owner
|
||||
obj.tags = tags
|
||||
return obj
|
||||
end
|
||||
obj:set_item(stack:to_string())
|
||||
obj.start_pos = vector.new(start_pos)
|
||||
obj:set_velocity(velocity)
|
||||
obj.owner = owner
|
||||
obj.tags = tags
|
||||
--obj:set_color("red") -- todo: this is test-only code
|
||||
return obj
|
||||
end
|
||||
|
||||
-- adding two tube functions
|
||||
@ -74,14 +63,14 @@ end
|
||||
|
||||
local tube_item_count = {}
|
||||
|
||||
core.register_globalstep(function(dtime)
|
||||
minetest.register_globalstep(function(dtime)
|
||||
if not luaentity.entities then
|
||||
return
|
||||
end
|
||||
tube_item_count = {}
|
||||
for _, entity in pairs(luaentity.entities) do
|
||||
if entity.name == "pipeworks:tubed_item" then
|
||||
local h = core.hash_node_position(vector.round(entity._pos))
|
||||
local h = minetest.hash_node_position(vector.round(entity._pos))
|
||||
tube_item_count[h] = (tube_item_count[h] or 0) + 1
|
||||
end
|
||||
end
|
||||
@ -94,20 +83,19 @@ end)
|
||||
-- exceeds the limit configured per tube, replace it with a broken one.
|
||||
|
||||
function pipeworks.break_tube(pos)
|
||||
local node = core.get_node(pos)
|
||||
if core.get_item_group(node.name, "tube") ~= 1 then return end
|
||||
local meta = core.get_meta(pos)
|
||||
meta:set_string("the_tube_was", core.serialize(node))
|
||||
core.swap_node(pos, {name = "pipeworks:broken_tube_1"})
|
||||
local node = minetest.get_node(pos)
|
||||
local meta = minetest.get_meta(pos)
|
||||
meta:set_string("the_tube_was", minetest.serialize(node))
|
||||
minetest.swap_node(pos, {name = "pipeworks:broken_tube_1"})
|
||||
pipeworks.scan_for_tube_objects(pos)
|
||||
end
|
||||
|
||||
local crunch_tube = function(pos, cnode, cmeta)
|
||||
if enable_max_limit then
|
||||
local h = core.hash_node_position(pos)
|
||||
local h = minetest.hash_node_position(pos)
|
||||
local itemcount = tube_item_count[h] or 0
|
||||
if itemcount > max_tube_limit then
|
||||
pipeworks.logger("Warning - a tube at "..core.pos_to_string(pos).." broke due to too many items ("..itemcount..")")
|
||||
pipeworks.logger("Warning - a tube at "..minetest.pos_to_string(pos).." broke due to too many items ("..itemcount..")")
|
||||
pipeworks.break_tube(pos)
|
||||
end
|
||||
end
|
||||
@ -122,12 +110,12 @@ local function go_next_compat(pos, cnode, cmeta, cycledir, vel, stack, owner, ta
|
||||
local max_priority = 0
|
||||
local can_go
|
||||
|
||||
local def = core.registered_nodes[cnode.name]
|
||||
local def = minetest.registered_nodes[cnode.name]
|
||||
if def and def.tube and def.tube.can_go then
|
||||
can_go = def.tube.can_go(pos, cnode, vel, stack, tags)
|
||||
else
|
||||
local adjlist_string = core.get_meta(pos):get_string("adjlist")
|
||||
local adjlist = core.deserialize(adjlist_string) or default_adjlist -- backward compat: if not found, use old behavior: all directions
|
||||
local adjlist_string = minetest.get_meta(pos):get_string("adjlist")
|
||||
local adjlist = minetest.deserialize(adjlist_string) or default_adjlist -- backward compat: if not found, use old behavior: all directions
|
||||
|
||||
can_go = pipeworks.notvel(adjlist, vel)
|
||||
end
|
||||
@ -140,11 +128,11 @@ local function go_next_compat(pos, cnode, cmeta, cycledir, vel, stack, owner, ta
|
||||
for _, vect in ipairs(can_go) do
|
||||
local npos = vector.add(pos, vect)
|
||||
pipeworks.load_position(npos)
|
||||
local node = core.get_node(npos)
|
||||
local reg_node = core.registered_nodes[node.name]
|
||||
local node = minetest.get_node(npos)
|
||||
local reg_node = minetest.registered_nodes[node.name]
|
||||
if reg_node then
|
||||
local tube_def = reg_node.tube
|
||||
local tubedevice = core.get_item_group(node.name, "tubedevice")
|
||||
local tubedevice = minetest.get_item_group(node.name, "tubedevice")
|
||||
local tube_priority = (tube_def and tube_def.priority) or 100
|
||||
if tubedevice > 0 and tube_priority >= max_priority then
|
||||
if not tube_def or not tube_def.can_insert or
|
||||
@ -184,8 +172,8 @@ end
|
||||
-- if this is not nil, the luaentity spawns new tubed items for each new fragment stack,
|
||||
-- then deletes itself (i.e. the original item stack).
|
||||
local function go_next(pos, velocity, stack, owner, tags)
|
||||
local cnode = core.get_node(pos)
|
||||
local cmeta = core.get_meta(pos)
|
||||
local cnode = minetest.get_node(pos)
|
||||
local cmeta = minetest.get_meta(pos)
|
||||
local speed = math.abs(velocity.x + velocity.y + velocity.z)
|
||||
if speed == 0 then
|
||||
speed = 1
|
||||
@ -223,7 +211,7 @@ end
|
||||
|
||||
|
||||
|
||||
core.register_entity("pipeworks:tubed_item", {
|
||||
minetest.register_entity("pipeworks:tubed_item", {
|
||||
initial_properties = {
|
||||
hp_max = 1,
|
||||
physical = false,
|
||||
@ -248,9 +236,9 @@ core.register_entity("pipeworks:tubed_item", {
|
||||
end
|
||||
local item_texture = nil
|
||||
local item_type = ""
|
||||
if core.registered_items[itemname] then
|
||||
item_texture = core.registered_items[itemname].inventory_image
|
||||
item_type = core.registered_items[itemname].type
|
||||
if minetest.registered_items[itemname] then
|
||||
item_texture = minetest.registered_items[itemname].inventory_image
|
||||
item_type = minetest.registered_items[itemname].type
|
||||
end
|
||||
--]]
|
||||
self.object:set_properties({
|
||||
@ -270,13 +258,13 @@ core.register_entity("pipeworks:tubed_item", {
|
||||
self.object:remove()
|
||||
return
|
||||
end
|
||||
local item = core.deserialize(staticdata)
|
||||
local item = minetest.deserialize(staticdata)
|
||||
pipeworks.tube_inject_item(self.object:get_pos(), item.start_pos, item.velocity, item.itemstring)
|
||||
self.object:remove()
|
||||
end,
|
||||
})
|
||||
|
||||
core.register_entity("pipeworks:color_entity", {
|
||||
minetest.register_entity("pipeworks:color_entity", {
|
||||
initial_properties = {
|
||||
hp_max = 1,
|
||||
physical = false,
|
||||
@ -374,10 +362,10 @@ luaentity.register_entity("pipeworks:tubed_item", {
|
||||
local stack = ItemStack(self.itemstring)
|
||||
|
||||
pipeworks.load_position(self.start_pos)
|
||||
local node = core.get_node(self.start_pos)
|
||||
if core.get_item_group(node.name, "tubedevice_receiver") == 1 then
|
||||
local node = minetest.get_node(self.start_pos)
|
||||
if minetest.get_item_group(node.name, "tubedevice_receiver") == 1 then
|
||||
local leftover
|
||||
local def = core.registered_nodes[node.name]
|
||||
local def = minetest.registered_nodes[node.name]
|
||||
if def.tube and def.tube.insert_object then
|
||||
leftover = def.tube.insert_object(self.start_pos, node, stack, vel, self.owner)
|
||||
else
|
||||
@ -404,15 +392,15 @@ luaentity.register_entity("pipeworks:tubed_item", {
|
||||
end
|
||||
local rev_vel = vector.multiply(velocity, -1)
|
||||
local rev_dir = vector.direction(self.start_pos,vector.add(self.start_pos,rev_vel))
|
||||
local rev_node = core.get_node(vector.round(vector.add(self.start_pos,rev_dir)))
|
||||
local tube_present = core.get_item_group(rev_node.name,"tubedevice") == 1
|
||||
local rev_node = minetest.get_node(vector.round(vector.add(self.start_pos,rev_dir)))
|
||||
local tube_present = minetest.get_item_group(rev_node.name,"tubedevice") == 1
|
||||
if not found_next then
|
||||
if pipeworks.drop_on_routing_fail or not tube_present or
|
||||
core.get_item_group(rev_node.name,"tube") ~= 1 then
|
||||
minetest.get_item_group(rev_node.name,"tube") ~= 1 then
|
||||
-- Using add_item instead of item_drop since this makes pipeworks backward
|
||||
-- compatible with Minetest 0.4.13.
|
||||
-- Using item_drop here makes Minetest 0.4.13 crash.
|
||||
local dropped_item = core.add_item(self.start_pos, stack)
|
||||
local dropped_item = minetest.add_item(self.start_pos, stack)
|
||||
if dropped_item then
|
||||
dropped_item:set_velocity(vector.multiply(velocity, 5))
|
||||
self:remove()
|
||||
@ -442,19 +430,19 @@ luaentity.register_entity("pipeworks:tubed_item", {
|
||||
end
|
||||
})
|
||||
|
||||
if core.get_modpath("mesecons_mvps") then
|
||||
if minetest.get_modpath("mesecons_mvps") then
|
||||
mesecon.register_mvps_unmov("pipeworks:tubed_item")
|
||||
mesecon.register_mvps_unmov("pipeworks:color_entity")
|
||||
mesecon.register_on_mvps_move(function(moved_nodes)
|
||||
local moved = {}
|
||||
for _, n in ipairs(moved_nodes) do
|
||||
moved[core.hash_node_position(n.oldpos)] = vector.subtract(n.pos, n.oldpos)
|
||||
moved[minetest.hash_node_position(n.oldpos)] = vector.subtract(n.pos, n.oldpos)
|
||||
end
|
||||
for _, entity in pairs(luaentity.entities) do
|
||||
if entity.name == "pipeworks:tubed_item" then
|
||||
local pos = entity:get_pos()
|
||||
local rpos = vector.round(pos)
|
||||
local dir = moved[core.hash_node_position(rpos)]
|
||||
local dir = moved[minetest.hash_node_position(rpos)]
|
||||
if dir then
|
||||
entity:set_pos(vector.add(pos, dir))
|
||||
entity.start_pos = vector.add(entity.start_pos, dir)
|
||||
|
62
legacy.lua
Normal file
62
legacy.lua
Normal file
@ -0,0 +1,62 @@
|
||||
local S = minetest.get_translator("pipeworks")
|
||||
|
||||
if not minetest.get_modpath("auto_tree_tap") and
|
||||
minetest.get_modpath("technic") then
|
||||
|
||||
minetest.register_abm({
|
||||
nodenames = { "auto_tree_tap:off", "auto_tree_tap:on" },
|
||||
chance = 1,
|
||||
interval = 1,
|
||||
action = function(pos, node, active_object_count, active_object_count_wider)
|
||||
local fdir = node.param2
|
||||
local meta = minetest.get_meta(pos)
|
||||
local inv = meta:get_inventory()
|
||||
inv:set_size("pick", 1)
|
||||
inv:set_size("ghost_pick", 1)
|
||||
inv:set_size("main", 100)
|
||||
minetest.set_node(pos, {name = "pipeworks:nodebreaker_off", param2 = fdir})
|
||||
minetest.registered_nodes["pipeworks:nodebreaker_off"].on_punch(pos, node)
|
||||
inv:set_stack("pick", 1, ItemStack("technic:treetap"))
|
||||
end
|
||||
})
|
||||
|
||||
minetest.register_node(":auto_tree_tap:off", {
|
||||
description = S("Auto-Tap"),
|
||||
tiles = {"pipeworks_nodebreaker_top_off.png","pipeworks_nodebreaker_bottom_off.png","pipeworks_nodebreaker_side2_off.png","pipeworks_nodebreaker_side1_off.png",
|
||||
"pipeworks_nodebreaker_back.png","pipeworks_nodebreaker_front_off.png"},
|
||||
is_ground_content = false,
|
||||
paramtype2 = "facedir",
|
||||
groups = {snappy=2,choppy=2,oddly_breakable_by_hand=2, mesecon = 2,tubedevice=1, not_in_creative_inventory=1, axey=1, handy=1, pickaxey=1},
|
||||
_mcl_hardness=0.8,
|
||||
_sound_def = {
|
||||
key = "node_sound_stone_defaults",
|
||||
},
|
||||
tube = {connect_sides={back=1}},
|
||||
on_construct = function(pos)
|
||||
local meta = minetest.get_meta(pos)
|
||||
local inv = meta:get_inventory()
|
||||
inv:set_size("pick", 1)
|
||||
inv:set_stack("pick", 1, ItemStack("default:pick_mese"))
|
||||
end,
|
||||
after_place_node = function (pos, placer)
|
||||
pipeworks.scan_for_tube_objects(pos, placer)
|
||||
local placer_pos = placer:get_pos()
|
||||
|
||||
--correct for the player's height
|
||||
if placer:is_player() then placer_pos.y = placer_pos.y + 1.5 end
|
||||
|
||||
--correct for 6d facedir
|
||||
if placer_pos then
|
||||
local dir = {
|
||||
x = pos.x - placer_pos.x,
|
||||
y = pos.y - placer_pos.y,
|
||||
z = pos.z - placer_pos.z
|
||||
}
|
||||
local node = minetest.get_node(pos)
|
||||
node.param2 = minetest.dir_to_facedir(dir, true)
|
||||
minetest.set_node(pos, node)
|
||||
end
|
||||
end,
|
||||
after_dig_node = pipeworks.scan_for_tube_objects,
|
||||
})
|
||||
end
|
@ -1,121 +0,0 @@
|
||||
# textdomain: pipeworks
|
||||
|
||||
# License: CC-by-SA 4.0
|
||||
# Author: VinAdmin ovvitalik@gmail.com
|
||||
|
||||
## generic interaction
|
||||
Set=Установить
|
||||
Cancel=Отмена
|
||||
|
||||
## digilines interfacing
|
||||
Channel=Канал
|
||||
|
||||
## init
|
||||
Allow splitting incoming stacks from tubes=Разрешить разделение входящих стопок из трубок
|
||||
|
||||
## autocrafter
|
||||
Unknown item=Неизвестный предмет
|
||||
unconfigured Autocrafter: unknown recipe=ненастроенный автокрафтер: неизвестный рецепт
|
||||
unconfigured Autocrafter=ненастроенный автокрафтер
|
||||
'@1' Autocrafter (@2)='@1' Автокрафтер (@2)
|
||||
Save=Сохранить
|
||||
paused '@1' Autocrafter=приостановлено '@1' Автокрафтер
|
||||
Autocrafter=Автокрафтер
|
||||
|
||||
## compat-furnaces
|
||||
Allow splitting incoming material (not fuel) stacks from tubes=Разрешить разделение стопок поступающего материала (не топлива) из трубок.
|
||||
|
||||
## decorative tubes
|
||||
Airtight steelblock embedded tube=Герметичная встроенная трубка из стального блока
|
||||
Airtight panel embedded tube=Герметичная встроенная в панель трубка
|
||||
|
||||
## devices
|
||||
Pump/Intake Module=Модуль насоса/впуска
|
||||
Valve=Клапан
|
||||
Decorative grating=Декоративная решетка
|
||||
Spigot outlet=Выходной патрубок
|
||||
Airtight Pipe entry/exit=Вход/выход герметичной трубы
|
||||
Flow Sensor=Датчик потока
|
||||
Flow sensor (on)=Датчик расхода (вкл.)
|
||||
empty=пустой
|
||||
@1% full=@1% заполнено
|
||||
Expansion Tank (@1)=Расширительный бак (@1)
|
||||
Fluid Storage Tank (@1)=Резервуар для хранения жидкости (@1)
|
||||
Fountainhead=Источник
|
||||
Straight-only Pipe=Только прямая труба
|
||||
|
||||
## filter-injector
|
||||
(slot #@1 next)=(слот #@1 следующий)
|
||||
@1 Filter-Injector=@1 фильтр-инжектор
|
||||
Sequence slots by Priority=Последовательность слотов по приоритету
|
||||
Sequence slots Randomly=Слоты последовательности Случайный
|
||||
Sequence slots by Rotation=Последовательность слотов по вращению
|
||||
Exact match - off=Точное совпадение – выключено
|
||||
Exact match - on=Точное совпадение - включено
|
||||
Prefer item types:=Предпочитаете типы предметов:
|
||||
Itemwise=По пунктам
|
||||
Stackwise=Стекообразно
|
||||
Digiline=Диджилайн
|
||||
|
||||
## legacy
|
||||
Auto-Tap=Авто-нажатие
|
||||
|
||||
## pipes
|
||||
Pipe Segment=Сегмент трубы
|
||||
Pipe Segment (legacy)=Сегмент трубы (устаревший)
|
||||
|
||||
|
||||
## routing tubes
|
||||
Pneumatic tube segment=Сегмент пневматической трубки
|
||||
Broken Tube=Сломанная трубка
|
||||
High Priority Tube Segment=Сегмент трубы с высоким приоритетом
|
||||
Accelerating Pneumatic Tube Segment=Ускорительный сегмент пневматической трубки
|
||||
Crossing Pneumatic Tube Segment=Пересечение сегмента пневматической трубы
|
||||
One way tube=Односторонняя трубка
|
||||
|
||||
## signal tubes
|
||||
Detecting Pneumatic Tube Segment on=Обнаружение сегмента пневматической трубки включено
|
||||
Detecting Pneumatic Tube Segment=Обнаружение сегмента пневматической трубки
|
||||
Digiline Detecting Pneumatic Tube Segment=Digiline обнаруживает сегмент пневматической трубки
|
||||
Digiline Detecting Tube=Детекторная трубка Digiline
|
||||
Conducting Pneumatic Tube Segment=Проводящий сегмент пневматической трубки
|
||||
Conducting Pneumatic Tube Segment on=Проводящий сегмент пневматической трубки на
|
||||
Digiline Conducting Pneumatic Tube Segment=Сегмент проводящей пневматической трубки Digiline
|
||||
Mesecon and Digiline Conducting Pneumatic Tube Segment=Сегмент токопроводящей пневматической трубки Mesecon и Digiline
|
||||
Mesecon and Digiline Conducting Pneumatic Tube Segment on=Сегмент проводящей пневматической трубки Mesecon и Digiline на
|
||||
Tag Sorting Pneumatic Tube Segment=Сегмент пневматической трубки для сортировки тегов
|
||||
Lua controlled Tube=Трубка, управляемая Lua
|
||||
|
||||
## sorting tubes
|
||||
Sorting Pneumatic Tube Segment=Сортировка сегментов пневматической трубки
|
||||
Sorting pneumatic tube=Сортировочная пневматическая труба
|
||||
|
||||
## teleport tube
|
||||
Receive=Получить
|
||||
Channels are public by default=По умолчанию каналы являются общедоступными
|
||||
Use <player>:<channel> for fully private channels=Используйте <игрок>:<канал> для полностью приватных каналов
|
||||
Use <player>;<channel> for private receivers=Используйте <игрок>;<канал> для частных приемников
|
||||
Teleporting Pneumatic Tube Segment=Сегмент пневматической трубы для телепортации
|
||||
Teleporting Tube=Телепортационная труба
|
||||
Unconfigured Teleportation Tube=Неконфигурированная телепортационная труба
|
||||
Sorry, channel '@1' is reserved for exclusive use by @2=Извините, канал '@1' зарезервирован исключительно для использования @2
|
||||
Sorry, receiving from channel '@1' is reserved for @2=Извините, прием с канала '@1' зарезервирован для @2
|
||||
Teleportation Tube @1 on '@2'=Трубка телепортации @1 на '@2'
|
||||
|
||||
## trashcan
|
||||
Trash Can=Мусорное ведро
|
||||
|
||||
## tube registration
|
||||
Pneumatic tube segment (legacy)=Сегмент пневматической трубы (устаревший)
|
||||
|
||||
## vacuum tubes
|
||||
Radius=Радиус
|
||||
Vacuuming Pneumatic Tube Segment=Сегмент пневматической трубки для вакуумирования
|
||||
Adjustable Vacuuming Tube=Регулируемая вакуумная трубка
|
||||
Adjustable Vacuuming Pneumatic Tube Segment=Регулируемый сегмент вакуумной пневматической трубки
|
||||
Adjustable Vacuuming Pneumatic Tube Segment (@1m)=Регулируемый сегмент вакуумной пневматической трубки (@1m)
|
||||
|
||||
## wielder
|
||||
Node Breaker=Разрушитель узла
|
||||
Deployer=Развертыватель
|
||||
Dispenser=Распылитель
|
@ -5,19 +5,19 @@ pipeworks.luaentity = luaentity
|
||||
|
||||
luaentity.registered_entities = {}
|
||||
|
||||
local filename = core.get_worldpath().."/luaentities"
|
||||
local filename = minetest.get_worldpath().."/luaentities"
|
||||
local function read_file()
|
||||
local f = io.open(filename, "r")
|
||||
if f == nil then return {} end
|
||||
local t = f:read("*all")
|
||||
f:close()
|
||||
if t == "" or t == nil then return {} end
|
||||
return core.deserialize(t) or {}
|
||||
return minetest.deserialize(t) or {}
|
||||
end
|
||||
|
||||
local function write_file(tbl)
|
||||
local f = io.open(filename, "w")
|
||||
f:write(core.serialize(tbl))
|
||||
f:write(minetest.serialize(tbl))
|
||||
f:close()
|
||||
end
|
||||
|
||||
@ -64,49 +64,44 @@ local function write_entities()
|
||||
write_file(luaentity.entities)
|
||||
end
|
||||
|
||||
core.register_on_shutdown(write_entities)
|
||||
minetest.register_on_shutdown(write_entities)
|
||||
luaentity.entities_index = 0
|
||||
|
||||
local function get_blockpos(pos)
|
||||
return {x = math.floor(pos.x / 16),
|
||||
y = math.floor(pos.y / 16),
|
||||
z = math.floor(pos.z / 16)}
|
||||
end
|
||||
|
||||
local move_entities_globalstep_part1
|
||||
local is_active
|
||||
|
||||
if pipeworks.use_real_entities then
|
||||
local active_blocks = {} -- These only contain active blocks near players (i.e., not forceloaded ones)
|
||||
|
||||
local function get_blockpos(pos)
|
||||
return {x = math.floor(pos.x / 16),
|
||||
y = math.floor(pos.y / 16),
|
||||
z = math.floor(pos.z / 16)}
|
||||
end
|
||||
|
||||
move_entities_globalstep_part1 = function(dtime)
|
||||
local active_block_range = tonumber(core.settings:get("active_block_range")) or 2
|
||||
for key in pairs(active_blocks) do
|
||||
active_blocks[key] = nil
|
||||
end
|
||||
for _, player in ipairs(core.get_connected_players()) do
|
||||
local active_block_range = tonumber(minetest.settings:get("active_block_range")) or 2
|
||||
local new_active_blocks = {}
|
||||
for _, player in ipairs(minetest.get_connected_players()) do
|
||||
local blockpos = get_blockpos(player:get_pos())
|
||||
local minpx = blockpos.x - active_block_range
|
||||
local minpy = blockpos.y - active_block_range
|
||||
local minpz = blockpos.z - active_block_range
|
||||
local maxpx = blockpos.x + active_block_range
|
||||
local maxpy = blockpos.y + active_block_range
|
||||
local maxpz = blockpos.z + active_block_range
|
||||
local minp = vector.subtract(blockpos, active_block_range)
|
||||
local maxp = vector.add(blockpos, active_block_range)
|
||||
|
||||
for x = minpx, maxpx do
|
||||
for y = minpy, maxpy do
|
||||
for z = minpz, maxpz do
|
||||
local pos = {x = x, y = y, z = z}
|
||||
active_blocks[core.hash_node_position(pos)] = true
|
||||
end
|
||||
end
|
||||
for x = minp.x, maxp.x do
|
||||
for y = minp.y, maxp.y do
|
||||
for z = minp.z, maxp.z do
|
||||
local pos = {x = x, y = y, z = z}
|
||||
new_active_blocks[minetest.hash_node_position(pos)] = pos
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
active_blocks = new_active_blocks
|
||||
-- todo: callbacks on block load/unload
|
||||
end
|
||||
|
||||
is_active = function(pos)
|
||||
return active_blocks[core.hash_node_position(get_blockpos(pos))] ~= nil
|
||||
return active_blocks[minetest.hash_node_position(get_blockpos(pos))] ~= nil
|
||||
end
|
||||
else
|
||||
move_entities_globalstep_part1 = function()
|
||||
@ -168,7 +163,7 @@ local entitydef_default = {
|
||||
if not is_active(entity_pos) then
|
||||
return
|
||||
end
|
||||
local object = core.add_entity(entity_pos, entity.name)
|
||||
local object = minetest.add_entity(entity_pos, entity.name)
|
||||
if not object then
|
||||
return
|
||||
end
|
||||
@ -290,7 +285,7 @@ end
|
||||
|
||||
function luaentity.add_entity(pos, name)
|
||||
if not luaentity.entities then
|
||||
core.after(0, luaentity.add_entity, vector.new(pos), name)
|
||||
minetest.after(0, luaentity.add_entity, vector.new(pos), name)
|
||||
return
|
||||
end
|
||||
local index = luaentity.entities_index
|
||||
@ -399,7 +394,7 @@ local dtime_accum = 0
|
||||
local dtime_delayed = 0
|
||||
local skip_update = false
|
||||
|
||||
core.register_globalstep(function(dtime)
|
||||
minetest.register_globalstep(function(dtime)
|
||||
if dtime >= 0.2 and dtime_delayed < 1 then
|
||||
-- Reduce activity when the server is lagging.
|
||||
skip_update = true
|
||||
|
72
mcl_barrels.lua
Normal file
72
mcl_barrels.lua
Normal file
@ -0,0 +1,72 @@
|
||||
-- this bit of code modifies the mcl barrels to be compatible with
|
||||
-- pipeworks.
|
||||
|
||||
-- Pipeworks Specific
|
||||
local tube_entry = "^pipeworks_tube_connection_wooden.png"
|
||||
|
||||
-- Original Definitions
|
||||
local old_barrel = table.copy(minetest.registered_items["mcl_barrels:barrel_closed"])
|
||||
|
||||
local groups = old_barrel.groups
|
||||
groups["tubedevice"] = 1
|
||||
groups["tubedevice_receiver"] = 1
|
||||
local groups_open = table.copy(groups)
|
||||
groups_open["not_in_creative_inventory"] = 1
|
||||
|
||||
|
||||
-- Override Construction
|
||||
local override_barrel = {}
|
||||
|
||||
override_barrel.tiles = {
|
||||
"mcl_barrels_barrel_top.png^[transformR270",
|
||||
"mcl_barrels_barrel_bottom.png"..tube_entry,
|
||||
"mcl_barrels_barrel_side.png"..tube_entry
|
||||
}
|
||||
|
||||
override_barrel.after_place_node = function(pos, placer, itemstack, pointed_thing)
|
||||
old_barrel.after_place_node(pos, placer, itemstack, pointed_thing)
|
||||
pipeworks.after_place(pos, placer, itemstack, pointed_thing)
|
||||
end
|
||||
|
||||
override_barrel.tube = {
|
||||
insert_object = function(pos, node, stack, direction)
|
||||
local meta = minetest.get_meta(pos)
|
||||
local inv = meta:get_inventory()
|
||||
return inv:add_item("main", stack)
|
||||
end,
|
||||
can_insert = function(pos, node, stack, direction)
|
||||
local meta = minetest.get_meta(pos)
|
||||
local inv = meta:get_inventory()
|
||||
if meta:get_int("splitstacks") == 1 then
|
||||
stack = stack:peek_item(1)
|
||||
end
|
||||
return inv:room_for_item("main", stack)
|
||||
end,
|
||||
input_inventory = "main",
|
||||
connect_sides = {left = 1, right = 1, back = 1, front = 1, bottom = 1}
|
||||
}
|
||||
|
||||
override_barrel.after_dig_node = function(pos, oldnode, oldmetadata, digger)
|
||||
old_barrel.after_dig_node(pos, oldnode, oldmetadata, digger)
|
||||
pipeworks.after_dig(pos)
|
||||
end
|
||||
|
||||
override_barrel.groups = table.copy(old_barrel.groups)
|
||||
|
||||
override_barrel.on_rotate = pipeworks.on_rotate
|
||||
|
||||
|
||||
local override_barrel_open = table.copy(override_barrel)
|
||||
|
||||
override_barrel_open.tiles = {
|
||||
"mcl_barrels_barrel_top_open.png",
|
||||
"mcl_barrels_barrel_bottom.png"..tube_entry,
|
||||
"mcl_barrels_barrel_side.png"..tube_entry
|
||||
}
|
||||
|
||||
override_barrel_open.groups = groups_open
|
||||
|
||||
|
||||
-- Override with the new modifications.
|
||||
minetest.override_item("mcl_barrels:barrel_closed", override_barrel)
|
||||
minetest.override_item("mcl_barrels:barrel_open", override_barrel_open)
|
@ -1,7 +1,7 @@
|
||||
|
||||
local old_furnace = table.copy(core.registered_nodes["mcl_furnaces:furnace"])
|
||||
local old_blast_furnace = table.copy(core.registered_nodes["mcl_blast_furnace:blast_furnace"])
|
||||
local old_smoker = table.copy(core.registered_nodes["mcl_smoker:smoker"])
|
||||
local old_furnace = table.copy(minetest.registered_nodes["mcl_furnaces:furnace"])
|
||||
local old_blast_furnace = table.copy(minetest.registered_nodes["mcl_blast_furnace:blast_furnace"])
|
||||
local old_smoker = table.copy(minetest.registered_nodes["mcl_smoker:smoker"])
|
||||
|
||||
local tube_entry = "^pipeworks_tube_connection_stony.png"
|
||||
|
||||
@ -27,8 +27,8 @@ smoker_groups_active["not_in_creative_inventory"] = 1
|
||||
|
||||
-- a hack to give the exp to fake players it's be dropped instead added to (fake) player inv
|
||||
local function give_xp(pos, player)
|
||||
local meta = core.get_meta(pos)
|
||||
local dir = vector.divide(core.facedir_to_dir(core.get_node(pos).param2), -1.95)
|
||||
local meta = minetest.get_meta(pos)
|
||||
local dir = vector.divide(minetest.facedir_to_dir(minetest.get_node(pos).param2), -1.95)
|
||||
local xp = meta:get_int("xp")
|
||||
if xp > 0 then
|
||||
mcl_experience.throw_xp(vector.add(pos, dir), xp)
|
||||
@ -51,9 +51,9 @@ override.groups = furnace_groups
|
||||
|
||||
override.tube = {
|
||||
insert_object = function(pos, node, stack, direction)
|
||||
local meta = core.get_meta(pos)
|
||||
local meta = minetest.get_meta(pos)
|
||||
local inv = meta:get_inventory()
|
||||
local timer = core.get_node_timer(pos)
|
||||
local timer = minetest.get_node_timer(pos)
|
||||
if not timer:is_started() then
|
||||
timer:start(1.0)
|
||||
end
|
||||
@ -64,7 +64,7 @@ override.tube = {
|
||||
end
|
||||
end,
|
||||
can_insert = function(pos,node,stack,direction)
|
||||
local meta = core.get_meta(pos)
|
||||
local meta = minetest.get_meta(pos)
|
||||
local inv = meta:get_inventory()
|
||||
if direction.y == 1 then
|
||||
return inv:room_for_item("fuel", stack)
|
||||
@ -117,9 +117,9 @@ override_active.groups = furnace_groups_active
|
||||
|
||||
override_active.tube = {
|
||||
insert_object = function(pos,node,stack,direction)
|
||||
local meta = core.get_meta(pos)
|
||||
local meta = minetest.get_meta(pos)
|
||||
local inv = meta:get_inventory()
|
||||
local timer = core.get_node_timer(pos)
|
||||
local timer = minetest.get_node_timer(pos)
|
||||
if not timer:is_started() then
|
||||
timer:start(1.0)
|
||||
end
|
||||
@ -130,7 +130,7 @@ override_active.tube = {
|
||||
end
|
||||
end,
|
||||
can_insert = function(pos, node, stack, direction)
|
||||
local meta = core.get_meta(pos)
|
||||
local meta = minetest.get_meta(pos)
|
||||
local inv = meta:get_inventory()
|
||||
if direction.y == 1 then
|
||||
return inv:room_for_item("fuel", stack)
|
||||
@ -160,9 +160,9 @@ override_blast_furnace.groups = blast_furnace_groups
|
||||
|
||||
override_blast_furnace.tube = {
|
||||
insert_object = function(pos, node, stack, direction)
|
||||
local meta = core.get_meta(pos)
|
||||
local meta = minetest.get_meta(pos)
|
||||
local inv = meta:get_inventory()
|
||||
local timer = core.get_node_timer(pos)
|
||||
local timer = minetest.get_node_timer(pos)
|
||||
if not timer:is_started() then
|
||||
timer:start(1.0)
|
||||
end
|
||||
@ -173,7 +173,7 @@ override_blast_furnace.tube = {
|
||||
end
|
||||
end,
|
||||
can_insert = function(pos,node,stack,direction)
|
||||
local meta = core.get_meta(pos)
|
||||
local meta = minetest.get_meta(pos)
|
||||
local inv = meta:get_inventory()
|
||||
if direction.y == 1 then
|
||||
return inv:room_for_item("fuel", stack)
|
||||
@ -228,9 +228,9 @@ override_blast_active.groups = blast_furnace_groups_active
|
||||
|
||||
override_blast_active.tube = {
|
||||
insert_object = function(pos,node,stack,direction)
|
||||
local meta = core.get_meta(pos)
|
||||
local meta = minetest.get_meta(pos)
|
||||
local inv = meta:get_inventory()
|
||||
local timer = core.get_node_timer(pos)
|
||||
local timer = minetest.get_node_timer(pos)
|
||||
if not timer:is_started() then
|
||||
timer:start(1.0)
|
||||
end
|
||||
@ -241,7 +241,7 @@ override_blast_active.tube = {
|
||||
end
|
||||
end,
|
||||
can_insert = function(pos, node, stack, direction)
|
||||
local meta = core.get_meta(pos)
|
||||
local meta = minetest.get_meta(pos)
|
||||
local inv = meta:get_inventory()
|
||||
if direction.y == 1 then
|
||||
return inv:room_for_item("fuel", stack)
|
||||
@ -271,9 +271,9 @@ override_smoker.groups = smoker_groups
|
||||
|
||||
override_smoker.tube = {
|
||||
insert_object = function(pos, node, stack, direction)
|
||||
local meta = core.get_meta(pos)
|
||||
local meta = minetest.get_meta(pos)
|
||||
local inv = meta:get_inventory()
|
||||
local timer = core.get_node_timer(pos)
|
||||
local timer = minetest.get_node_timer(pos)
|
||||
if not timer:is_started() then
|
||||
timer:start(1.0)
|
||||
end
|
||||
@ -284,7 +284,7 @@ override_smoker.tube = {
|
||||
end
|
||||
end,
|
||||
can_insert = function(pos,node,stack,direction)
|
||||
local meta = core.get_meta(pos)
|
||||
local meta = minetest.get_meta(pos)
|
||||
local inv = meta:get_inventory()
|
||||
if direction.y == 1 then
|
||||
return inv:room_for_item("fuel", stack)
|
||||
@ -339,9 +339,9 @@ override_smoker_active.groups = smoker_groups_active
|
||||
|
||||
override_smoker_active.tube = {
|
||||
insert_object = function(pos,node,stack,direction)
|
||||
local meta = core.get_meta(pos)
|
||||
local meta = minetest.get_meta(pos)
|
||||
local inv = meta:get_inventory()
|
||||
local timer = core.get_node_timer(pos)
|
||||
local timer = minetest.get_node_timer(pos)
|
||||
if not timer:is_started() then
|
||||
timer:start(1.0)
|
||||
end
|
||||
@ -352,7 +352,7 @@ override_smoker_active.tube = {
|
||||
end
|
||||
end,
|
||||
can_insert = function(pos, node, stack, direction)
|
||||
local meta = core.get_meta(pos)
|
||||
local meta = minetest.get_meta(pos)
|
||||
local inv = meta:get_inventory()
|
||||
if direction.y == 1 then
|
||||
return inv:room_for_item("fuel", stack)
|
||||
@ -366,11 +366,11 @@ override_smoker_active.tube = {
|
||||
|
||||
|
||||
-- override
|
||||
core.override_item("mcl_furnaces:furnace", override)
|
||||
core.override_item("mcl_furnaces:furnace_active", override_active)
|
||||
minetest.override_item("mcl_furnaces:furnace", override)
|
||||
minetest.override_item("mcl_furnaces:furnace_active", override_active)
|
||||
|
||||
core.override_item("mcl_blast_furnace:blast_furnace", override_blast_furnace)
|
||||
core.override_item("mcl_blast_furnace:blast_furnace_active", override_blast_active)
|
||||
minetest.override_item("mcl_blast_furnace:blast_furnace", override_blast_furnace)
|
||||
minetest.override_item("mcl_blast_furnace:blast_furnace_active", override_blast_active)
|
||||
|
||||
core.override_item("mcl_smoker:smoker", override_smoker)
|
||||
core.override_item("mcl_smoker:smoker_active", override_smoker_active)
|
||||
minetest.override_item("mcl_smoker:smoker", override_smoker)
|
||||
minetest.override_item("mcl_smoker:smoker_active", override_smoker_active)
|
||||
|
4
mod.conf
4
mod.conf
@ -1,5 +1,5 @@
|
||||
name = pipeworks
|
||||
description = This mod uses mesh nodes and nodeboxes to supply a complete set of 3D pipes and tubes, along with devices that work with them.
|
||||
depends = basic_materials, xcompat, fakelib
|
||||
optional_depends = mesecons, mesecons_mvps, digilines, signs_lib, unified_inventory, default, screwdriver, fl_mapgen, sound_api, i3, hades_core, hades_furnaces, hades_chests, mcl_mapgen_core, mcl_barrels, mcl_furnaces, mcl_experience, vizlib
|
||||
depends = basic_materials, xcompat
|
||||
optional_depends = mesecons, mesecons_mvps, digilines, signs_lib, unified_inventory, default, screwdriver, fl_mapgen, sound_api, i3, hades_core, hades_furnaces, hades_chests, mcl_mapgen_core, mcl_barrels, mcl_furnaces, mcl_experience
|
||||
min_minetest_version = 5.5.0
|
||||
|
38
pipes.lua
38
pipes.lua
@ -1,5 +1,5 @@
|
||||
-- This file supplies the steel pipes
|
||||
local S = core.get_translator("pipeworks")
|
||||
local S = minetest.get_translator("pipeworks")
|
||||
|
||||
local REGISTER_COMPATIBILITY = true
|
||||
|
||||
@ -37,11 +37,11 @@ for index, connects in ipairs(cconnects) do
|
||||
end
|
||||
--]]
|
||||
|
||||
local pgroups = {snappy = 3, pipe = 1, not_in_creative_inventory = 1, dig_generic = 4, axey = 1, handy = 1, pickaxey = 1}
|
||||
local pgroups = {snappy = 3, pipe = 1, not_in_creative_inventory = 1, dig_generic = 4, axey=1, handy=1, pickaxey=1}
|
||||
local pipedesc = S("Pipe Segment").." "..dump(connects)
|
||||
|
||||
if #connects == 0 then
|
||||
pgroups = {snappy = 3, pipe = 1, dig_generic = 4, axey = 1, handy = 1, pickaxey = 1}
|
||||
pgroups = {snappy = 3, tube = 1, dig_generic = 4, axey=1, handy=1, pickaxey=1}
|
||||
pipedesc = S("Pipe Segment")
|
||||
end
|
||||
|
||||
@ -59,7 +59,7 @@ for index, connects in ipairs(cconnects) do
|
||||
mesh = "pipeworks_pipe_3"..polys..".obj"
|
||||
end
|
||||
|
||||
core.register_node("pipeworks:pipe_"..index.."_empty", {
|
||||
minetest.register_node("pipeworks:pipe_"..index.."_empty", {
|
||||
description = pipedesc,
|
||||
drawtype = "mesh",
|
||||
mesh = mesh,
|
||||
@ -77,7 +77,7 @@ for index, connects in ipairs(cconnects) do
|
||||
},
|
||||
groups = pgroups,
|
||||
is_ground_content = false,
|
||||
_mcl_hardness = 0.8,
|
||||
_mcl_hardness=0.8,
|
||||
_sound_def = {
|
||||
key = "node_sound_metal_defaults",
|
||||
},
|
||||
@ -95,9 +95,9 @@ for index, connects in ipairs(cconnects) do
|
||||
pipenumber = index
|
||||
})
|
||||
|
||||
local pgroups = {snappy = 3, pipe = 1, not_in_creative_inventory = 1, dig_generic = 4, axey = 1, handy = 1, pickaxey = 1}
|
||||
local pgroups = {snappy = 3, pipe = 1, not_in_creative_inventory = 1, dig_generic = 4, axey=1, handy=1, pickaxey=1}
|
||||
|
||||
core.register_node("pipeworks:pipe_"..index.."_loaded", {
|
||||
minetest.register_node("pipeworks:pipe_"..index.."_loaded", {
|
||||
description = pipedesc,
|
||||
drawtype = "mesh",
|
||||
mesh = mesh,
|
||||
@ -115,14 +115,14 @@ for index, connects in ipairs(cconnects) do
|
||||
},
|
||||
groups = pgroups,
|
||||
is_ground_content = false,
|
||||
_mcl_hardness = 0.8,
|
||||
_mcl_hardness=0.8,
|
||||
_sound_def = {
|
||||
key = "node_sound_metal_defaults",
|
||||
},
|
||||
walkable = true,
|
||||
drop = "pipeworks:pipe_1_empty",
|
||||
after_place_node = function(pos)
|
||||
core.set_node(pos, { name = "pipeworks:pipe_"..index.."_empty" })
|
||||
minetest.set_node(pos, { name = "pipeworks:pipe_"..index.."_empty" })
|
||||
pipeworks.scan_for_pipe_objects(pos)
|
||||
end,
|
||||
after_dig_node = function(pos)
|
||||
@ -147,7 +147,7 @@ pipeworks.ui_cat_tube_list[#pipeworks.ui_cat_tube_list+1] = "pipeworks:pipe_1_em
|
||||
if REGISTER_COMPATIBILITY then
|
||||
local cempty = "pipeworks:pipe_compatibility_empty"
|
||||
local cloaded = "pipeworks:pipe_compatibility_loaded"
|
||||
core.register_node(cempty, {
|
||||
minetest.register_node(cempty, {
|
||||
drawtype = "airlike",
|
||||
sunlight_propagates = true,
|
||||
paramtype = "light",
|
||||
@ -161,7 +161,7 @@ if REGISTER_COMPATIBILITY then
|
||||
on_rotate = false
|
||||
|
||||
})
|
||||
core.register_node(cloaded, {
|
||||
minetest.register_node(cloaded, {
|
||||
drawtype = "airlike",
|
||||
sunlight_propagates = true,
|
||||
paramtype = "light",
|
||||
@ -181,22 +181,22 @@ if REGISTER_COMPATIBILITY then
|
||||
for zm = 0, 1 do
|
||||
for zp = 0, 1 do
|
||||
local pname = xm..xp..ym..yp..zm..zp
|
||||
core.register_alias("pipeworks:pipe_"..pname.."_empty", cempty)
|
||||
core.register_alias("pipeworks:pipe_"..pname.."_loaded", cloaded)
|
||||
minetest.register_alias("pipeworks:pipe_"..pname.."_empty", cempty)
|
||||
minetest.register_alias("pipeworks:pipe_"..pname.."_loaded", cloaded)
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
core.register_abm({
|
||||
minetest.register_abm({
|
||||
nodenames = {"group:pipe_to_update"},
|
||||
interval = 1,
|
||||
chance = 1,
|
||||
action = function(pos, node, active_object_count, active_object_count_wider)
|
||||
local minp = {x = pos.x-1, y = pos.y-1, z = pos.z-1}
|
||||
local maxp = {x = pos.x+1, y = pos.y+1, z = pos.z+1}
|
||||
if table.getn(core.find_nodes_in_area(minp, maxp, "ignore")) == 0 then
|
||||
if table.getn(minetest.find_nodes_in_area(minp, maxp, "ignore")) == 0 then
|
||||
pipeworks.scan_for_pipe_objects(pos)
|
||||
end
|
||||
end
|
||||
@ -229,7 +229,7 @@ pipeworks.pipes_empty_nodenames = pipes_empty_nodenames
|
||||
|
||||
if pipeworks.toggles.pipe_mode == "classic" then
|
||||
|
||||
core.register_abm({
|
||||
minetest.register_abm({
|
||||
nodenames = pipes_empty_nodenames,
|
||||
interval = 1,
|
||||
chance = 1,
|
||||
@ -238,7 +238,7 @@ core.register_abm({
|
||||
end
|
||||
})
|
||||
|
||||
core.register_abm({
|
||||
minetest.register_abm({
|
||||
nodenames = pipes_full_nodenames,
|
||||
interval = 1,
|
||||
chance = 1,
|
||||
@ -247,7 +247,7 @@ core.register_abm({
|
||||
end
|
||||
})
|
||||
|
||||
core.register_abm({
|
||||
minetest.register_abm({
|
||||
nodenames = {"pipeworks:spigot","pipeworks:spigot_pouring"},
|
||||
interval = 1,
|
||||
chance = 1,
|
||||
@ -256,7 +256,7 @@ core.register_abm({
|
||||
end
|
||||
})
|
||||
|
||||
core.register_abm({
|
||||
minetest.register_abm({
|
||||
nodenames = {"pipeworks:fountainhead","pipeworks:fountainhead_pouring"},
|
||||
interval = 1,
|
||||
chance = 1,
|
||||
|
@ -11,7 +11,7 @@ local flowlogic = pipeworks.flowlogic
|
||||
|
||||
local register_flowlogic_abm = function(nodename)
|
||||
if pipeworks.toggles.pipe_mode == "pressure" then
|
||||
core.register_abm({
|
||||
minetest.register_abm({
|
||||
label = "pipeworks new_flow_logic run",
|
||||
nodenames = { nodename },
|
||||
interval = 1,
|
||||
@ -21,7 +21,7 @@ local register_flowlogic_abm = function(nodename)
|
||||
end
|
||||
})
|
||||
else
|
||||
core.log("warning", "pipeworks pressure_logic not enabled but register.flowlogic() requested")
|
||||
minetest.log("warning", "pipeworks pressure_logic not enabled but register.flowlogic() requested")
|
||||
end
|
||||
end
|
||||
register.flowlogic = register_flowlogic_abm
|
||||
|
@ -41,9 +41,9 @@ local check_for_liquids_v2 = function(pos, limit)
|
||||
local total = 0
|
||||
for _, tpos in ipairs(coords) do
|
||||
if total >= limit then break end
|
||||
local name = core.get_node(tpos).name
|
||||
local name = minetest.get_node(tpos).name
|
||||
if name == pipeworks.liquids.water.source then
|
||||
core.remove_node(tpos)
|
||||
minetest.remove_node(tpos)
|
||||
total = total + 1
|
||||
end
|
||||
end
|
||||
@ -56,7 +56,7 @@ flowlogic.check_for_liquids_v2 = check_for_liquids_v2
|
||||
|
||||
local label_pressure = "pipeworks.water_pressure"
|
||||
local get_pressure_access = function(pos)
|
||||
local metaref = core.get_meta(pos)
|
||||
local metaref = minetest.get_meta(pos)
|
||||
return {
|
||||
get = function()
|
||||
return metaref:get_float(label_pressure)
|
||||
@ -114,7 +114,7 @@ flowlogic.run = function(pos, node)
|
||||
if pipeworks.flowables.transitions.list[nodename] then
|
||||
local newnode = flowlogic.run_transition(node, currentpressure)
|
||||
--pipeworks.logger("flowlogic.run()@"..formatvec(pos).." transition, new node name = "..dump(newnode).." pressure "..tostring(currentpressure))
|
||||
core.swap_node(pos, newnode)
|
||||
minetest.swap_node(pos, newnode)
|
||||
flowlogic.run_transition_post(pos, newnode)
|
||||
end
|
||||
|
||||
@ -155,7 +155,7 @@ local get_neighbour_positions = function(pos, node)
|
||||
local connections = {}
|
||||
for _, offset in ipairs(candidates) do
|
||||
local npos = vector.add(pos, offset)
|
||||
local neighbour = core.get_node(npos)
|
||||
local neighbour = minetest.get_node(npos)
|
||||
local nodename = neighbour.name
|
||||
local is_simple = (pipeworks.flowables.list.simple[nodename])
|
||||
if is_simple then
|
||||
@ -241,7 +241,7 @@ flowlogic.helpers.make_neighbour_output_fixed = function(neighbours)
|
||||
local taken = 0
|
||||
for _, offset in pairs(neighbours) do
|
||||
local npos = vector.add(pos, offset)
|
||||
local name = core.get_node(npos).name
|
||||
local name = minetest.get_node(npos).name
|
||||
if currentpressure < 1 then break end
|
||||
-- take pressure anyway in non-finite mode, even if node is water source already.
|
||||
-- in non-finite mode, pressure has to be sustained to keep the sources there.
|
||||
@ -249,7 +249,7 @@ flowlogic.helpers.make_neighbour_output_fixed = function(neighbours)
|
||||
-- draining pressure is not.
|
||||
local canplace = (name == "air") or (name == pipeworks.liquids.water.flowing)
|
||||
if canplace then
|
||||
core.swap_node(npos, {name=pipeworks.liquids.water.source})
|
||||
minetest.swap_node(npos, {name=pipeworks.liquids.water.source})
|
||||
end
|
||||
if (not finitemode) or canplace then
|
||||
taken = taken + 1
|
||||
@ -267,10 +267,10 @@ flowlogic.helpers.make_neighbour_cleanup_fixed = function(neighbours)
|
||||
--pipeworks.logger("neighbour_cleanup_fixed@"..formatvec(pos))
|
||||
for _, offset in pairs(neighbours) do
|
||||
local npos = vector.add(pos, offset)
|
||||
local name = core.get_node(npos).name
|
||||
local name = minetest.get_node(npos).name
|
||||
if (name == pipeworks.liquids.water.source) then
|
||||
--pipeworks.logger("neighbour_cleanup_fixed removing "..formatvec(npos))
|
||||
core.remove_node(npos)
|
||||
minetest.remove_node(npos)
|
||||
end
|
||||
end
|
||||
end
|
||||
@ -351,9 +351,9 @@ end
|
||||
-- among other things, updates mesecons if present.
|
||||
-- node here means the new node, returned from run_transition() above
|
||||
flowlogic.run_transition_post = function(pos, node)
|
||||
local mesecons_def = core.registered_nodes[node.name].mesecons
|
||||
local mesecons_def = minetest.registered_nodes[node.name].mesecons
|
||||
local mesecons_rules = pipeworks.flowables.transitions.mesecons[node.name]
|
||||
if core.get_modpath("mesecons") and (mesecons_def ~= nil) and mesecons_rules then
|
||||
if minetest.get_modpath("mesecons") and (mesecons_def ~= nil) and mesecons_rules then
|
||||
if type(mesecons_def) ~= "table" then
|
||||
pipeworks.logger("flowlogic.run_transition_post() BUG mesecons def for "..node.name.."not a table: got "..tostring(mesecons_def))
|
||||
else
|
||||
|
@ -85,17 +85,5 @@ pipeworks_use_real_entities (Use Real Entities) bool true
|
||||
#A value 0.2 or above may cause issues with accelerator tubes.
|
||||
pipeworks_entity_update_interval (Entity Update Interval) float 0 0 0.8
|
||||
|
||||
# Use the default rules from the digilines mod.
|
||||
# If enabled the following devices will connect to digiline networks in the vertical direction:
|
||||
# digiline filter injector, deployer, dispenser, node breaker, autocrafter
|
||||
# This breaks expected behavior with digiline conducting tubes.
|
||||
# If disabled, the devices will not be able to send or recieve digiline signals from the top
|
||||
# or bottom faces, regardless of the node rotation.
|
||||
enable_vertical_digilines_connectivity (Use the default rules from the digilines mod) bool false
|
||||
|
||||
# if set to true, items passing through teleport tubes will log log where they came from and where they went.
|
||||
pipeworks_log_teleport_tubes (Log Teleport Tubes) bool false
|
||||
|
||||
# Behavior of print() inside a lua tube. By default, this emits a message into actionstream.
|
||||
# Set it to noop if you wish to disable that behavior.
|
||||
pipeworks_lua_tube_print_behavior (Behavior of print in Lua Tube) enum log log,noop
|
||||
|
10
trashcan.lua
10
trashcan.lua
@ -1,5 +1,5 @@
|
||||
local S = core.get_translator("pipeworks")
|
||||
core.register_node("pipeworks:trashcan", {
|
||||
local S = minetest.get_translator("pipeworks")
|
||||
minetest.register_node("pipeworks:trashcan", {
|
||||
description = S("Trash Can"),
|
||||
drawtype = "normal",
|
||||
tiles = {
|
||||
@ -21,10 +21,10 @@ core.register_node("pipeworks:trashcan", {
|
||||
priority = 1, -- Lower than anything else
|
||||
},
|
||||
on_construct = function(pos)
|
||||
local meta = core.get_meta(pos)
|
||||
local meta = minetest.get_meta(pos)
|
||||
local size = "10.2,9"
|
||||
local list_background = ""
|
||||
if core.get_modpath("i3") or core.get_modpath("mcl_formspec") then
|
||||
if minetest.get_modpath("i3") or minetest.get_modpath("mcl_formspec") then
|
||||
list_background = "style_type[box;colors=#666]box[4.5,2;1,1;]"
|
||||
end
|
||||
meta:set_string("formspec",
|
||||
@ -46,7 +46,7 @@ core.register_node("pipeworks:trashcan", {
|
||||
after_place_node = pipeworks.after_place,
|
||||
after_dig_node = pipeworks.after_dig,
|
||||
on_metadata_inventory_put = function(pos, listname, index, stack, player)
|
||||
core.get_meta(pos):get_inventory():set_stack(listname, index, ItemStack(""))
|
||||
minetest.get_meta(pos):get_inventory():set_stack(listname, index, ItemStack(""))
|
||||
end,
|
||||
})
|
||||
pipeworks.ui_cat_tube_list[#pipeworks.ui_cat_tube_list+1] = "pipeworks:trashcan"
|
||||
|
@ -1,13 +1,13 @@
|
||||
local materials = xcompat.materials
|
||||
local S = core.get_translator("pipeworks")
|
||||
local S = minetest.get_translator("pipeworks")
|
||||
|
||||
local straight = function(pos, node, velocity, stack) return {velocity} end
|
||||
local steel_tex = "[combine:16x16^[noalpha^[colorize:#D3D3D3"
|
||||
if core.get_modpath("default") then steel_tex = "default_steel_block.png" end
|
||||
if minetest.get_modpath("default") then steel_tex = "default_steel_block.png" end
|
||||
|
||||
-- register an embedded tube
|
||||
function pipeworks.register_embedded_tube(nodename, opts)
|
||||
core.register_node(nodename, {
|
||||
minetest.register_node(nodename, {
|
||||
description = opts.description,
|
||||
tiles = {
|
||||
opts.base_texture,
|
||||
@ -41,7 +41,7 @@ function pipeworks.register_embedded_tube(nodename, opts)
|
||||
priority = 50,
|
||||
can_go = straight,
|
||||
can_insert = function(pos, node, stack, direction)
|
||||
local dir = core.facedir_to_dir(node.param2)
|
||||
local dir = minetest.facedir_to_dir(node.param2)
|
||||
return vector.equals(dir, direction) or vector.equals(vector.multiply(dir, -1), direction)
|
||||
end
|
||||
},
|
||||
@ -50,7 +50,7 @@ function pipeworks.register_embedded_tube(nodename, opts)
|
||||
on_rotate = pipeworks.on_rotate,
|
||||
})
|
||||
|
||||
core.register_craft( {
|
||||
minetest.register_craft( {
|
||||
output = nodename .. " 1",
|
||||
recipe = {
|
||||
{ opts.base_ingredient, opts.base_ingredient, opts.base_ingredient },
|
||||
|
112
tubes/lua.lua
112
tubes/lua.lua
@ -26,12 +26,10 @@
|
||||
-- use too much memory from the sandbox.
|
||||
-- You can add more functions to the environment
|
||||
-- (see where local env is defined)
|
||||
-- Something nice to play is appending core.env to it.
|
||||
-- Something nice to play is appending minetest.env to it.
|
||||
|
||||
local BASENAME = "pipeworks:lua_tube"
|
||||
|
||||
local has_digilines = core.get_modpath("digilines")
|
||||
|
||||
local rules = {
|
||||
red = {x = -1, y = 0, z = 0, name = "red"},
|
||||
blue = {x = 1, y = 0, z = 0, name = "blue"},
|
||||
@ -65,7 +63,7 @@ local digiline_rules_luatube = {
|
||||
-- These helpers are required to set the port states of the lua_tube
|
||||
|
||||
local function update_real_port_states(pos, rule_name, new_state)
|
||||
local meta = core.get_meta(pos)
|
||||
local meta = minetest.get_meta(pos)
|
||||
if rule_name == nil then
|
||||
meta:set_int("real_portstates", 1)
|
||||
return
|
||||
@ -102,7 +100,7 @@ local port_names = {"red", "blue", "yellow", "green", "black", "white"}
|
||||
|
||||
local function get_real_port_states(pos)
|
||||
-- Determine if ports are powered (by itself or from outside)
|
||||
local meta = core.get_meta(pos)
|
||||
local meta = minetest.get_meta(pos)
|
||||
local L = {}
|
||||
local n = meta:get_int("real_portstates") - 1
|
||||
for _, name in ipairs(port_names) do
|
||||
@ -155,10 +153,10 @@ end
|
||||
|
||||
|
||||
local function set_port_states(pos, ports)
|
||||
local node = core.get_node(pos)
|
||||
local node = minetest.get_node(pos)
|
||||
local name = node.name
|
||||
clean_port_states(ports)
|
||||
local vports = core.registered_nodes[name].virtual_portstates
|
||||
local vports = minetest.registered_nodes[name].virtual_portstates
|
||||
local new_name = generate_name(ports)
|
||||
|
||||
if name ~= new_name and vports then
|
||||
@ -171,17 +169,17 @@ local function set_port_states(pos, ports)
|
||||
-- its output off.
|
||||
-- Solution / Workaround:
|
||||
-- Remember which output was turned off and ignore next "off" event.
|
||||
local meta = core.get_meta(pos)
|
||||
local ign = core.deserialize(meta:get_string("ignore_offevents"), true) or {}
|
||||
local meta = minetest.get_meta(pos)
|
||||
local ign = minetest.deserialize(meta:get_string("ignore_offevents"), true) or {}
|
||||
if ports.red and not vports.red and not mesecon.is_powered(pos, rules.red) then ign.red = true end
|
||||
if ports.blue and not vports.blue and not mesecon.is_powered(pos, rules.blue) then ign.blue = true end
|
||||
if ports.yellow and not vports.yellow and not mesecon.is_powered(pos, rules.yellow) then ign.yellow = true end
|
||||
if ports.green and not vports.green and not mesecon.is_powered(pos, rules.green) then ign.green = true end
|
||||
if ports.black and not vports.black and not mesecon.is_powered(pos, rules.black) then ign.black = true end
|
||||
if ports.white and not vports.white and not mesecon.is_powered(pos, rules.white) then ign.white = true end
|
||||
meta:set_string("ignore_offevents", core.serialize(ign))
|
||||
meta:set_string("ignore_offevents", minetest.serialize(ign))
|
||||
|
||||
core.swap_node(pos, {name = new_name, param2 = node.param2})
|
||||
minetest.swap_node(pos, {name = new_name, param2 = node.param2})
|
||||
|
||||
if ports.red ~= vports.red then set_port(pos, rules.red, ports.red) end
|
||||
if ports.blue ~= vports.blue then set_port(pos, rules.blue, ports.blue) end
|
||||
@ -197,12 +195,12 @@ end
|
||||
-- Overheating --
|
||||
-----------------
|
||||
local function burn_controller(pos)
|
||||
local node = core.get_node(pos)
|
||||
local node = minetest.get_node(pos)
|
||||
node.name = BASENAME.."_burnt"
|
||||
core.swap_node(pos, node)
|
||||
core.get_meta(pos):set_string("lc_memory", "");
|
||||
minetest.swap_node(pos, node)
|
||||
minetest.get_meta(pos):set_string("lc_memory", "");
|
||||
-- Wait for pending operations
|
||||
core.after(0.2, mesecon.receptor_off, pos, mesecon.rules.flat)
|
||||
minetest.after(0.2, mesecon.receptor_off, pos, mesecon.rules.flat)
|
||||
end
|
||||
|
||||
local function overheat(pos, meta)
|
||||
@ -218,10 +216,10 @@ end
|
||||
|
||||
local function ignore_event(event, meta)
|
||||
if event.type ~= "off" then return false end
|
||||
local ignore_offevents = core.deserialize(meta:get_string("ignore_offevents"), true) or {}
|
||||
local ignore_offevents = minetest.deserialize(meta:get_string("ignore_offevents"), true) or {}
|
||||
if ignore_offevents[event.pin.name] then
|
||||
ignore_offevents[event.pin.name] = nil
|
||||
meta:set_string("ignore_offevents", core.serialize(ignore_offevents))
|
||||
meta:set_string("ignore_offevents", minetest.serialize(ignore_offevents))
|
||||
return true
|
||||
end
|
||||
end
|
||||
@ -231,13 +229,11 @@ end
|
||||
-------------------------
|
||||
|
||||
local function safe_print(param)
|
||||
if (core.settings:get("pipeworks_lua_tube_print_behavior") or "log") == "log" then
|
||||
local string_meta = getmetatable("")
|
||||
local sandbox = string_meta.__index
|
||||
string_meta.__index = string -- Leave string sandbox temporarily
|
||||
core.log("action", string.format("[pipeworks.tubes.lua] print(%s)", dump(param)))
|
||||
string_meta.__index = sandbox -- Restore string sandbox
|
||||
end
|
||||
local string_meta = getmetatable("")
|
||||
local sandbox = string_meta.__index
|
||||
string_meta.__index = string -- Leave string sandbox temporarily
|
||||
print(dump(param))
|
||||
string_meta.__index = sandbox -- Restore string sandbox
|
||||
end
|
||||
|
||||
local function safe_date()
|
||||
@ -309,7 +305,7 @@ if mesecon.setting("luacontroller_lightweight_interrupts", false) then
|
||||
return (function(time, iid)
|
||||
if type(time) ~= "number" then error("Delay must be a number") end
|
||||
if iid ~= nil then send_warning("Interrupt IDs are disabled on this server") end
|
||||
table.insert(itbl, function() core.get_node_timer(pos):start(time) end)
|
||||
table.insert(itbl, function() minetest.get_node_timer(pos):start(time) end)
|
||||
end)
|
||||
end
|
||||
else
|
||||
@ -323,12 +319,12 @@ else
|
||||
if type(time) ~= "number" then error("Delay must be a number") end
|
||||
table.insert(itbl, function ()
|
||||
-- Outside string metatable sandbox, can safely run this now
|
||||
local luac_id = core.get_meta(pos):get_int("luac_id")
|
||||
local luac_id = minetest.get_meta(pos):get_int("luac_id")
|
||||
-- Check if IID is dodgy, so you can't use interrupts to store an infinite amount of data.
|
||||
-- Note that this is safe from alter-after-free because this code gets run after the sandbox has ended.
|
||||
-- This runs outside of the timer and *shouldn't* harm perf. unless dodgy data is being sent in the first place
|
||||
iid = remove_functions(iid)
|
||||
local msg_ser = core.serialize(iid)
|
||||
local msg_ser = minetest.serialize(iid)
|
||||
if #msg_ser <= mesecon.setting("luacontroller_interruptid_maxlen", 256) then
|
||||
mesecon.queue:add_action(pos, "pipeworks:lc_tube_interrupt", {luac_id, iid}, time, iid, 1)
|
||||
else
|
||||
@ -432,7 +428,7 @@ end
|
||||
|
||||
-- itbl: Flat table of functions to run after sandbox cleanup, used to prevent various security hazards
|
||||
local function get_digiline_send(pos, itbl, send_warning)
|
||||
if not has_digilines then return end
|
||||
if not minetest.get_modpath("digilines") then return end
|
||||
local chan_maxlen = mesecon.setting("luacontroller_digiline_channel_maxlen", 256)
|
||||
local maxlen = mesecon.setting("luacontroller_digiline_maxlen", 50000)
|
||||
return function(channel, msg)
|
||||
@ -458,7 +454,7 @@ local function get_digiline_send(pos, itbl, send_warning)
|
||||
|
||||
table.insert(itbl, function ()
|
||||
-- Runs outside of string metatable sandbox
|
||||
local luac_id = core.get_meta(pos):get_int("luac_id")
|
||||
local luac_id = minetest.get_meta(pos):get_int("luac_id")
|
||||
mesecon.queue:add_action(pos, "pipeworks:lt_digiline_relay", {channel, luac_id, msg})
|
||||
end)
|
||||
return true
|
||||
@ -473,7 +469,7 @@ local safe_globals = {
|
||||
|
||||
local function create_environment(pos, mem, event, itbl, send_warning)
|
||||
-- Make sure the tube hasn't broken.
|
||||
local vports = core.registered_nodes[core.get_node(pos).name].virtual_portstates
|
||||
local vports = minetest.registered_nodes[minetest.get_node(pos).name].virtual_portstates
|
||||
if not vports then return {} end
|
||||
|
||||
-- Gather variables for the environment
|
||||
@ -595,19 +591,19 @@ end
|
||||
|
||||
|
||||
local function load_memory(meta)
|
||||
return core.deserialize(meta:get_string("lc_memory"), true) or {}
|
||||
return minetest.deserialize(meta:get_string("lc_memory"), true) or {}
|
||||
end
|
||||
|
||||
|
||||
local function save_memory(pos, meta, mem)
|
||||
local memstring = core.serialize(remove_functions(mem))
|
||||
local memstring = minetest.serialize(remove_functions(mem))
|
||||
local memsize_max = mesecon.setting("luacontroller_memsize", 100000)
|
||||
|
||||
if (#memstring <= memsize_max) then
|
||||
meta:set_string("lc_memory", memstring)
|
||||
meta:mark_as_private("lc_memory")
|
||||
else
|
||||
core.log("info", "lua_tube memory overflow. "..memsize_max.." bytes available, "
|
||||
print("Error: lua_tube memory overflow. "..memsize_max.." bytes available, "
|
||||
..#memstring.." required. Controller overheats.")
|
||||
burn_controller(pos)
|
||||
end
|
||||
@ -616,7 +612,7 @@ end
|
||||
-- Returns success (boolean), errmsg (string), retval(any, return value of the user supplied code)
|
||||
-- run (as opposed to run_inner) is responsible for setting up meta according to this output
|
||||
local function run_inner(pos, code, event)
|
||||
local meta = core.get_meta(pos)
|
||||
local meta = minetest.get_meta(pos)
|
||||
-- Note: These return success, presumably to avoid changing LC ID.
|
||||
if overheat(pos) then return true, "", nil end
|
||||
if ignore_event(event, meta) then return true, "", nil end
|
||||
@ -670,8 +666,8 @@ end
|
||||
local function reset_formspec(meta, code, errmsg)
|
||||
meta:set_string("code", code)
|
||||
meta:mark_as_private("code")
|
||||
code = core.formspec_escape(code or "")
|
||||
errmsg = core.formspec_escape(tostring(errmsg or ""))
|
||||
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]"
|
||||
@ -683,14 +679,14 @@ local function reset_formspec(meta, code, errmsg)
|
||||
end
|
||||
|
||||
local function reset_meta(pos, code, errmsg)
|
||||
local meta = core.get_meta(pos)
|
||||
local meta = minetest.get_meta(pos)
|
||||
reset_formspec(meta, code, errmsg)
|
||||
meta:set_int("luac_id", math.random(1, 65535))
|
||||
end
|
||||
|
||||
-- Wraps run_inner with LC-reset-on-error
|
||||
local function run(pos, event)
|
||||
local meta = core.get_meta(pos)
|
||||
local meta = minetest.get_meta(pos)
|
||||
local code = meta:get_string("code")
|
||||
local ok, errmsg, retval = run_inner(pos, code, event)
|
||||
if not ok then
|
||||
@ -707,7 +703,7 @@ local function reset(pos)
|
||||
end
|
||||
|
||||
local function node_timer(pos)
|
||||
if core.registered_nodes[core.get_node(pos).name].is_burnt then
|
||||
if minetest.registered_nodes[minetest.get_node(pos).name].is_burnt then
|
||||
return false
|
||||
end
|
||||
run(pos, {type="interrupt"})
|
||||
@ -720,18 +716,18 @@ end
|
||||
|
||||
mesecon.queue:add_function("pipeworks:lc_tube_interrupt", function (pos, luac_id, iid)
|
||||
-- There is no lua_tube anymore / it has been reprogrammed / replaced / burnt
|
||||
if (core.get_meta(pos):get_int("luac_id") ~= luac_id) then return end
|
||||
if (core.registered_nodes[core.get_node(pos).name].is_burnt) then return end
|
||||
if (minetest.get_meta(pos):get_int("luac_id") ~= luac_id) then return end
|
||||
if (minetest.registered_nodes[minetest.get_node(pos).name].is_burnt) then return end
|
||||
run(pos, {type="interrupt", iid = iid})
|
||||
end)
|
||||
|
||||
mesecon.queue:add_function("pipeworks:lt_digiline_relay", function (pos, channel, luac_id, msg)
|
||||
if not has_digilines then return end
|
||||
if not digiline then return end
|
||||
-- This check is only really necessary because in case of server crash, old actions can be thrown into the future
|
||||
if (core.get_meta(pos):get_int("luac_id") ~= luac_id) then return end
|
||||
if (core.registered_nodes[core.get_node(pos).name].is_burnt) then return end
|
||||
if (minetest.get_meta(pos):get_int("luac_id") ~= luac_id) then return end
|
||||
if (minetest.registered_nodes[minetest.get_node(pos).name].is_burnt) then return end
|
||||
-- The actual work
|
||||
digilines.receptor_send(pos, digiline_rules_luatube, channel, msg)
|
||||
digiline:receptor_send(pos, digiline_rules_luatube, channel, msg)
|
||||
end)
|
||||
|
||||
-----------------------
|
||||
@ -772,7 +768,7 @@ local digiline = {
|
||||
}
|
||||
|
||||
local function get_program(pos)
|
||||
local meta = core.get_meta(pos)
|
||||
local meta = minetest.get_meta(pos)
|
||||
return meta:get_string("code")
|
||||
end
|
||||
|
||||
@ -787,14 +783,14 @@ local function on_receive_fields(pos, form_name, fields, sender)
|
||||
return
|
||||
end
|
||||
local name = sender:get_player_name()
|
||||
if core.is_protected(pos, name) and not core.check_player_privs(name, {protection_bypass=true}) then
|
||||
core.record_protection_violation(pos, name)
|
||||
if minetest.is_protected(pos, name) and not minetest.check_player_privs(name, {protection_bypass=true}) then
|
||||
minetest.record_protection_violation(pos, name)
|
||||
return
|
||||
end
|
||||
local ok, err = set_program(pos, fields.code)
|
||||
if not ok then
|
||||
-- it's not an error from the server perspective
|
||||
core.log("action", "Lua controller programming error: " .. tostring(err))
|
||||
minetest.log("action", "Lua controller programming error: " .. tostring(err))
|
||||
end
|
||||
end
|
||||
|
||||
@ -828,7 +824,7 @@ local tiles_on_off = {
|
||||
R270 = "^(pipeworks_lua_tube_port_%s.png^[transformR270)"
|
||||
}
|
||||
|
||||
local texture_alpha_mode = core.features.use_texture_alpha_string_modes
|
||||
local texture_alpha_mode = minetest.features.use_texture_alpha_string_modes
|
||||
and "clip" or true
|
||||
|
||||
for red = 0, 1 do -- 0 = off 1 = on
|
||||
@ -911,7 +907,7 @@ for white = 0, 1 do
|
||||
},
|
||||
}
|
||||
|
||||
core.register_node(node_name, {
|
||||
minetest.register_node(node_name, {
|
||||
description = "Lua controlled Tube",
|
||||
drawtype = "nodebox",
|
||||
tiles = tiles,
|
||||
@ -930,7 +926,7 @@ for white = 0, 1 do
|
||||
key = "node_sound_wood_defaults",
|
||||
},
|
||||
mesecons = mesecons,
|
||||
digilines = digiline,
|
||||
digiline = digiline,
|
||||
-- Virtual portstates are the ports that
|
||||
-- the node shows as powered up (light up).
|
||||
virtual_portstates = {
|
||||
@ -999,10 +995,10 @@ for white = 0, 1 do
|
||||
after_place_node = pipeworks.after_place,
|
||||
on_blast = function(pos, intensity)
|
||||
if not intensity or intensity > 1 + 3^0.5 then
|
||||
core.remove_node(pos)
|
||||
minetest.remove_node(pos)
|
||||
return
|
||||
end
|
||||
core.swap_node(pos, {name = "pipeworks:broken_tube_1"})
|
||||
minetest.swap_node(pos, {name = "pipeworks:broken_tube_1"})
|
||||
pipeworks.scan_for_tube_objects(pos)
|
||||
end,
|
||||
})
|
||||
@ -1045,7 +1041,7 @@ tiles_burnt[2] = tiles_burnt[2].."^(pipeworks_lua_tube_port_burnt.png^[transform
|
||||
tiles_burnt[3] = tiles_burnt[3].."^(pipeworks_lua_tube_port_burnt.png^[transformR270)"
|
||||
tiles_burnt[4] = tiles_burnt[4].."^(pipeworks_lua_tube_port_burnt.png^[transformR90)"
|
||||
|
||||
core.register_node(BASENAME .. "_burnt", {
|
||||
minetest.register_node(BASENAME .. "_burnt", {
|
||||
drawtype = "nodebox",
|
||||
tiles = tiles_burnt,
|
||||
use_texture_alpha = texture_alpha_mode,
|
||||
@ -1082,10 +1078,10 @@ core.register_node(BASENAME .. "_burnt", {
|
||||
after_dig_node = pipeworks.after_dig,
|
||||
on_blast = function(pos, intensity)
|
||||
if not intensity or intensity > 1 + 3^0.5 then
|
||||
core.remove_node(pos)
|
||||
minetest.remove_node(pos)
|
||||
return
|
||||
end
|
||||
core.swap_node(pos, {name = "pipeworks:broken_tube_1"})
|
||||
minetest.swap_node(pos, {name = "pipeworks:broken_tube_1"})
|
||||
pipeworks.scan_for_tube_objects(pos)
|
||||
end,
|
||||
})
|
||||
@ -1094,7 +1090,7 @@ core.register_node(BASENAME .. "_burnt", {
|
||||
-- Craft Registration --
|
||||
------------------------
|
||||
|
||||
core.register_craft({
|
||||
minetest.register_craft({
|
||||
type = "shapeless",
|
||||
output = BASENAME.."000000",
|
||||
recipe = {"pipeworks:mese_tube_000000", "mesecons_luacontroller:luacontroller0000"},
|
||||
|
@ -1,4 +1,4 @@
|
||||
local S = core.get_translator("pipeworks")
|
||||
local S = minetest.get_translator("pipeworks")
|
||||
|
||||
local straight = function(pos, node, velocity, stack) return {velocity} end
|
||||
|
||||
@ -10,10 +10,10 @@ local pane_box = {
|
||||
}
|
||||
}
|
||||
|
||||
local texture_alpha_mode = core.features.use_texture_alpha_string_modes
|
||||
local texture_alpha_mode = minetest.features.use_texture_alpha_string_modes
|
||||
and "clip" or true
|
||||
|
||||
core.register_node("pipeworks:steel_pane_embedded_tube", {
|
||||
minetest.register_node("pipeworks:steel_pane_embedded_tube", {
|
||||
drawtype = "nodebox",
|
||||
description = S("Airtight panel embedded tube"),
|
||||
tiles = {
|
||||
@ -30,7 +30,7 @@ core.register_node("pipeworks:steel_pane_embedded_tube", {
|
||||
collision_box = pane_box,
|
||||
paramtype = "light",
|
||||
paramtype2 = "facedir",
|
||||
groups = {cracky=1, oddly_breakable_by_hand = 1, tubedevice = 1, tube = 1, dig_glass = 2, pickaxey=1, handy=1},
|
||||
groups = {cracky=1, oddly_breakable_by_hand = 1, tubedevice = 1, dig_glass = 2, pickaxey=1, handy=1},
|
||||
is_ground_content = false,
|
||||
_mcl_hardness=0.8,
|
||||
legacy_facedir_simple = true,
|
||||
@ -42,7 +42,7 @@ core.register_node("pipeworks:steel_pane_embedded_tube", {
|
||||
priority = 50,
|
||||
can_go = straight,
|
||||
can_insert = function(pos, node, stack, direction)
|
||||
local dir = core.facedir_to_dir(node.param2)
|
||||
local dir = minetest.facedir_to_dir(node.param2)
|
||||
return vector.equals(dir, direction) or vector.equals(vector.multiply(dir, -1), direction)
|
||||
end,
|
||||
},
|
||||
|
@ -1,10 +1,10 @@
|
||||
-- This file supplies the various kinds of pneumatic tubes
|
||||
local S = core.get_translator("pipeworks")
|
||||
local S = minetest.get_translator("pipeworks")
|
||||
|
||||
local tubenodes = {}
|
||||
pipeworks.tubenodes = tubenodes
|
||||
|
||||
core.register_alias("pipeworks:tube", "pipeworks:tube_000000")
|
||||
minetest.register_alias("pipeworks:tube", "pipeworks:tube_000000")
|
||||
|
||||
-- now, a function to define the tubes
|
||||
|
||||
@ -27,8 +27,8 @@ local texture_mt = {
|
||||
}
|
||||
|
||||
-- This will remove any semi-transparent pixels
|
||||
-- because that is still buggy in Luanti, force this as default
|
||||
local texture_alpha_mode = core.features.use_texture_alpha_string_modes
|
||||
-- because that is still buggy in Minetest, force this as default
|
||||
local texture_alpha_mode = minetest.features.use_texture_alpha_string_modes
|
||||
and "clip" or true
|
||||
|
||||
local register_one_tube = function(name, tname, dropname, desc, plain, noctrs, ends, short, inv, special, connects, style)
|
||||
@ -112,6 +112,7 @@ local register_one_tube = function(name, tname, dropname, desc, plain, noctrs, e
|
||||
key = "node_sound_wood_defaults",
|
||||
},
|
||||
walkable = true,
|
||||
stack_max = 99,
|
||||
basename = name,
|
||||
style = style,
|
||||
drop = string.format("%s_%s", name, dropname),
|
||||
@ -122,25 +123,25 @@ local register_one_tube = function(name, tname, dropname, desc, plain, noctrs, e
|
||||
},
|
||||
on_punch = function(pos, node, player, pointed)
|
||||
local playername = player:get_player_name()
|
||||
if core.is_protected(pos, playername) and not core.check_player_privs(playername, {protection_bypass=true}) then
|
||||
return core.node_punch(pos, node, player, pointed)
|
||||
if minetest.is_protected(pos, playername) and not minetest.check_player_privs(playername, {protection_bypass=true}) then
|
||||
return minetest.node_punch(pos, node, player, pointed)
|
||||
end
|
||||
if pipeworks.check_and_wear_hammer(player) then
|
||||
local wieldname = player:get_wielded_item():get_name()
|
||||
pipeworks.logger(string.format("%s struck a tube at %s with %s to break it.", playername, core.pos_to_string(pos), wieldname))
|
||||
pipeworks.logger(string.format("%s struck a tube at %s with %s to break it.", playername, minetest.pos_to_string(pos), wieldname))
|
||||
pipeworks.break_tube(pos)
|
||||
end
|
||||
return core.node_punch(pos, node, player, pointed)
|
||||
return minetest.node_punch(pos, node, player, pointed)
|
||||
end,
|
||||
after_place_node = pipeworks.after_place,
|
||||
after_dig_node = pipeworks.after_dig,
|
||||
on_rotate = false,
|
||||
on_blast = function(pos, intensity)
|
||||
if not intensity or intensity > 1 + 3^0.5 then
|
||||
core.remove_node(pos)
|
||||
minetest.remove_node(pos)
|
||||
return {string.format("%s_%s", name, dropname)}
|
||||
end
|
||||
core.swap_node(pos, {name = "pipeworks:broken_tube_1"})
|
||||
minetest.swap_node(pos, {name = "pipeworks:broken_tube_1"})
|
||||
pipeworks.scan_for_tube_objects(pos)
|
||||
end,
|
||||
check_for_pole = pipeworks.check_for_vert_tube,
|
||||
@ -169,7 +170,7 @@ local register_one_tube = function(name, tname, dropname, desc, plain, noctrs, e
|
||||
end
|
||||
end
|
||||
|
||||
core.register_node(rname, nodedef)
|
||||
minetest.register_node(rname, nodedef)
|
||||
end
|
||||
|
||||
local register_all_tubes = function(name, desc, plain, noctrs, ends, short, inv, special, old_registration)
|
||||
@ -216,7 +217,7 @@ local register_all_tubes = function(name, desc, plain, noctrs, ends, short, inv,
|
||||
end
|
||||
if REGISTER_COMPATIBILITY then
|
||||
local cname = name.."_compatibility"
|
||||
core.register_node(cname, {
|
||||
minetest.register_node(cname, {
|
||||
drawtype = "airlike",
|
||||
style = "6d",
|
||||
basename = name,
|
||||
@ -240,7 +241,7 @@ local register_all_tubes = function(name, desc, plain, noctrs, ends, short, inv,
|
||||
for zm = 0, 1 do
|
||||
for zp = 0, 1 do
|
||||
local tname = xm..xp..ym..yp..zm..zp
|
||||
core.register_alias(name.."_"..tname, cname)
|
||||
minetest.register_alias(name.."_"..tname, cname)
|
||||
end
|
||||
end
|
||||
end
|
||||
@ -266,14 +267,14 @@ end
|
||||
|
||||
|
||||
if REGISTER_COMPATIBILITY then
|
||||
core.register_abm({
|
||||
minetest.register_abm({
|
||||
nodenames = {"group:tube_to_update"},
|
||||
interval = 1,
|
||||
chance = 1,
|
||||
action = function(pos, node, active_object_count, active_object_count_wider)
|
||||
local minp = vector.subtract(pos, 1)
|
||||
local maxp = vector.add(pos, 1)
|
||||
if table.getn(core.find_nodes_in_area(minp, maxp, "ignore")) == 0 then
|
||||
if table.getn(minetest.find_nodes_in_area(minp, maxp, "ignore")) == 0 then
|
||||
pipeworks.scan_for_tube_objects(pos)
|
||||
end
|
||||
end
|
||||
|
@ -1,7 +1,7 @@
|
||||
local S = core.get_translator("pipeworks")
|
||||
local S = minetest.get_translator("pipeworks")
|
||||
-- the default tube and default textures
|
||||
pipeworks.register_tube("pipeworks:tube", S("Pneumatic tube segment"))
|
||||
core.register_craft( {
|
||||
minetest.register_craft( {
|
||||
output = "pipeworks:tube_1 6",
|
||||
recipe = {
|
||||
{ "basic_materials:plastic_sheet", "basic_materials:plastic_sheet", "basic_materials:plastic_sheet" },
|
||||
@ -53,7 +53,7 @@ pipeworks.register_tube("pipeworks:broken_tube", {
|
||||
is_ground_content = false,
|
||||
tube = {
|
||||
insert_object = function(pos, node, stack, direction)
|
||||
core.item_drop(stack, nil, pos)
|
||||
minetest.item_drop(stack, nil, pos)
|
||||
return ItemStack("")
|
||||
end,
|
||||
can_insert = function(pos,node,stack,direction)
|
||||
@ -65,9 +65,9 @@ pipeworks.register_tube("pipeworks:broken_tube", {
|
||||
local itemstack = puncher:get_wielded_item()
|
||||
local wieldname = itemstack:get_name()
|
||||
local playername = puncher:get_player_name()
|
||||
local log_msg = playername.." struck a broken tube at "..core.pos_to_string(pos).."\n "
|
||||
local meta = core.get_meta(pos)
|
||||
local was_node = core.deserialize(meta:get_string("the_tube_was"))
|
||||
local log_msg = playername.." struck a broken tube at "..minetest.pos_to_string(pos).."\n "
|
||||
local meta = minetest.get_meta(pos)
|
||||
local was_node = minetest.deserialize(meta:get_string("the_tube_was"))
|
||||
if not was_node then
|
||||
pipeworks.logger(log_msg.."but it can't be repaired.")
|
||||
return
|
||||
@ -75,8 +75,8 @@ pipeworks.register_tube("pipeworks:broken_tube", {
|
||||
if not pipeworks.check_and_wear_hammer(puncher) then
|
||||
if wieldname == "" then
|
||||
pipeworks.logger(log_msg.."by hand. It's not very effective.")
|
||||
if core.settings:get_bool("enable_damage") then
|
||||
core.chat_send_player(playername,S("Broken tubes may be a bit sharp. Perhaps try with a hammer?"))
|
||||
if minetest.settings:get_bool("enable_damage") then
|
||||
minetest.chat_send_player(playername,S("Broken tubes may be a bit sharp. Perhaps try with a hammer?"))
|
||||
puncher:set_hp(puncher:get_hp()-1)
|
||||
end
|
||||
else
|
||||
@ -85,19 +85,19 @@ pipeworks.register_tube("pipeworks:broken_tube", {
|
||||
return
|
||||
end
|
||||
log_msg = log_msg.."with "..wieldname.." to repair it"
|
||||
local nodedef = core.registered_nodes[was_node.name]
|
||||
local nodedef = minetest.registered_nodes[was_node.name]
|
||||
if nodedef then
|
||||
pipeworks.logger(log_msg..".")
|
||||
if nodedef.tube and nodedef.tube.on_repair then
|
||||
nodedef.tube.on_repair(pos, was_node)
|
||||
else
|
||||
core.swap_node(pos, { name = was_node.name, param2 = was_node.param2 })
|
||||
minetest.swap_node(pos, { name = was_node.name, param2 = was_node.param2 })
|
||||
pipeworks.scan_for_tube_objects(pos)
|
||||
end
|
||||
meta:set_string("the_tube_was", "")
|
||||
else
|
||||
pipeworks.logger(log_msg.." but original node "..was_node.name.." is not registered anymore.")
|
||||
core.chat_send_player(playername, S("This tube cannot be repaired."))
|
||||
minetest.chat_send_player(playername, S("This tube cannot be repaired."))
|
||||
end
|
||||
end,
|
||||
allow_metadata_inventory_put = function()
|
||||
@ -161,7 +161,7 @@ if pipeworks.enable_crossing_tube then
|
||||
})
|
||||
end
|
||||
|
||||
local texture_alpha_mode = core.features.use_texture_alpha_string_modes
|
||||
local texture_alpha_mode = minetest.features.use_texture_alpha_string_modes
|
||||
and "clip" or true
|
||||
|
||||
if pipeworks.enable_one_way_tube then
|
||||
@ -170,7 +170,7 @@ if pipeworks.enable_one_way_tube then
|
||||
for i, tile in ipairs(tiles) do
|
||||
tiles[i] = pipeworks.make_tube_tile(tile)
|
||||
end
|
||||
core.register_node("pipeworks:one_way_tube", {
|
||||
minetest.register_node("pipeworks:one_way_tube", {
|
||||
description = S("One way tube"),
|
||||
tiles = tiles,
|
||||
use_texture_alpha = texture_alpha_mode,
|
||||
@ -179,7 +179,7 @@ if pipeworks.enable_one_way_tube then
|
||||
paramtype = "light",
|
||||
node_box = {type = "fixed",
|
||||
fixed = {{-1/2, -9/64, -9/64, 1/2, 9/64, 9/64}}},
|
||||
groups = {snappy = 2, choppy = 2, oddly_breakable_by_hand = 2, tubedevice = 1, tube = 1, axey=1, handy=1, pickaxey=1},
|
||||
groups = {snappy = 2, choppy = 2, oddly_breakable_by_hand = 2, tubedevice = 1, axey=1, handy=1, pickaxey=1},
|
||||
is_ground_content = false,
|
||||
_mcl_hardness=0.8,
|
||||
_sound_def = {
|
||||
|
@ -1,51 +1,51 @@
|
||||
local S = core.get_translator("pipeworks")
|
||||
local S = minetest.get_translator("pipeworks")
|
||||
|
||||
-- the core.after() calls below can sometimes trigger after a tube
|
||||
-- the minetest.after() calls below can sometimes trigger after a tube
|
||||
-- breaks, at which point item_exit() is no longer valid, so we have to make
|
||||
-- sure that there even IS a callback to run, first.
|
||||
|
||||
local function after_break(pos)
|
||||
local name = core.get_node(pos).name
|
||||
if core.registered_nodes[name].item_exit then
|
||||
core.registered_nodes[name].item_exit(pos)
|
||||
local name = minetest.get_node(pos).name
|
||||
if minetest.registered_nodes[name].item_exit then
|
||||
minetest.registered_nodes[name].item_exit(pos)
|
||||
end
|
||||
end
|
||||
|
||||
if core.get_modpath("mesecons") and pipeworks.enable_detector_tube then
|
||||
local detector_tube_step = 5 * (tonumber(core.settings:get("dedicated_server_step")) or 0.09)
|
||||
if minetest.get_modpath("mesecons") and pipeworks.enable_detector_tube then
|
||||
local detector_tube_step = 5 * (tonumber(minetest.settings:get("dedicated_server_step")) or 0.09)
|
||||
pipeworks.register_tube("pipeworks:detector_tube_on", {
|
||||
description = S("Detecting Pneumatic Tube Segment on"),
|
||||
inventory_image = "pipeworks_detector_tube_inv.png",
|
||||
plain = { "pipeworks_detector_tube_plain.png" },
|
||||
node_def = {
|
||||
tube = {can_go = function(pos, node, velocity, stack)
|
||||
local meta = core.get_meta(pos)
|
||||
local meta = minetest.get_meta(pos)
|
||||
local nitems = meta:get_int("nitems")+1
|
||||
meta:set_int("nitems", nitems)
|
||||
local saved_pos = vector.new(pos)
|
||||
core.after(detector_tube_step, after_break, saved_pos)
|
||||
minetest.after(detector_tube_step, after_break, saved_pos)
|
||||
return pipeworks.notvel(pipeworks.meseadjlist,velocity)
|
||||
end},
|
||||
groups = {mesecon = 2, not_in_creative_inventory = 1},
|
||||
drop = "pipeworks:detector_tube_off_1",
|
||||
mesecons = {receptor = {state = "on", rules = pipeworks.mesecons_rules}},
|
||||
item_exit = function(pos)
|
||||
local meta = core.get_meta(pos)
|
||||
local meta = minetest.get_meta(pos)
|
||||
local nitems = meta:get_int("nitems")-1
|
||||
local node = core.get_node(pos)
|
||||
local node = minetest.get_node(pos)
|
||||
local name = node.name
|
||||
local fdir = node.param2
|
||||
if nitems == 0 then
|
||||
core.set_node(pos, {name = string.gsub(name, "on", "off"), param2 = fdir})
|
||||
minetest.set_node(pos, {name = string.gsub(name, "on", "off"), param2 = fdir})
|
||||
mesecon.receptor_off(pos, pipeworks.mesecons_rules)
|
||||
else
|
||||
meta:set_int("nitems", nitems)
|
||||
end
|
||||
end,
|
||||
on_construct = function(pos)
|
||||
local meta = core.get_meta(pos)
|
||||
local meta = minetest.get_meta(pos)
|
||||
meta:set_int("nitems", 1)
|
||||
core.after(detector_tube_step, after_break, pos)
|
||||
minetest.after(detector_tube_step, after_break, pos)
|
||||
end,
|
||||
},
|
||||
})
|
||||
@ -55,10 +55,10 @@ if core.get_modpath("mesecons") and pipeworks.enable_detector_tube then
|
||||
plain = { "pipeworks_detector_tube_plain.png" },
|
||||
node_def = {
|
||||
tube = {can_go = function(pos, node, velocity, stack)
|
||||
local node = core.get_node(pos)
|
||||
local node = minetest.get_node(pos)
|
||||
local name = node.name
|
||||
local fdir = node.param2
|
||||
core.set_node(pos,{name = string.gsub(name, "off", "on"), param2 = fdir})
|
||||
minetest.set_node(pos,{name = string.gsub(name, "off", "on"), param2 = fdir})
|
||||
mesecon.receptor_on(pos, pipeworks.mesecons_rules)
|
||||
return pipeworks.notvel(pipeworks.meseadjlist, velocity)
|
||||
end},
|
||||
@ -67,7 +67,7 @@ if core.get_modpath("mesecons") and pipeworks.enable_detector_tube then
|
||||
},
|
||||
})
|
||||
|
||||
core.register_craft( {
|
||||
minetest.register_craft( {
|
||||
output = "pipeworks:detector_tube_off_1 2",
|
||||
recipe = {
|
||||
{ "basic_materials:plastic_sheet", "basic_materials:plastic_sheet", "basic_materials:plastic_sheet" },
|
||||
@ -77,7 +77,7 @@ if core.get_modpath("mesecons") and pipeworks.enable_detector_tube then
|
||||
})
|
||||
end
|
||||
|
||||
local digiline_enabled = core.get_modpath("digilines") ~= nil
|
||||
local digiline_enabled = minetest.get_modpath("digilines") ~= nil
|
||||
if digiline_enabled and pipeworks.enable_digiline_detector_tube then
|
||||
pipeworks.register_tube("pipeworks:digiline_detector_tube", {
|
||||
description = S("Digiline Detecting Pneumatic Tube Segment"),
|
||||
@ -85,16 +85,16 @@ if digiline_enabled and pipeworks.enable_digiline_detector_tube then
|
||||
plain = { "pipeworks_digiline_detector_tube_plain.png" },
|
||||
node_def = {
|
||||
tube = {can_go = function(pos, node, velocity, stack)
|
||||
local meta = core.get_meta(pos)
|
||||
local meta = minetest.get_meta(pos)
|
||||
|
||||
local setchan = meta:get_string("channel")
|
||||
|
||||
digilines.receptor_send(pos, digilines.rules.default, setchan, stack:to_table())
|
||||
digiline:receptor_send(pos, digiline.rules.default, setchan, stack:to_table())
|
||||
|
||||
return pipeworks.notvel(pipeworks.meseadjlist, velocity)
|
||||
end},
|
||||
on_construct = function(pos)
|
||||
local meta = core.get_meta(pos)
|
||||
local meta = minetest.get_meta(pos)
|
||||
meta:set_string("formspec",
|
||||
"size[8.5,2.2]"..
|
||||
"image[0.2,0;1,1;pipeworks_digiline_detector_tube_inv.png]"..
|
||||
@ -111,11 +111,11 @@ if digiline_enabled and pipeworks.enable_digiline_detector_tube then
|
||||
return
|
||||
end
|
||||
if fields.channel then
|
||||
core.get_meta(pos):set_string("channel", fields.channel)
|
||||
minetest.get_meta(pos):set_string("channel", fields.channel)
|
||||
end
|
||||
end,
|
||||
groups = {},
|
||||
digilines = {
|
||||
digiline = {
|
||||
receptor = {},
|
||||
effector = {
|
||||
action = function(pos,node,channel,msg) end
|
||||
@ -127,7 +127,7 @@ if digiline_enabled and pipeworks.enable_digiline_detector_tube then
|
||||
},
|
||||
})
|
||||
|
||||
core.register_craft( {
|
||||
minetest.register_craft( {
|
||||
output = "pipeworks:digiline_detector_tube_1 2",
|
||||
recipe = {
|
||||
{ "basic_materials:plastic_sheet", "basic_materials:plastic_sheet", "basic_materials:plastic_sheet" },
|
||||
@ -137,7 +137,7 @@ if digiline_enabled and pipeworks.enable_digiline_detector_tube then
|
||||
})
|
||||
end
|
||||
|
||||
if core.get_modpath("mesecons") and pipeworks.enable_conductor_tube then
|
||||
if minetest.get_modpath("mesecons") and pipeworks.enable_conductor_tube then
|
||||
pipeworks.register_tube("pipeworks:conductor_tube_off", {
|
||||
description = S("Conducting Pneumatic Tube Segment"),
|
||||
inventory_image = "pipeworks_conductor_tube_inv.png",
|
||||
@ -168,7 +168,7 @@ if core.get_modpath("mesecons") and pipeworks.enable_conductor_tube then
|
||||
},
|
||||
})
|
||||
|
||||
core.register_craft({
|
||||
minetest.register_craft({
|
||||
type = "shapeless",
|
||||
output = "pipeworks:conductor_tube_off_1",
|
||||
recipe = {"pipeworks:tube_1", "mesecons:mesecon"}
|
||||
@ -183,9 +183,9 @@ if digiline_enabled and pipeworks.enable_digiline_conductor_tube then
|
||||
plain = {"pipeworks_tube_plain.png^pipeworks_digiline_conductor_tube_plain.png"},
|
||||
noctr = {"pipeworks_tube_noctr.png^pipeworks_digiline_conductor_tube_noctr.png"},
|
||||
ends = {"pipeworks_tube_end.png^pipeworks_digiline_conductor_tube_end.png"},
|
||||
node_def = {digilines = {wire = {rules = pipeworks.digilines_rules}}},
|
||||
node_def = {digiline = {wire = {rules = pipeworks.digilines_rules}}},
|
||||
})
|
||||
core.register_craft({
|
||||
minetest.register_craft({
|
||||
type = "shapeless",
|
||||
output = "pipeworks:digiline_conductor_tube_1",
|
||||
recipe = {"pipeworks:tube_1", "digilines:wire_std_00000000"}
|
||||
@ -202,7 +202,7 @@ if digiline_enabled and pipeworks.enable_digiline_conductor_tube and
|
||||
noctr = {"pipeworks_conductor_tube_noctr.png^pipeworks_digiline_conductor_tube_noctr.png"},
|
||||
ends = {"pipeworks_conductor_tube_end.png^pipeworks_digiline_conductor_tube_end.png"},
|
||||
node_def = {
|
||||
digilines = {wire = {rules = pipeworks.digilines_rules}},
|
||||
digiline = {wire = {rules = pipeworks.digilines_rules}},
|
||||
groups = {mesecon = 2},
|
||||
mesecons = {conductor = {
|
||||
state = "off",
|
||||
@ -219,7 +219,7 @@ if digiline_enabled and pipeworks.enable_digiline_conductor_tube and
|
||||
noctr = {"pipeworks_conductor_tube_on_noctr.png^pipeworks_digiline_conductor_tube_noctr.png"},
|
||||
ends = {"pipeworks_conductor_tube_on_end.png^pipeworks_digiline_conductor_tube_end.png"},
|
||||
node_def = {
|
||||
digilines = {wire = {rules = pipeworks.digilines_rules}},
|
||||
digiline = {wire = {rules = pipeworks.digilines_rules}},
|
||||
groups = {mesecon = 2, not_in_creative_inventory = 1},
|
||||
drop = "pipeworks:mesecon_and_digiline_conductor_tube_off_1",
|
||||
mesecons = {conductor = {
|
||||
@ -229,17 +229,17 @@ if digiline_enabled and pipeworks.enable_digiline_conductor_tube and
|
||||
},
|
||||
},
|
||||
})
|
||||
core.register_craft({
|
||||
minetest.register_craft({
|
||||
type = "shapeless",
|
||||
output = "pipeworks:mesecon_and_digiline_conductor_tube_off_1",
|
||||
recipe = {"pipeworks:tube_1", "mesecons:mesecon", "digilines:wire_std_00000000"}
|
||||
})
|
||||
core.register_craft({
|
||||
minetest.register_craft({
|
||||
type = "shapeless",
|
||||
output = "pipeworks:mesecon_and_digiline_conductor_tube_off_1",
|
||||
recipe = {"pipeworks:conductor_tube_off_1", "digilines:wire_std_00000000"}
|
||||
})
|
||||
core.register_craft({
|
||||
minetest.register_craft({
|
||||
type = "shapeless",
|
||||
output = "pipeworks:mesecon_and_digiline_conductor_tube_off_1",
|
||||
recipe = {"pipeworks:digiline_conductor_tube_1", "mesecons:mesecon"}
|
||||
|
@ -1,15 +1,15 @@
|
||||
local S = core.get_translator("pipeworks")
|
||||
local S = minetest.get_translator("pipeworks")
|
||||
local fs_helpers = pipeworks.fs_helpers
|
||||
|
||||
if pipeworks.enable_mese_tube then
|
||||
local function update_formspec(pos)
|
||||
local meta = core.get_meta(pos)
|
||||
local meta = minetest.get_meta(pos)
|
||||
local old_formspec = meta:get_string("formspec")
|
||||
if string.find(old_formspec, "button1") then -- Old version
|
||||
local inv = meta:get_inventory()
|
||||
for i = 1, 6 do
|
||||
for _, stack in ipairs(inv:get_list("line"..i)) do
|
||||
core.add_item(pos, stack)
|
||||
minetest.add_item(pos, stack)
|
||||
end
|
||||
end
|
||||
end
|
||||
@ -24,7 +24,7 @@ if pipeworks.enable_mese_tube then
|
||||
)
|
||||
end
|
||||
local list_backgrounds = ""
|
||||
if core.get_modpath("i3") or core.get_modpath("mcl_formspec") then
|
||||
if minetest.get_modpath("i3") or minetest.get_modpath("mcl_formspec") then
|
||||
list_backgrounds = "style_type[box;colors=#666]"
|
||||
for i=0, 5 do
|
||||
for j=0, 5 do
|
||||
@ -83,13 +83,13 @@ if pipeworks.enable_mese_tube then
|
||||
tube = {can_go = function(pos, node, velocity, stack)
|
||||
local tbl, tbln = {}, 0
|
||||
local found, foundn = {}, 0
|
||||
local meta = core.get_meta(pos)
|
||||
local meta = minetest.get_meta(pos)
|
||||
local inv = meta:get_inventory()
|
||||
local name = stack:get_name()
|
||||
for i, vect in ipairs(pipeworks.meseadjlist) do
|
||||
local npos = vector.add(pos, vect)
|
||||
local node = core.get_node(npos)
|
||||
local reg_node = core.registered_nodes[node.name]
|
||||
local node = minetest.get_node(npos)
|
||||
local reg_node = minetest.registered_nodes[node.name]
|
||||
if meta:get_int("l"..i.."s") == 1 and reg_node then
|
||||
local tube_def = reg_node.tube
|
||||
if not tube_def or not tube_def.can_insert or
|
||||
@ -115,7 +115,7 @@ if pipeworks.enable_mese_tube then
|
||||
return (foundn > 0) and found or tbl
|
||||
end},
|
||||
on_construct = function(pos)
|
||||
local meta = core.get_meta(pos)
|
||||
local meta = minetest.get_meta(pos)
|
||||
local inv = meta:get_inventory()
|
||||
for i = 1, 6 do
|
||||
meta:set_int("l"..tostring(i).."s", 1)
|
||||
@ -126,7 +126,7 @@ if pipeworks.enable_mese_tube then
|
||||
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 = core.get_meta(pos)
|
||||
local meta = minetest.get_meta(pos)
|
||||
for i = 1, 6 do
|
||||
meta:set_int("l"..tostring(i).."s", 0)
|
||||
end
|
||||
@ -150,7 +150,7 @@ if pipeworks.enable_mese_tube then
|
||||
allow_metadata_inventory_put = function(pos, listname, index, stack, player)
|
||||
if not pipeworks.may_configure(pos, player) then return 0 end
|
||||
update_formspec(pos) -- For old tubes
|
||||
local inv = core.get_meta(pos):get_inventory()
|
||||
local inv = minetest.get_meta(pos):get_inventory()
|
||||
local stack_copy = ItemStack(stack)
|
||||
stack_copy:set_count(1)
|
||||
inv:set_stack(listname, index, stack_copy)
|
||||
@ -159,14 +159,14 @@ if pipeworks.enable_mese_tube then
|
||||
allow_metadata_inventory_take = function(pos, listname, index, stack, player)
|
||||
if not pipeworks.may_configure(pos, player) then return 0 end
|
||||
update_formspec(pos) -- For old tubes
|
||||
local inv = core.get_meta(pos):get_inventory()
|
||||
local inv = minetest.get_meta(pos):get_inventory()
|
||||
inv:set_stack(listname, index, ItemStack(""))
|
||||
return 0
|
||||
end,
|
||||
allow_metadata_inventory_move = function(pos, from_list, from_index, to_list, to_index, count, player)
|
||||
if not pipeworks.may_configure(pos, player) then return 0 end
|
||||
update_formspec(pos) -- For old tubes
|
||||
local inv = core.get_meta(pos):get_inventory()
|
||||
local inv = minetest.get_meta(pos):get_inventory()
|
||||
|
||||
if from_list:match("line%d") and to_list:match("line%d") then
|
||||
return count
|
||||
|
@ -1,15 +1,15 @@
|
||||
local S = core.get_translator("pipeworks")
|
||||
local S = minetest.get_translator("pipeworks")
|
||||
local fs_helpers = pipeworks.fs_helpers
|
||||
|
||||
if not pipeworks.enable_item_tags or not pipeworks.enable_tag_tube then return end
|
||||
|
||||
local help_text = core.formspec_escape(
|
||||
local help_text = minetest.formspec_escape(
|
||||
S("Separate multiple tags using commas.").."\n"..
|
||||
S("Use \"<none>\" to match items without tags.")
|
||||
)
|
||||
|
||||
local update_formspec = function(pos)
|
||||
local meta = core.get_meta(pos)
|
||||
local meta = minetest.get_meta(pos)
|
||||
local buttons_formspec = ""
|
||||
for i = 0, 5 do
|
||||
buttons_formspec = buttons_formspec .. fs_helpers.cycling_button(meta,
|
||||
@ -59,7 +59,7 @@ pipeworks.register_tube("pipeworks:tag_tube", {
|
||||
can_go = function(pos, node, velocity, stack, tags)
|
||||
local tbl, tbln = {}, 0
|
||||
local found, foundn = {}, 0
|
||||
local meta = core.get_meta(pos)
|
||||
local meta = minetest.get_meta(pos)
|
||||
local tag_hash = {}
|
||||
if #tags > 0 then
|
||||
for _,tag in ipairs(tags) do
|
||||
@ -70,8 +70,8 @@ pipeworks.register_tube("pipeworks:tag_tube", {
|
||||
end
|
||||
for i, vect in ipairs(pipeworks.meseadjlist) do
|
||||
local npos = vector.add(pos, vect)
|
||||
local node = core.get_node(npos)
|
||||
local reg_node = core.registered_nodes[node.name]
|
||||
local node = minetest.get_node(npos)
|
||||
local reg_node = minetest.registered_nodes[node.name]
|
||||
if meta:get_int("l" .. i .. "s") == 1 and reg_node then
|
||||
local tube_def = reg_node.tube
|
||||
if not tube_def or not tube_def.can_insert or
|
||||
@ -97,7 +97,7 @@ pipeworks.register_tube("pipeworks:tag_tube", {
|
||||
end
|
||||
},
|
||||
on_construct = function(pos)
|
||||
local meta = core.get_meta(pos)
|
||||
local meta = minetest.get_meta(pos)
|
||||
for i = 1, 6 do
|
||||
meta:set_int("l" .. tostring(i) .. "s", 1)
|
||||
end
|
||||
@ -106,7 +106,7 @@ pipeworks.register_tube("pipeworks:tag_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 = core.get_meta(pos)
|
||||
local meta = minetest.get_meta(pos)
|
||||
for i = 1, 6 do
|
||||
meta:set_int("l" .. tostring(i) .. "s", 0)
|
||||
end
|
||||
@ -120,7 +120,7 @@ pipeworks.register_tube("pipeworks:tag_tube", {
|
||||
return
|
||||
end
|
||||
|
||||
local meta = core.get_meta(pos)
|
||||
local meta = minetest.get_meta(pos)
|
||||
for i = 1, 6 do
|
||||
local field_name = "tags" .. tostring(i)
|
||||
if fields[field_name] then
|
||||
|
@ -1,11 +1,11 @@
|
||||
|
||||
local S = core.get_translator("pipeworks")
|
||||
local filename = core.get_worldpath().."/teleport_tubes" -- Only used for backward-compat
|
||||
local storage = core.get_mod_storage()
|
||||
local S = minetest.get_translator("pipeworks")
|
||||
local filename = minetest.get_worldpath().."/teleport_tubes" -- Only used for backward-compat
|
||||
local storage = minetest.get_mod_storage()
|
||||
|
||||
local enable_logging = core.settings:get_bool("pipeworks_log_teleport_tubes", false)
|
||||
local enable_logging = minetest.settings:get_bool("pipeworks_log_teleport_tubes", false)
|
||||
|
||||
local has_digilines = core.get_modpath("digilines")
|
||||
local has_digilines = minetest.get_modpath("digilines")
|
||||
|
||||
-- V1: Serialized text file indexed by vector position.
|
||||
-- V2: Serialized text file indexed by hash position.
|
||||
@ -17,7 +17,7 @@ local receiver_cache = {}
|
||||
|
||||
local function hash_pos(pos)
|
||||
vector.round(pos)
|
||||
return string.format("%.0f", core.hash_node_position(pos))
|
||||
return string.format("%.0f", minetest.hash_node_position(pos))
|
||||
end
|
||||
|
||||
local function serialize_tube(tube)
|
||||
@ -29,7 +29,7 @@ local function deserialize_tube(hash, str)
|
||||
local cr = tonumber(str:sub(1, 1))
|
||||
local channel = str:sub(3)
|
||||
if sep and cr and channel then
|
||||
local pos = core.get_position_from_hash(tonumber(hash))
|
||||
local pos = minetest.get_position_from_hash(tonumber(hash))
|
||||
return {x = pos.x, y = pos.y, z = pos.z, cr = cr, channel = channel}
|
||||
end
|
||||
end
|
||||
@ -62,7 +62,7 @@ local function migrate_tube_db()
|
||||
if storage:get_int("version") == 3 then
|
||||
for key, val in pairs(storage:to_table().fields) do
|
||||
if tonumber(key) then
|
||||
tube_db[key] = core.deserialize(val)
|
||||
tube_db[key] = minetest.deserialize(val)
|
||||
elseif key ~= "version" then
|
||||
error("Unknown field in teleport tube database: "..key)
|
||||
end
|
||||
@ -75,7 +75,7 @@ local function migrate_tube_db()
|
||||
local content = file:read("*all")
|
||||
io.close(file)
|
||||
if content and content ~= "" then
|
||||
tube_db = core.deserialize(content)
|
||||
tube_db = minetest.deserialize(content)
|
||||
end
|
||||
end
|
||||
local version = tube_db.version or 0
|
||||
@ -134,8 +134,8 @@ local function get_receivers(pos, channel)
|
||||
local receivers = {}
|
||||
for key, val in pairs(tube_db) do
|
||||
if val.cr == 1 and val.channel == channel and not vector.equals(val, pos) then
|
||||
core.load_area(val)
|
||||
local node_name = core.get_node(val).name
|
||||
minetest.load_area(val)
|
||||
local node_name = minetest.get_node(val).name
|
||||
if node_name:find("pipeworks:teleport_tube") then
|
||||
table.insert(receivers, val)
|
||||
else
|
||||
@ -148,7 +148,7 @@ local function get_receivers(pos, channel)
|
||||
return receivers
|
||||
end
|
||||
|
||||
local help_text = core.formspec_escape(
|
||||
local help_text = minetest.formspec_escape(
|
||||
S("Channels are public by default").."\n"..
|
||||
S("Use <player>:<channel> for fully private channels").."\n"..
|
||||
S("Use <player>;<channel> for private receivers")
|
||||
@ -187,7 +187,7 @@ local function update_meta(meta)
|
||||
end
|
||||
|
||||
local function update_tube(pos, channel, cr, player_name)
|
||||
local meta = core.get_meta(pos)
|
||||
local meta = minetest.get_meta(pos)
|
||||
if meta:get_string("channel") == channel and meta:get_int("can_receive") == cr then
|
||||
return
|
||||
end
|
||||
@ -200,11 +200,11 @@ local function update_tube(pos, channel, cr, player_name)
|
||||
local name, mode = channel:match("^([^:;]+)([:;])")
|
||||
if name and mode and name ~= player_name then
|
||||
if mode == ":" then
|
||||
core.chat_send_player(player_name,
|
||||
minetest.chat_send_player(player_name,
|
||||
S("Sorry, channel '@1' is reserved for exclusive use by @2", channel, name))
|
||||
return
|
||||
elseif mode == ";" and cr ~= 0 then
|
||||
core.chat_send_player(player_name,
|
||||
minetest.chat_send_player(player_name,
|
||||
S("Sorry, receiving from channel '@1' is reserved for @2", channel, name))
|
||||
return
|
||||
end
|
||||
@ -218,7 +218,7 @@ local function receive_fields(pos, _, fields, sender)
|
||||
if not fields.channel or not pipeworks.may_configure(pos, sender) then
|
||||
return
|
||||
end
|
||||
local meta = core.get_meta(pos)
|
||||
local meta = minetest.get_meta(pos)
|
||||
local channel = fields.channel:trim()
|
||||
local cr = meta:get_int("can_receive")
|
||||
if fields.cr_on then
|
||||
@ -237,7 +237,7 @@ local function can_go(pos, node, velocity, stack)
|
||||
velocity.x = 0
|
||||
velocity.y = 0
|
||||
velocity.z = 0
|
||||
local src_meta = core.get_meta(pos)
|
||||
local src_meta = minetest.get_meta(pos)
|
||||
local channel = src_meta:get_string("channel")
|
||||
if channel == "" then
|
||||
return {}
|
||||
@ -249,10 +249,10 @@ local function can_go(pos, node, velocity, stack)
|
||||
local target = receivers[math.random(1, #receivers)]
|
||||
if enable_logging then
|
||||
local src_owner = src_meta:get_string("owner")
|
||||
local dst_meta = core.get_meta(pos)
|
||||
local dst_meta = minetest.get_meta(pos)
|
||||
local dst_owner = dst_meta:get_string("owner")
|
||||
core.log("action", string.format("[pipeworks] %s teleported from %s (owner=%s) to %s (owner=%s) via %s",
|
||||
stack:to_string(), core.pos_to_string(pos), src_owner, core.pos_to_string(target), dst_owner, channel
|
||||
minetest.log("action", string.format("[pipeworks] %s teleported from %s (owner=%s) to %s (owner=%s) via %s",
|
||||
stack:to_string(), minetest.pos_to_string(pos), src_owner, minetest.pos_to_string(target), dst_owner, channel
|
||||
))
|
||||
end
|
||||
pos.x = target.x
|
||||
@ -262,9 +262,9 @@ local function can_go(pos, node, velocity, stack)
|
||||
end
|
||||
|
||||
local function repair_tube(pos, node)
|
||||
core.swap_node(pos, {name = node.name, param2 = node.param2})
|
||||
minetest.swap_node(pos, {name = node.name, param2 = node.param2})
|
||||
pipeworks.scan_for_tube_objects(pos)
|
||||
local meta = core.get_meta(pos)
|
||||
local meta = minetest.get_meta(pos)
|
||||
local channel = meta:get_string("channel")
|
||||
if channel ~= "" then
|
||||
set_tube(pos, channel, meta:get_int("can_receive"))
|
||||
@ -273,7 +273,7 @@ local function repair_tube(pos, node)
|
||||
end
|
||||
|
||||
local function digiline_action(pos, _, digiline_channel, msg)
|
||||
local meta = core.get_meta(pos)
|
||||
local meta = minetest.get_meta(pos)
|
||||
if digiline_channel ~= meta:get_string("digiline_channel") then
|
||||
return
|
||||
end
|
||||
@ -304,7 +304,7 @@ local def = {
|
||||
on_repair = repair_tube,
|
||||
},
|
||||
on_construct = function(pos)
|
||||
local meta = core.get_meta(pos)
|
||||
local meta = minetest.get_meta(pos)
|
||||
meta:set_int("can_receive", 1) -- Enabled by default
|
||||
update_meta(meta)
|
||||
end,
|
||||
@ -315,10 +315,10 @@ local def = {
|
||||
if has_digilines then
|
||||
def.after_place_node = function(pos, placer)
|
||||
-- Set owner for digilines
|
||||
core.get_meta(pos):set_string("owner", placer:get_player_name())
|
||||
minetest.get_meta(pos):set_string("owner", placer:get_player_name())
|
||||
pipeworks.after_place(pos)
|
||||
end
|
||||
def.digilines = {
|
||||
def.digiline = {
|
||||
receptor = {
|
||||
rules = pipeworks.digilines_rules,
|
||||
},
|
||||
@ -339,12 +339,12 @@ pipeworks.register_tube("pipeworks:teleport_tube", {
|
||||
node_def = def,
|
||||
})
|
||||
|
||||
if core.get_modpath("mesecons_mvps") then
|
||||
if minetest.get_modpath("mesecons_mvps") then
|
||||
-- Update tubes when moved by pistons
|
||||
mesecon.register_on_mvps_move(function(moved_nodes)
|
||||
for _, n in ipairs(moved_nodes) do
|
||||
if n.node.name:find("pipeworks:teleport_tube") then
|
||||
local meta = core.get_meta(n.pos)
|
||||
local meta = minetest.get_meta(n.pos)
|
||||
set_tube(n.pos, meta:get_string("channel"), meta:get_int("can_receive"))
|
||||
end
|
||||
end
|
||||
|
@ -1,10 +1,8 @@
|
||||
|
||||
local S = core.get_translator("pipeworks")
|
||||
local S = minetest.get_translator("pipeworks")
|
||||
|
||||
local has_vislib = core.get_modpath("vizlib")
|
||||
|
||||
local enable_max = core.settings:get_bool("pipeworks_enable_items_per_tube_limit", true)
|
||||
local max_items = tonumber(core.settings:get("pipeworks_max_items_per_tube")) or 30
|
||||
local enable_max = minetest.settings:get_bool("pipeworks_enable_items_per_tube_limit", true)
|
||||
local max_items = tonumber(minetest.settings:get("pipeworks_max_items_per_tube")) or 30
|
||||
max_items = math.ceil(max_items / 2) -- Limit vacuuming to half the max limit
|
||||
|
||||
local function vacuum(pos, radius)
|
||||
@ -12,7 +10,7 @@ local function vacuum(pos, radius)
|
||||
local min_pos = vector.subtract(pos, radius)
|
||||
local max_pos = vector.add(pos, radius)
|
||||
local count = 0
|
||||
for _, obj in pairs(core.get_objects_in_area(min_pos, max_pos)) do
|
||||
for _, obj in pairs(minetest.get_objects_in_area(min_pos, max_pos)) do
|
||||
local entity = obj:get_luaentity()
|
||||
if entity and entity.name == "__builtin:item" then
|
||||
if entity.itemstring ~= "" then
|
||||
@ -29,26 +27,17 @@ local function vacuum(pos, radius)
|
||||
end
|
||||
|
||||
local function set_timer(pos)
|
||||
local timer = core.get_node_timer(pos)
|
||||
local timer = minetest.get_node_timer(pos)
|
||||
-- Randomize timer so not all tubes vacuum at the same time
|
||||
timer:start(math.random(10, 20) * 0.1)
|
||||
end
|
||||
|
||||
local function repair_tube(pos, was_node)
|
||||
core.swap_node(pos, {name = was_node.name, param2 = was_node.param2})
|
||||
minetest.swap_node(pos, {name = was_node.name, param2 = was_node.param2})
|
||||
pipeworks.scan_for_tube_objects(pos)
|
||||
set_timer(pos)
|
||||
end
|
||||
|
||||
local function show_area(pos, node, player)
|
||||
if not player or player:get_wielded_item():get_name() ~= "" then
|
||||
-- Only show area when using an empty hand
|
||||
return
|
||||
end
|
||||
local radius = tonumber(core.get_meta(pos):get("dist")) or 2
|
||||
vizlib.draw_cube(pos, radius + 0.5, {player = player})
|
||||
end
|
||||
|
||||
if pipeworks.enable_sand_tube then
|
||||
pipeworks.register_tube("pipeworks:sand_tube", {
|
||||
description = S("Vacuuming Pneumatic Tube Segment"),
|
||||
@ -67,7 +56,6 @@ if pipeworks.enable_sand_tube then
|
||||
vacuum(pos, 2)
|
||||
set_timer(pos)
|
||||
end,
|
||||
on_punch = has_vislib and show_area or nil,
|
||||
},
|
||||
})
|
||||
end
|
||||
@ -93,14 +81,14 @@ if pipeworks.enable_mese_sand_tube then
|
||||
on_repair = repair_tube,
|
||||
},
|
||||
on_construct = function(pos)
|
||||
local meta = core.get_meta(pos)
|
||||
local meta = minetest.get_meta(pos)
|
||||
meta:set_int("dist", 2)
|
||||
meta:set_string("formspec", formspec)
|
||||
meta:set_string("infotext", S("Adjustable Vacuuming Tube (@1m)", 2))
|
||||
set_timer(pos)
|
||||
end,
|
||||
on_timer = function(pos, elapsed)
|
||||
local radius = core.get_meta(pos):get_int("dist")
|
||||
local radius = minetest.get_meta(pos):get_int("dist")
|
||||
vacuum(pos, radius)
|
||||
set_timer(pos)
|
||||
end,
|
||||
@ -108,17 +96,16 @@ if pipeworks.enable_mese_sand_tube then
|
||||
if not fields.dist or not pipeworks.may_configure(pos, sender) then
|
||||
return
|
||||
end
|
||||
local meta = core.get_meta(pos)
|
||||
local meta = minetest.get_meta(pos)
|
||||
local dist = math.min(math.max(tonumber(fields.dist) or 0, 0), 8)
|
||||
meta:set_int("dist", dist)
|
||||
meta:set_string("infotext", S("Adjustable Vacuuming Tube (@1m)", dist))
|
||||
end,
|
||||
on_punch = has_vislib and show_area or nil,
|
||||
},
|
||||
})
|
||||
end
|
||||
|
||||
core.register_lbm({
|
||||
minetest.register_lbm({
|
||||
label = "Vacuum tube node timer starter",
|
||||
name = "pipeworks:vacuum_tube_start",
|
||||
nodenames = {"group:vacuum_tube"},
|
||||
|
654
wielder.lua
654
wielder.lua
@ -1,208 +1,255 @@
|
||||
local S = core.get_translator("pipeworks")
|
||||
local has_digilines = core.get_modpath("digilines")
|
||||
local S = minetest.get_translator("pipeworks")
|
||||
local assumed_eye_pos = vector.new(0, 1.5, 0)
|
||||
|
||||
local function set_wielder_formspec(def, meta)
|
||||
local width, height = def.wield_inv.width, def.wield_inv.height
|
||||
local offset = 5.22 - width * 0.625
|
||||
local size = "10.2,"..(6.5 + height * 1.25 + (has_digilines and 1.25 or 0))
|
||||
local list_bg = ""
|
||||
if core.get_modpath("i3") or core.get_modpath("mcl_formspec") then
|
||||
list_bg = "style_type[box;colors=#666]"
|
||||
for i=0, height-1 do
|
||||
for j=0, width-1 do
|
||||
list_bg = list_bg.."box["..offset+(i*1.25)..","..1.25+(j*1.25)..";1,1;]"
|
||||
end
|
||||
end
|
||||
end
|
||||
local inv_offset = 1.5 + height * 1.25
|
||||
local fs = "formspec_version[2]size["..size.."]"..
|
||||
pipeworks.fs_helpers.get_prepends(size)..list_bg..
|
||||
"item_image[0.5,0.3;1,1;"..def.name.."_off]"..
|
||||
"label[1.75,0.8;"..core.formspec_escape(def.description).."]"..
|
||||
"list[context;"..def.wield_inv.name..";"..offset..",1.25;"..width..","..height..";]"
|
||||
if has_digilines then
|
||||
fs = fs.."field[1.5,"..inv_offset..";5,0.8;channel;"..S("Channel")..";${channel}]"..
|
||||
"button_exit[6.5,"..inv_offset..";2,0.8;save;"..S("Save").."]"..
|
||||
pipeworks.fs_helpers.get_inv(inv_offset + 1.25).."listring[]"
|
||||
else
|
||||
fs = fs..pipeworks.fs_helpers.get_inv(inv_offset).."listring[]"
|
||||
end
|
||||
meta:set_string("formspec", fs)
|
||||
meta:set_string("infotext", def.description)
|
||||
local function delay(x)
|
||||
return (function() return x end)
|
||||
end
|
||||
|
||||
local function wielder_action(def, pos, node, index)
|
||||
local meta = core.get_meta(pos)
|
||||
local inv = meta:get_inventory()
|
||||
local list = inv:get_list(def.wield_inv.name)
|
||||
local wield_index
|
||||
if index then
|
||||
if list[index] and (def.wield_hand or not list[index]:is_empty()) then
|
||||
wield_index = index
|
||||
end
|
||||
else
|
||||
for i, stack in ipairs(list) do
|
||||
if not stack:is_empty() then
|
||||
wield_index = i
|
||||
break
|
||||
local function set_wielder_formspec(data, meta)
|
||||
local size = "10.2,"..(7+data.wield_inv_height)
|
||||
local list_background = ""
|
||||
if minetest.get_modpath("i3") or minetest.get_modpath("mcl_formspec") then
|
||||
list_background = "style_type[box;colors=#666]"
|
||||
for i=0, data.wield_inv_height-1 do
|
||||
for j=0, data.wield_inv_width-1 do
|
||||
list_background = list_background .. "box[".. ((10-data.wield_inv_width)*0.5)+(i*1.25) ..",".. 1+(j*1.25) ..";1,1;]"
|
||||
end
|
||||
end
|
||||
end
|
||||
if not wield_index and not def.wield_hand then
|
||||
return
|
||||
meta:set_string("formspec",
|
||||
"formspec_version[2]" ..
|
||||
"size["..size.."]"..
|
||||
pipeworks.fs_helpers.get_prepends(size)..
|
||||
"item_image[0.5,0.5;1,1;"..data.name_base.."_off]"..
|
||||
"label[1.5,1;"..minetest.formspec_escape(data.description).."]"..
|
||||
list_background ..
|
||||
"list[context;"..minetest.formspec_escape(data.wield_inv_name)..";"..((10-data.wield_inv_width)*0.5)..",1;"..data.wield_inv_width..","..data.wield_inv_height..";]"..
|
||||
pipeworks.fs_helpers.get_inv((2+data.wield_inv_height)) ..
|
||||
"listring[context;"..minetest.formspec_escape(data.wield_inv_name).."]" ..
|
||||
"listring[current_player;main]"
|
||||
)
|
||||
meta:set_string("infotext", data.description)
|
||||
end
|
||||
|
||||
local can_tool_dig_node = function(nodename, toolcaps, toolname)
|
||||
--pipeworks.logger("can_tool_dig_node() STUB nodename="..tostring(nodename).." toolname="..tostring(toolname).." toolcaps: "..dump(toolcaps))
|
||||
-- brief documentation of minetest.get_dig_params() as it's not yet documented in lua_api.txt:
|
||||
-- takes two arguments, a node's block groups and a tool's capabilities,
|
||||
-- both as they appear in their respective definitions.
|
||||
-- returns a table with the following fields:
|
||||
-- diggable: boolean, can this tool dig this node at all
|
||||
-- time: float, time needed to dig with this tool
|
||||
-- wear: int, number of wear points to inflict on the item
|
||||
local nodedef = minetest.registered_nodes[nodename]
|
||||
-- don't explode due to nil def in event of unknown node!
|
||||
if (nodedef == nil) then return false end
|
||||
|
||||
local nodegroups = nodedef.groups
|
||||
local diggable = minetest.get_dig_params(nodegroups, toolcaps).diggable
|
||||
if not diggable then
|
||||
-- a pickaxe can't actually dig leaves based on it's groups alone,
|
||||
-- but a player holding one can - the game seems to fall back to the hand.
|
||||
-- fall back to checking the hand's properties if the tool isn't the correct one.
|
||||
local hand_caps = minetest.registered_items[""].tool_capabilities
|
||||
diggable = minetest.get_dig_params(nodegroups, hand_caps).diggable
|
||||
end
|
||||
local dir = core.facedir_to_dir(node.param2)
|
||||
local fakeplayer = fakelib.create_player({
|
||||
name = meta:get_string("owner"),
|
||||
direction = vector.multiply(dir, -1),
|
||||
position = pos,
|
||||
return diggable
|
||||
end
|
||||
|
||||
local function wielder_on(data, wielder_pos, wielder_node)
|
||||
data.fixup_node(wielder_pos, wielder_node)
|
||||
if wielder_node.name ~= data.name_base.."_off" then return end
|
||||
wielder_node.name = data.name_base.."_on"
|
||||
minetest.swap_node(wielder_pos, wielder_node)
|
||||
minetest.check_for_falling(wielder_pos)
|
||||
local wielder_meta = minetest.get_meta(wielder_pos)
|
||||
local inv = wielder_meta:get_inventory()
|
||||
local wield_inv_name = data.wield_inv_name
|
||||
local wieldindex
|
||||
for i, stack in ipairs(inv:get_list(wield_inv_name)) do
|
||||
if not stack:is_empty() then
|
||||
wieldindex = i
|
||||
break
|
||||
end
|
||||
end
|
||||
if not wieldindex then
|
||||
if not data.ghost_inv_name then return end
|
||||
wield_inv_name = data.ghost_inv_name
|
||||
inv:set_stack(wield_inv_name, 1, ItemStack(data.ghost_tool))
|
||||
wieldindex = 1
|
||||
end
|
||||
local dir = minetest.facedir_to_dir(wielder_node.param2)
|
||||
-- under/above is currently intentionally left switched
|
||||
-- even though this causes some problems with deployers and e.g. seeds
|
||||
-- as there are some issues related to nodebreakers otherwise breaking 2 nodes afar.
|
||||
-- solidity would have to be checked as well,
|
||||
-- but would open a whole can of worms related to difference in nodebreaker/deployer behavior
|
||||
-- and the problems of wielders acting on themselves if below is solid
|
||||
local under_pos = vector.subtract(wielder_pos, dir)
|
||||
local above_pos = vector.subtract(under_pos, dir)
|
||||
local pitch
|
||||
local yaw
|
||||
if dir.z < 0 then
|
||||
yaw = 0
|
||||
pitch = 0
|
||||
elseif dir.z > 0 then
|
||||
yaw = math.pi
|
||||
pitch = 0
|
||||
elseif dir.x < 0 then
|
||||
yaw = 3*math.pi/2
|
||||
pitch = 0
|
||||
elseif dir.x > 0 then
|
||||
yaw = math.pi/2
|
||||
pitch = 0
|
||||
elseif dir.y > 0 then
|
||||
yaw = 0
|
||||
pitch = -math.pi/2
|
||||
else
|
||||
yaw = 0
|
||||
pitch = math.pi/2
|
||||
end
|
||||
local virtplayer = pipeworks.create_fake_player({
|
||||
name = data.masquerade_as_owner and wielder_meta:get_string("owner")
|
||||
or ":pipeworks:" .. minetest.pos_to_string(wielder_pos),
|
||||
formspec = wielder_meta:get_string("formspec"),
|
||||
look_dir = vector.multiply(dir, -1),
|
||||
look_pitch = pitch,
|
||||
look_yaw = yaw,
|
||||
sneak = data.sneak,
|
||||
position = vector.subtract(wielder_pos, assumed_eye_pos),
|
||||
inventory = inv,
|
||||
wield_index = wield_index or 1,
|
||||
wield_list = def.wield_inv.name,
|
||||
wield_index = wieldindex,
|
||||
wield_list = wield_inv_name
|
||||
})
|
||||
-- Under and above positions are intentionally switched.
|
||||
local pointed = {
|
||||
type = "node",
|
||||
under = vector.subtract(pos, dir),
|
||||
above = vector.subtract(pos, vector.multiply(dir, 2)),
|
||||
}
|
||||
def.action(fakeplayer, pointed)
|
||||
if def.eject_drops then
|
||||
|
||||
local pointed_thing = { type="node", under=under_pos, above=above_pos }
|
||||
data.act(virtplayer, pointed_thing)
|
||||
if data.eject_drops then
|
||||
for i, stack in ipairs(inv:get_list("main")) do
|
||||
if not stack:is_empty() then
|
||||
pipeworks.tube_inject_item(pos, pos, dir, stack)
|
||||
pipeworks.tube_inject_item(wielder_pos, wielder_pos, dir, stack)
|
||||
inv:set_stack("main", i, ItemStack(""))
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
local function wielder_on(def, pos, node)
|
||||
if node.name ~= def.name.."_off" then
|
||||
return
|
||||
end
|
||||
node.name = def.name.."_on"
|
||||
core.swap_node(pos, node)
|
||||
wielder_action(def, pos, node)
|
||||
end
|
||||
|
||||
local function wielder_off(def, pos, node)
|
||||
if node.name == def.name.."_on" then
|
||||
node.name = def.name.."_off"
|
||||
core.swap_node(pos, node)
|
||||
local function wielder_off(data, pos, node)
|
||||
if node.name == data.name_base.."_on" then
|
||||
node.name = data.name_base.."_off"
|
||||
minetest.swap_node(pos, node)
|
||||
minetest.check_for_falling(pos)
|
||||
end
|
||||
end
|
||||
|
||||
local function wielder_digiline_action(def, pos, channel, msg)
|
||||
local meta = core.get_meta(pos)
|
||||
local set_channel = meta:get_string("channel")
|
||||
if channel ~= set_channel then
|
||||
return
|
||||
end
|
||||
if type(msg) ~= "table" then
|
||||
if type(msg) == "string" then
|
||||
if msg:sub(1, 8) == "activate" then
|
||||
msg = {command = "activate", slot = tonumber(msg:sub(9))}
|
||||
end
|
||||
else
|
||||
return
|
||||
local function register_wielder(data)
|
||||
data.fixup_node = data.fixup_node or function (pos, node) end
|
||||
data.fixup_oldmetadata = data.fixup_oldmetadata or function (m) return m end
|
||||
for _, state in ipairs({ "off", "on" }) do
|
||||
local groups = { snappy=2, choppy=2, oddly_breakable_by_hand=2, mesecon=2, tubedevice=1, tubedevice_receiver=1, axey=1, handy=1, pickaxey=1 }
|
||||
if state == "on" then groups.not_in_creative_inventory = 1 end
|
||||
local tile_images = {}
|
||||
for _, face in ipairs({ "top", "bottom", "side2", "side1", "back", "front" }) do
|
||||
table.insert(tile_images, data.texture_base.."_"..face..(data.texture_stateful[face] and "_"..state or "")..".png")
|
||||
end
|
||||
end
|
||||
if msg.command == "activate" then
|
||||
local node = core.get_node(pos)
|
||||
local index = type(msg.slot) == "number" and msg.slot or nil
|
||||
wielder_action(def, pos, node, index)
|
||||
end
|
||||
end
|
||||
|
||||
function pipeworks.register_wielder(def)
|
||||
for _,state in ipairs({"off", "on"}) do
|
||||
local groups = {
|
||||
snappy = 2, choppy = 2, oddly_breakable_by_hand = 2,
|
||||
mesecon = 2, tubedevice = 1, tubedevice_receiver = 1,
|
||||
axey = 1, handy = 1, pickaxey = 1,
|
||||
not_in_creative_inventory = state == "on" and 1 or nil
|
||||
}
|
||||
core.register_node(def.name.."_"..state, {
|
||||
description = def.description,
|
||||
tiles = def.tiles[state],
|
||||
paramtype2 = "facedir",
|
||||
groups = groups,
|
||||
is_ground_content = false,
|
||||
_mcl_hardness = 0.6,
|
||||
_sound_def = {
|
||||
key = "node_sound_stone_defaults",
|
||||
},
|
||||
drop = def.name.."_off",
|
||||
minetest.register_node(data.name_base.."_"..state, {
|
||||
description = data.description,
|
||||
tiles = tile_images,
|
||||
mesecons = {
|
||||
effector = {
|
||||
rules = pipeworks.rules_all,
|
||||
action_on = function(pos, node)
|
||||
wielder_on(def, pos, node)
|
||||
action_on = function (pos, node)
|
||||
wielder_on(data, pos, node)
|
||||
end,
|
||||
action_off = function(pos, node)
|
||||
wielder_off(def, pos, node)
|
||||
end,
|
||||
},
|
||||
},
|
||||
digilines = {
|
||||
receptor = {},
|
||||
effector = {
|
||||
action = function(pos, _, channel, msg)
|
||||
wielder_digiline_action(def, pos, channel, msg)
|
||||
action_off = function (pos, node)
|
||||
wielder_off(data, pos, node)
|
||||
end,
|
||||
},
|
||||
},
|
||||
tube = {
|
||||
can_insert = function(pos, node, stack, direction)
|
||||
if def.eject_drops then
|
||||
-- Prevent ejected items from being inserted
|
||||
local dir = vector.multiply(core.facedir_to_dir(node.param2), -1)
|
||||
if vector.equals(direction, dir) then
|
||||
can_insert = function(pos, node, stack, tubedir)
|
||||
if not data.tube_permit_anteroposterior_insert then
|
||||
local nodedir = minetest.facedir_to_dir(node.param2)
|
||||
if vector.equals(tubedir, nodedir) or vector.equals(tubedir, vector.multiply(nodedir, -1)) then
|
||||
return false
|
||||
end
|
||||
end
|
||||
local inv = core.get_meta(pos):get_inventory()
|
||||
return inv:room_for_item(def.wield_inv.name, stack)
|
||||
local meta = minetest.get_meta(pos)
|
||||
local inv = meta:get_inventory()
|
||||
return inv:room_for_item(data.wield_inv_name, stack)
|
||||
end,
|
||||
insert_object = function(pos, node, stack)
|
||||
local inv = core.get_meta(pos):get_inventory()
|
||||
return inv:add_item(def.wield_inv.name, stack)
|
||||
insert_object = function(pos, node, stack, tubedir)
|
||||
if not data.tube_permit_anteroposterior_insert then
|
||||
local nodedir = minetest.facedir_to_dir(node.param2)
|
||||
if vector.equals(tubedir, nodedir) or vector.equals(tubedir, vector.multiply(nodedir, -1)) then
|
||||
return stack
|
||||
end
|
||||
end
|
||||
local meta = minetest.get_meta(pos)
|
||||
local inv = meta:get_inventory()
|
||||
return inv:add_item(data.wield_inv_name, stack)
|
||||
end,
|
||||
input_inventory = def.wield_inv.name,
|
||||
connect_sides = def.connect_sides,
|
||||
can_remove = function(pos, node, stack)
|
||||
input_inventory = data.wield_inv_name,
|
||||
connect_sides = data.tube_connect_sides,
|
||||
can_remove = function(pos, node, stack, tubedir)
|
||||
return stack:get_count()
|
||||
end,
|
||||
},
|
||||
is_ground_content = false,
|
||||
paramtype2 = "facedir",
|
||||
tubelike = 1,
|
||||
groups = groups,
|
||||
_mcl_hardness=0.6,
|
||||
_sound_def = {
|
||||
key = "node_sound_stone_defaults",
|
||||
},
|
||||
drop = data.name_base.."_off",
|
||||
on_construct = function(pos)
|
||||
local meta = core.get_meta(pos)
|
||||
local meta = minetest.get_meta(pos)
|
||||
set_wielder_formspec(data, meta)
|
||||
local inv = meta:get_inventory()
|
||||
inv:set_size(def.wield_inv.name, def.wield_inv.width * def.wield_inv.height)
|
||||
if def.eject_drops then
|
||||
inv:set_size("main", 32)
|
||||
inv:set_size(data.wield_inv_name, data.wield_inv_width*data.wield_inv_height)
|
||||
if data.ghost_inv_name then
|
||||
inv:set_size(data.ghost_inv_name, 1)
|
||||
end
|
||||
if data.eject_drops then
|
||||
inv:set_size("main", 100)
|
||||
end
|
||||
set_wielder_formspec(def, meta)
|
||||
end,
|
||||
after_place_node = function(pos, placer)
|
||||
after_place_node = function (pos, placer)
|
||||
pipeworks.scan_for_tube_objects(pos)
|
||||
if not placer then
|
||||
return
|
||||
local placer_pos = placer:get_pos()
|
||||
if placer_pos and placer:is_player() then placer_pos = vector.add(placer_pos, assumed_eye_pos) end
|
||||
if placer_pos then
|
||||
local dir = vector.subtract(pos, placer_pos)
|
||||
local node = minetest.get_node(pos)
|
||||
node.param2 = minetest.dir_to_facedir(dir, true)
|
||||
minetest.set_node(pos, node)
|
||||
end
|
||||
local node = core.get_node(pos)
|
||||
node.param2 = core.dir_to_facedir(placer:get_look_dir(), true)
|
||||
core.set_node(pos, node)
|
||||
core.get_meta(pos):set_string("owner", placer:get_player_name())
|
||||
minetest.get_meta(pos):set_string("owner", placer:get_player_name())
|
||||
end,
|
||||
can_dig = (data.can_dig_nonempty_wield_inv and delay(true) or function(pos, player)
|
||||
local meta = minetest.get_meta(pos)
|
||||
local inv = meta:get_inventory()
|
||||
return inv:is_empty(data.wield_inv_name)
|
||||
end),
|
||||
after_dig_node = function(pos, oldnode, oldmetadata, digger)
|
||||
for _,stack in ipairs(oldmetadata.inventory[def.wield_inv.name] or {}) do
|
||||
-- The legacy-node fixup is done here in a
|
||||
-- different form from the standard fixup,
|
||||
-- rather than relying on a standard fixup
|
||||
-- in an on_dig callback, because some
|
||||
-- non-standard diggers (such as technic's
|
||||
-- mining drill) don't respect on_dig.
|
||||
oldmetadata = data.fixup_oldmetadata(oldmetadata)
|
||||
for _, stack in ipairs(oldmetadata.inventory[data.wield_inv_name] or {}) do
|
||||
if not stack:is_empty() then
|
||||
core.add_item(pos, stack)
|
||||
minetest.add_item(pos, stack)
|
||||
end
|
||||
end
|
||||
pipeworks.scan_for_tube_objects(pos)
|
||||
end,
|
||||
on_rotate = pipeworks.on_rotate,
|
||||
on_punch = data.fixup_node,
|
||||
allow_metadata_inventory_put = function(pos, listname, index, stack, player)
|
||||
if not pipeworks.may_configure(pos, player) then return 0 end
|
||||
return stack:get_count()
|
||||
@ -214,141 +261,212 @@ function pipeworks.register_wielder(def)
|
||||
allow_metadata_inventory_move = function(pos, from_list, from_index, to_list, to_index, count, player)
|
||||
if not pipeworks.may_configure(pos, player) then return 0 end
|
||||
return count
|
||||
end,
|
||||
on_receive_fields = function(pos, _, fields, sender)
|
||||
if not fields.channel or not pipeworks.may_configure(pos, sender) then
|
||||
return
|
||||
end
|
||||
core.get_meta(pos):set_string("channel", fields.channel)
|
||||
end,
|
||||
end
|
||||
})
|
||||
end
|
||||
table.insert(pipeworks.ui_cat_tube_list, def.name.."_off")
|
||||
end
|
||||
|
||||
local function get_tiles(name, stateful)
|
||||
local tiles = {on = {}, off = {}}
|
||||
for _,state in ipairs({"off", "on"}) do
|
||||
for _,side in ipairs({"top", "bottom", "side2", "side1", "back", "front"}) do
|
||||
local suffix = stateful[side] and "_"..state or ""
|
||||
table.insert(tiles[state], "pipeworks_"..name.."_"..side..suffix..".png")
|
||||
end
|
||||
end
|
||||
return tiles
|
||||
end
|
||||
|
||||
if pipeworks.enable_node_breaker then
|
||||
pipeworks.register_wielder({
|
||||
name = "pipeworks:nodebreaker",
|
||||
local data
|
||||
-- see after end of data table for other use of these variables
|
||||
local name_base = "pipeworks:nodebreaker"
|
||||
local wield_inv_name = "pick"
|
||||
data = {
|
||||
name_base = name_base,
|
||||
description = S("Node Breaker"),
|
||||
tiles = get_tiles("nodebreaker", {top = 1, bottom = 1, side2 = 1, side1 = 1, front = 1}),
|
||||
connect_sides = {top = 1, bottom = 1, left = 1, right = 1, back = 1},
|
||||
wield_inv = {name = "pick", width = 1, height = 1},
|
||||
wield_hand = true,
|
||||
eject_drops = true,
|
||||
action = function(fakeplayer, pointed)
|
||||
local stack = fakeplayer:get_wielded_item()
|
||||
local old_stack = ItemStack(stack)
|
||||
local item_def = core.registered_items[stack:get_name()]
|
||||
if item_def.on_use then
|
||||
stack = item_def.on_use(stack, fakeplayer, pointed) or stack
|
||||
fakeplayer:set_wielded_item(stack)
|
||||
else
|
||||
local node = core.get_node(pointed.under)
|
||||
local node_def = core.registered_nodes[node.name]
|
||||
if not node_def or not node_def.on_dig then
|
||||
return
|
||||
end
|
||||
-- Check if the tool can dig the node
|
||||
local tool = stack:get_tool_capabilities()
|
||||
if not core.get_dig_params(node_def.groups, tool).diggable then
|
||||
-- Try using hand if tool can't dig the node
|
||||
local hand = ItemStack():get_tool_capabilities()
|
||||
if not core.get_dig_params(node_def.groups, hand).diggable then
|
||||
return
|
||||
end
|
||||
end
|
||||
-- This must only check for false, because `on_dig` returning nil is the same as returning true.
|
||||
if node_def.on_dig(pointed.under, node, fakeplayer) == false then
|
||||
return
|
||||
end
|
||||
local sound = node_def.sounds and node_def.sounds.dug
|
||||
if sound then
|
||||
core.sound_play(sound, {pos = pointed.under}, true)
|
||||
end
|
||||
stack = fakeplayer:get_wielded_item()
|
||||
texture_base = "pipeworks_nodebreaker",
|
||||
texture_stateful = { top = true, bottom = true, side2 = true, side1 = true, front = true },
|
||||
tube_connect_sides = { top=1, bottom=1, left=1, right=1, back=1 },
|
||||
tube_permit_anteroposterior_insert = false,
|
||||
wield_inv_name = wield_inv_name,
|
||||
wield_inv_width = 1,
|
||||
wield_inv_height = 1,
|
||||
can_dig_nonempty_wield_inv = true,
|
||||
ghost_inv_name = "ghost_pick",
|
||||
ghost_tool = ":", -- hand by default
|
||||
fixup_node = function (pos, node)
|
||||
local meta = minetest.get_meta(pos)
|
||||
local inv = meta:get_inventory()
|
||||
-- Node breakers predating the visible pick slot
|
||||
-- may have been partially updated. This code
|
||||
-- fully updates them. Some have been observed
|
||||
-- to have no pick slot at all; first add one.
|
||||
if inv:get_size("pick") ~= 1 then
|
||||
inv:set_size("pick", 1)
|
||||
end
|
||||
if stack:get_name() == old_stack:get_name() then
|
||||
-- Don't mechanically wear out tool
|
||||
if stack:get_wear() ~= old_stack:get_wear() and stack:get_count() == old_stack:get_count()
|
||||
and (item_def.wear_represents == nil or item_def.wear_represents == "mechanical_wear") then
|
||||
fakeplayer:set_wielded_item(old_stack)
|
||||
end
|
||||
elseif not stack:is_empty() then
|
||||
-- Tool got replaced by something else, treat it as a drop.
|
||||
fakeplayer:get_inventory():add_item("main", stack)
|
||||
fakeplayer:set_wielded_item("")
|
||||
-- Originally, they had a ghost pick in a "pick"
|
||||
-- inventory, no other inventory, and no form.
|
||||
-- The partial update of early with-form node
|
||||
-- breaker code gives them "ghost_pick" and "main"
|
||||
-- inventories, but leaves the old ghost pick in
|
||||
-- the "pick" inventory, and doesn't add a form.
|
||||
-- First perform that partial update.
|
||||
if inv:get_size("ghost_pick") ~= 1 then
|
||||
inv:set_size("ghost_pick", 1)
|
||||
inv:set_size("main", 100)
|
||||
end
|
||||
-- If the node breaker predates the visible pick
|
||||
-- slot, which we can detect by it not having a
|
||||
-- form, then the pick slot needs to be cleared
|
||||
-- of the old ghost pick.
|
||||
if (meta:get_string("formspec") or "") == "" then
|
||||
inv:set_stack("pick", 1, ItemStack(""))
|
||||
end
|
||||
-- Finally, unconditionally set the formspec
|
||||
-- and infotext. This not only makes the
|
||||
-- pick slot visible for node breakers where
|
||||
-- it wasn't before; it also updates the form
|
||||
-- for node breakers that had an older version
|
||||
-- of the form, and sets infotext where it was
|
||||
-- missing for early with-form node breakers.
|
||||
set_wielder_formspec(data, meta)
|
||||
end,
|
||||
fixup_oldmetadata = function (oldmetadata)
|
||||
-- Node breakers predating the visible pick slot,
|
||||
-- with node form, kept their ghost pick in an
|
||||
-- inventory named "pick", the same name as the
|
||||
-- later visible pick slot. The pick must be
|
||||
-- removed to avoid spilling it.
|
||||
if not oldmetadata.fields.formspec then
|
||||
return { inventory = { pick = {} }, fields = oldmetadata.fields }
|
||||
else
|
||||
return oldmetadata
|
||||
end
|
||||
end,
|
||||
masquerade_as_owner = true,
|
||||
sneak = false,
|
||||
act = function(virtplayer, pointed_thing)
|
||||
if minetest.is_protected(vector.add(virtplayer:get_pos(), assumed_eye_pos), virtplayer:get_player_name()) then
|
||||
return
|
||||
end
|
||||
|
||||
--local dname = "nodebreaker.act() "
|
||||
local wieldstack = virtplayer:get_wielded_item()
|
||||
local oldwieldstack = ItemStack(wieldstack)
|
||||
local on_use = (minetest.registered_items[wieldstack:get_name()] or {}).on_use
|
||||
if on_use then
|
||||
--pipeworks.logger(dname.."invoking on_use "..tostring(on_use))
|
||||
wieldstack = on_use(wieldstack, virtplayer, pointed_thing) or wieldstack
|
||||
virtplayer:set_wielded_item(wieldstack)
|
||||
else
|
||||
local under_node = minetest.get_node(pointed_thing.under)
|
||||
local def = minetest.registered_nodes[under_node.name]
|
||||
if not def then
|
||||
-- do not dig an unknown node
|
||||
return
|
||||
end
|
||||
-- check that the current tool is capable of destroying the
|
||||
-- target node.
|
||||
-- if we can't, don't dig, and leave the wield stack unchanged.
|
||||
-- note that wieldstack:get_tool_capabilities() returns hand
|
||||
-- properties if the item has none of it's own.
|
||||
if can_tool_dig_node(under_node.name,
|
||||
wieldstack:get_tool_capabilities(),
|
||||
wieldstack:get_name()) then
|
||||
def.on_dig(pointed_thing.under, under_node, virtplayer)
|
||||
local sound = def.sounds and def.sounds.dug
|
||||
if sound then
|
||||
minetest.sound_play(sound.name,
|
||||
{pos=pointed_thing.under, gain=sound.gain})
|
||||
end
|
||||
wieldstack = virtplayer:get_wielded_item()
|
||||
--~ else
|
||||
--pipeworks.logger(dname.."couldn't dig node!")
|
||||
end
|
||||
end
|
||||
local wieldname = wieldstack:get_name()
|
||||
if wieldname == oldwieldstack:get_name() then
|
||||
-- don't mechanically wear out tool
|
||||
if wieldstack:get_count() == oldwieldstack:get_count() and
|
||||
wieldstack:get_metadata() == oldwieldstack:get_metadata() and
|
||||
((minetest.registered_items[wieldstack:get_name()] or {}).wear_represents or "mechanical_wear") == "mechanical_wear" then
|
||||
virtplayer:set_wielded_item(oldwieldstack)
|
||||
end
|
||||
elseif wieldname ~= "" then
|
||||
-- tool got replaced by something else:
|
||||
-- treat it as a drop
|
||||
virtplayer:get_inventory():add_item("main", wieldstack)
|
||||
virtplayer:set_wielded_item(ItemStack(""))
|
||||
end
|
||||
end,
|
||||
eject_drops = true,
|
||||
}
|
||||
register_wielder(data)
|
||||
pipeworks.ui_cat_tube_list[#pipeworks.ui_cat_tube_list+1] = "pipeworks:nodebreaker_off"
|
||||
-- aliases for when someone had technic installed, but then uninstalled it but not pipeworks
|
||||
minetest.register_alias("technic:nodebreaker_off", "pipeworks:nodebreaker_off")
|
||||
minetest.register_alias("technic:nodebreaker_on", "pipeworks:nodebreaker_on")
|
||||
minetest.register_alias("technic:node_breaker_off", "pipeworks:nodebreaker_off")
|
||||
minetest.register_alias("technic:node_breaker_on", "pipeworks:nodebreaker_on")
|
||||
-- turn legacy auto-tree-taps into node breakers
|
||||
dofile(pipeworks.modpath.."/legacy.lua")
|
||||
|
||||
-- register LBM for transition to cheaper node breakers
|
||||
local lbm_id = "pipeworks:refund_node_breaker_pick"
|
||||
minetest.register_lbm({
|
||||
name = lbm_id,
|
||||
label = "Give back mese pick for pre-transition node breakers",
|
||||
run_at_every_load = false,
|
||||
nodenames = { name_base.."_on", name_base.."_off" },
|
||||
action = function(pos, node)
|
||||
pipeworks.logger(lbm_id.." entry, nodename="..node.name)
|
||||
local invref = minetest.get_meta(pos):get_inventory()
|
||||
invref:add_item(wield_inv_name, ItemStack("default:pick_mese"))
|
||||
end
|
||||
})
|
||||
core.register_alias("technic:nodebreaker_off", "pipeworks:nodebreaker_off")
|
||||
core.register_alias("technic:nodebreaker_on", "pipeworks:nodebreaker_on")
|
||||
core.register_alias("technic:node_breaker_off", "pipeworks:nodebreaker_off")
|
||||
core.register_alias("technic:node_breaker_on", "pipeworks:nodebreaker_on")
|
||||
core.register_alias("auto_tree_tap:off", "pipeworks:nodebreaker_off")
|
||||
core.register_alias("auto_tree_tap:on", "pipeworks:nodebreaker_on")
|
||||
end
|
||||
|
||||
if pipeworks.enable_deployer then
|
||||
pipeworks.register_wielder({
|
||||
name = "pipeworks:deployer",
|
||||
register_wielder({
|
||||
name_base = "pipeworks:deployer",
|
||||
description = S("Deployer"),
|
||||
tiles = get_tiles("deployer", {front = 1}),
|
||||
connect_sides = {back = 1},
|
||||
wield_inv = {name = "main", width = 3, height = 3},
|
||||
action = function(fakeplayer, pointed)
|
||||
local stack = fakeplayer:get_wielded_item()
|
||||
local def = core.registered_items[stack:get_name()]
|
||||
if def and def.on_place then
|
||||
local new_stack, placed_pos = def.on_place(stack, fakeplayer, pointed)
|
||||
fakeplayer:set_wielded_item(new_stack or stack)
|
||||
-- core.item_place_node doesn't play sound to the placer
|
||||
local sound = placed_pos and def.sounds and def.sounds.place
|
||||
local name = fakeplayer:get_player_name()
|
||||
if sound and name ~= "" then
|
||||
core.sound_play(sound, {pos = placed_pos, to_player = name}, true)
|
||||
end
|
||||
texture_base = "pipeworks_deployer",
|
||||
texture_stateful = { front = true },
|
||||
tube_connect_sides = { back=1 },
|
||||
tube_permit_anteroposterior_insert = true,
|
||||
wield_inv_name = "main",
|
||||
wield_inv_width = 3,
|
||||
wield_inv_height = 3,
|
||||
can_dig_nonempty_wield_inv = false,
|
||||
masquerade_as_owner = true,
|
||||
sneak = false,
|
||||
act = function(virtplayer, pointed_thing)
|
||||
if minetest.is_protected(vector.add(virtplayer:get_pos(), assumed_eye_pos), virtplayer:get_player_name()) then
|
||||
return
|
||||
end
|
||||
|
||||
local wieldstack = virtplayer:get_wielded_item()
|
||||
virtplayer:set_wielded_item((minetest.registered_items[wieldstack:get_name()] or {on_place=minetest.item_place}).on_place(wieldstack, virtplayer, pointed_thing) or wieldstack)
|
||||
end,
|
||||
eject_drops = false,
|
||||
})
|
||||
core.register_alias("technic:deployer_off", "pipeworks:deployer_off")
|
||||
core.register_alias("technic:deployer_on", "pipeworks:deployer_on")
|
||||
pipeworks.ui_cat_tube_list[#pipeworks.ui_cat_tube_list+1] = "pipeworks:deployer_off"
|
||||
-- aliases for when someone had technic installed, but then uninstalled it but not pipeworks
|
||||
minetest.register_alias("technic:deployer_off", "pipeworks:deployer_off")
|
||||
minetest.register_alias("technic:deployer_on", "pipeworks:deployer_on")
|
||||
end
|
||||
|
||||
if pipeworks.enable_dispenser then
|
||||
-- Override core.item_drop to negate its hardcoded offset
|
||||
-- when the dropper is a fake player.
|
||||
local item_drop = core.item_drop
|
||||
-- luacheck: ignore 122
|
||||
function core.item_drop(stack, dropper, pos)
|
||||
if dropper and dropper.is_fake_player then
|
||||
pos = vector.new(pos.x, pos.y - 1.2, pos.z)
|
||||
end
|
||||
return item_drop(stack, dropper, pos)
|
||||
end
|
||||
pipeworks.register_wielder({
|
||||
name = "pipeworks:dispenser",
|
||||
register_wielder({
|
||||
name_base = "pipeworks:dispenser",
|
||||
description = S("Dispenser"),
|
||||
tiles = get_tiles("dispenser", {front = 1}),
|
||||
connect_sides = {back = 1},
|
||||
wield_inv = {name = "main", width = 3, height = 3},
|
||||
action = function(fakeplayer)
|
||||
local stack = fakeplayer:get_wielded_item()
|
||||
local def = core.registered_items[stack:get_name()]
|
||||
if def and def.on_drop then
|
||||
local pos = fakeplayer:get_pos()
|
||||
fakeplayer:set_wielded_item(def.on_drop(stack, fakeplayer, pos) or stack)
|
||||
end
|
||||
texture_base = "pipeworks_dispenser",
|
||||
texture_stateful = { front = true },
|
||||
tube_connect_sides = { back=1 },
|
||||
tube_permit_anteroposterior_insert = true,
|
||||
wield_inv_name = "main",
|
||||
wield_inv_width = 3,
|
||||
wield_inv_height = 3,
|
||||
can_dig_nonempty_wield_inv = false,
|
||||
masquerade_as_owner = false,
|
||||
sneak = true,
|
||||
act = function(virtplayer, pointed_thing)
|
||||
local wieldstack = virtplayer:get_wielded_item()
|
||||
virtplayer:set_wielded_item((minetest.registered_items[wieldstack:get_name()] or
|
||||
{on_drop=minetest.item_drop}).on_drop(wieldstack, virtplayer, virtplayer:get_pos()) or
|
||||
wieldstack)
|
||||
end,
|
||||
eject_drops = false,
|
||||
})
|
||||
pipeworks.ui_cat_tube_list[#pipeworks.ui_cat_tube_list+1] = "pipeworks:dispenser_off"
|
||||
end
|
||||
|
Reference in New Issue
Block a user