mirror of
https://github.com/mt-mods/pipeworks.git
synced 2024-11-08 08:23:59 +01:00
code and registrations cleanup (#101)
* code and registrations cleanup * don't expose materials to global env --------- Co-authored-by: BuckarooBanzay <BuckarooBanzay@users.noreply.github.com>
This commit is contained in:
parent
dd6950f7b0
commit
578e45257b
13
.github/workflows/luacheck.yml
vendored
13
.github/workflows/luacheck.yml
vendored
@ -1,13 +1,10 @@
|
|||||||
name: luacheck
|
name: luacheck
|
||||||
on: [push, pull_request]
|
on: [push, pull_request]
|
||||||
jobs:
|
jobs:
|
||||||
build:
|
luacheck:
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@master
|
- name: Checkout
|
||||||
- name: apt
|
uses: actions/checkout@master
|
||||||
run: sudo apt-get install -y luarocks
|
- name: Luacheck
|
||||||
- name: luacheck install
|
uses: lunarmodules/luacheck@master
|
||||||
run: luarocks install --local luacheck
|
|
||||||
- name: luacheck run
|
|
||||||
run: $HOME/.luarocks/bin/luacheck ./
|
|
93
common.lua
93
common.lua
@ -1,3 +1,96 @@
|
|||||||
|
local S = minetest.get_translator("pipeworks")
|
||||||
|
|
||||||
|
-- Random variables
|
||||||
|
|
||||||
|
pipeworks.expect_infinite_stacks = true
|
||||||
|
if minetest.get_modpath("unified_inventory") or not minetest.settings:get_bool("creative_mode") then
|
||||||
|
pipeworks.expect_infinite_stacks = false
|
||||||
|
end
|
||||||
|
|
||||||
|
pipeworks.meseadjlist={{x=0,y=0,z=1},{x=0,y=0,z=-1},{x=0,y=1,z=0},{x=0,y=-1,z=0},{x=1,y=0,z=0},{x=-1,y=0,z=0}}
|
||||||
|
|
||||||
|
pipeworks.rules_all = {{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=1},{x=0, y=1, z=-1},{x=1, y=1, z=0},{x=-1, y=1, z=0},
|
||||||
|
{x=0, y=-1, z=1},{x=0, y=-1, z=-1},{x=1, y=-1, z=0},{x=-1, y=-1, z=0},
|
||||||
|
{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}}
|
||||||
|
|
||||||
|
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"}
|
||||||
|
pipeworks.button_on = {text="", texture="pipeworks_button_on.png", addopts="false;false;pipeworks_button_interm.png"}
|
||||||
|
pipeworks.button_base = "image_button[0,4.3;1,0.6"
|
||||||
|
pipeworks.button_label = "label[0.9,4.31;"..S("Allow splitting incoming stacks from tubes").."]"
|
||||||
|
|
||||||
|
-- Helper functions
|
||||||
|
|
||||||
|
function pipeworks.fix_image_names(table, replacement)
|
||||||
|
local outtable={}
|
||||||
|
for i in ipairs(table) do
|
||||||
|
outtable[i]=string.gsub(table[i], "_XXXXX", replacement)
|
||||||
|
end
|
||||||
|
|
||||||
|
return outtable
|
||||||
|
end
|
||||||
|
|
||||||
|
local function overlay_tube_texture(texture)
|
||||||
|
-- The texture appears the first time to be colorized as the opaque background.
|
||||||
|
return ("(%s)^[noalpha^[colorize:#dadada^(%s)"):format(texture, texture)
|
||||||
|
end
|
||||||
|
|
||||||
|
function pipeworks.make_tube_tile(tile)
|
||||||
|
if pipeworks.use_real_entities then
|
||||||
|
return tile
|
||||||
|
elseif type(tile) == "string" then
|
||||||
|
return overlay_tube_texture(tile)
|
||||||
|
else
|
||||||
|
tile = table.copy(tile)
|
||||||
|
if tile.color then
|
||||||
|
-- Won't work 100% of the time, but good enough.
|
||||||
|
tile.name = tile.name .. "^[multiply:" .. minetest.colorspec_to_colorstring(tile.color)
|
||||||
|
tile.color = nil
|
||||||
|
end
|
||||||
|
tile.name = overlay_tube_texture(tile.name)
|
||||||
|
tile.backface_culling = nil -- The texture is opaque
|
||||||
|
return tile
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
function pipeworks.add_node_box(t, b)
|
||||||
|
if not t or not b then return end
|
||||||
|
for i in ipairs(b)
|
||||||
|
do table.insert(t, b[i])
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
function pipeworks.may_configure(pos, player)
|
||||||
|
local name = player:get_player_name()
|
||||||
|
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 minetest.is_protected(pos, name)
|
||||||
|
end
|
||||||
|
|
||||||
|
function pipeworks.replace_name(tbl,tr,name)
|
||||||
|
local ntbl={}
|
||||||
|
for key,i in pairs(tbl) do
|
||||||
|
if type(i)=="string" then
|
||||||
|
ntbl[key]=string.gsub(i,tr,name)
|
||||||
|
elseif type(i)=="table" then
|
||||||
|
ntbl[key]=pipeworks.replace_name(i,tr,name)
|
||||||
|
else
|
||||||
|
ntbl[key]=i
|
||||||
|
end
|
||||||
|
end
|
||||||
|
return ntbl
|
||||||
|
end
|
||||||
|
|
||||||
----------------------
|
----------------------
|
||||||
-- Vector functions --
|
-- Vector functions --
|
||||||
----------------------
|
----------------------
|
||||||
|
76
crafts.lua
76
crafts.lua
@ -1,70 +1,5 @@
|
|||||||
local materials = {
|
|
||||||
stone = "default:stone",
|
|
||||||
desert_stone = "default:desert_stone",
|
|
||||||
desert_sand = "default:desert_sand",
|
|
||||||
chest = "default:chest",
|
|
||||||
copper_ingot = "default:copper_ingot",
|
|
||||||
steel_ingot = "default:steel_ingot",
|
|
||||||
gold_ingot = "default:gold_ingot",
|
|
||||||
mese = "default:mese",
|
|
||||||
mese_crystal = "default:mese_crystal",
|
|
||||||
mese_crystal_fragment = "default:mese_crystal_fragment",
|
|
||||||
teleporter = "default:mese",
|
|
||||||
glass = "default:glass",
|
|
||||||
}
|
|
||||||
|
|
||||||
if minetest.get_modpath("mcl_core") then
|
|
||||||
materials = {
|
|
||||||
stone = "mcl_core:stone",
|
|
||||||
desert_stone = "mcl_core:redsandstone",
|
|
||||||
desert_sand = "mcl_core:sand",
|
|
||||||
chest = "mcl_chests:chest",
|
|
||||||
steel_ingot = "mcl_core:iron_ingot",
|
|
||||||
gold_ingot = "mcl_core:gold_ingot",
|
|
||||||
mese = "mesecons_torch:redstoneblock",
|
|
||||||
mese_crystal = "mesecons:redstone",
|
|
||||||
mese_crystal_fragment = "mesecons:redstone",
|
|
||||||
teleporter = "mesecons_torch:redstoneblock",
|
|
||||||
copper_ingot = "mcl_copper:copper_ingot",
|
|
||||||
glass = "mcl_core:glass",
|
|
||||||
}
|
|
||||||
elseif minetest.get_modpath("fl_ores") and minetest.get_modpath("fl_stone") then
|
|
||||||
materials = {
|
|
||||||
stone = "fl_stone:stone",
|
|
||||||
desert_stone = "fl_stone:desert_stone",
|
|
||||||
desert_sand = "fl_stone:desert_sand",
|
|
||||||
chest = "fl_storage:wood_chest",
|
|
||||||
steel_ingot = "fl_ores:iron_ingot",
|
|
||||||
gold_ingot = "fl_ores:gold_ingot",
|
|
||||||
mese = "fl_ores:iron_ingot",
|
|
||||||
mese_crystal = "fl_ores:iron_ingot",
|
|
||||||
mese_crystal_fragment = "fl_ores:iron_ingot",
|
|
||||||
teleporter = "fl_ores:iron_ingot",
|
|
||||||
copper_ingot = "fl_ores:copper_ingot",
|
|
||||||
glass = "fl_glass:framed_glass",
|
|
||||||
}
|
|
||||||
elseif minetest.get_modpath("hades_core") then
|
|
||||||
materials = {
|
|
||||||
stone = "hades_core:stone",
|
|
||||||
desert_stone = "hades_core:stone_baked",
|
|
||||||
desert_sand = "hades_core:volcanic_sand",
|
|
||||||
chest = "hades_chests:chest";
|
|
||||||
steel_ingot = "hades_core:steel_ingot",
|
|
||||||
gold_ingot = "hades_core:gold_ingot",
|
|
||||||
mese = "hades_core:mese",
|
|
||||||
mese_crystal = "hades_core:mese_crystal",
|
|
||||||
mese_crystal_fragment = "hades_core:mese_crystal_fragment",
|
|
||||||
teleporter = "hades_materials:teleporter_device",
|
|
||||||
copper_ingot = "hades_core:copper_ingot",
|
|
||||||
tin_ingot = "hades_core:tin_ingot",
|
|
||||||
glass = "hades_core:glass",
|
|
||||||
}
|
|
||||||
if minetest.get_modpath("hades_default") then
|
|
||||||
materials.desert_sand = "hades_default:desert_sand"
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
-- Crafting recipes for pipes
|
-- Crafting recipes for pipes
|
||||||
|
local materials = ...
|
||||||
|
|
||||||
minetest.register_craft( {
|
minetest.register_craft( {
|
||||||
output = "pipeworks:pipe_1_empty 12",
|
output = "pipeworks:pipe_1_empty 12",
|
||||||
@ -194,15 +129,6 @@ minetest.register_craft( {
|
|||||||
},
|
},
|
||||||
})
|
})
|
||||||
|
|
||||||
minetest.register_craft( {
|
|
||||||
output = "pipeworks:steel_block_embedded_tube 1",
|
|
||||||
recipe = {
|
|
||||||
{ materials.steel_ingot, materials.steel_ingot, materials.steel_ingot },
|
|
||||||
{ materials.steel_ingot, "pipeworks:tube_1", materials.steel_ingot },
|
|
||||||
{ materials.steel_ingot, materials.steel_ingot, materials.steel_ingot }
|
|
||||||
},
|
|
||||||
})
|
|
||||||
|
|
||||||
minetest.register_craft( {
|
minetest.register_craft( {
|
||||||
output = "pipeworks:steel_pane_embedded_tube 1",
|
output = "pipeworks:steel_pane_embedded_tube 1",
|
||||||
recipe = {
|
recipe = {
|
||||||
|
155
init.lua
155
init.lua
@ -4,21 +4,20 @@
|
|||||||
-- and devices that they can connect to.
|
-- and devices that they can connect to.
|
||||||
--
|
--
|
||||||
|
|
||||||
pipeworks = {}
|
pipeworks = {
|
||||||
pipeworks.ui_cat_tube_list = {}
|
ui_cat_tube_list = {},
|
||||||
|
worldpath = minetest.get_worldpath(),
|
||||||
pipeworks.worldpath = minetest.get_worldpath()
|
modpath = minetest.get_modpath("pipeworks"),
|
||||||
pipeworks.modpath = minetest.get_modpath("pipeworks")
|
liquids = {
|
||||||
local S = minetest.get_translator("pipeworks")
|
water = {
|
||||||
|
source = minetest.registered_nodes["mapgen_water_source"].name,
|
||||||
pipeworks.liquids = {}
|
flowing = minetest.registered_nodes["mapgen_water_source"].liquid_alternative_flowing
|
||||||
pipeworks.liquids.water = {
|
},
|
||||||
source = minetest.registered_nodes["mapgen_water_source"].name,
|
river_water = {
|
||||||
flowing = minetest.registered_nodes["mapgen_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
|
||||||
pipeworks.liquids.river_water = {
|
}
|
||||||
source = minetest.registered_nodes["mapgen_river_water_source"].name,
|
}
|
||||||
flowing = minetest.registered_nodes["mapgen_river_water_source"].liquid_alternative_flowing
|
|
||||||
}
|
}
|
||||||
|
|
||||||
dofile(pipeworks.modpath.."/default_settings.lua")
|
dofile(pipeworks.modpath.."/default_settings.lua")
|
||||||
@ -36,97 +35,6 @@ if pipeworks.entity_update_interval >= 0.2 and pipeworks.enable_accelerator_tube
|
|||||||
minetest.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
|
end
|
||||||
|
|
||||||
-- Random variables
|
|
||||||
|
|
||||||
pipeworks.expect_infinite_stacks = true
|
|
||||||
if minetest.get_modpath("unified_inventory") or not minetest.settings:get_bool("creative_mode") then
|
|
||||||
pipeworks.expect_infinite_stacks = false
|
|
||||||
end
|
|
||||||
|
|
||||||
pipeworks.meseadjlist={{x=0,y=0,z=1},{x=0,y=0,z=-1},{x=0,y=1,z=0},{x=0,y=-1,z=0},{x=1,y=0,z=0},{x=-1,y=0,z=0}}
|
|
||||||
|
|
||||||
pipeworks.rules_all = {{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=1},{x=0, y=1, z=-1},{x=1, y=1, z=0},{x=-1, y=1, z=0},
|
|
||||||
{x=0, y=-1, z=1},{x=0, y=-1, z=-1},{x=1, y=-1, z=0},{x=-1, y=-1, z=0},
|
|
||||||
{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}}
|
|
||||||
|
|
||||||
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"}
|
|
||||||
pipeworks.button_on = {text="", texture="pipeworks_button_on.png", addopts="false;false;pipeworks_button_interm.png"}
|
|
||||||
pipeworks.button_base = "image_button[0,4.3;1,0.6"
|
|
||||||
pipeworks.button_label = "label[0.9,4.31;"..S("Allow splitting incoming stacks from tubes").."]"
|
|
||||||
|
|
||||||
-- Helper functions
|
|
||||||
|
|
||||||
function pipeworks.fix_image_names(table, replacement)
|
|
||||||
local outtable={}
|
|
||||||
for i in ipairs(table) do
|
|
||||||
outtable[i]=string.gsub(table[i], "_XXXXX", replacement)
|
|
||||||
end
|
|
||||||
|
|
||||||
return outtable
|
|
||||||
end
|
|
||||||
|
|
||||||
local function overlay_tube_texture(texture)
|
|
||||||
-- The texture appears the first time to be colorized as the opaque background.
|
|
||||||
return ("(%s)^[noalpha^[colorize:#dadada^(%s)"):format(texture, texture)
|
|
||||||
end
|
|
||||||
|
|
||||||
function pipeworks.make_tube_tile(tile)
|
|
||||||
if pipeworks.use_real_entities then
|
|
||||||
return tile
|
|
||||||
elseif type(tile) == "string" then
|
|
||||||
return overlay_tube_texture(tile)
|
|
||||||
else
|
|
||||||
tile = table.copy(tile)
|
|
||||||
if tile.color then
|
|
||||||
-- Won't work 100% of the time, but good enough.
|
|
||||||
tile.name = tile.name .. "^[multiply:" .. minetest.colorspec_to_colorstring(tile.color)
|
|
||||||
tile.color = nil
|
|
||||||
end
|
|
||||||
tile.name = overlay_tube_texture(tile.name)
|
|
||||||
tile.backface_culling = nil -- The texture is opaque
|
|
||||||
return tile
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
function pipeworks.add_node_box(t, b)
|
|
||||||
if not t or not b then return end
|
|
||||||
for i in ipairs(b)
|
|
||||||
do table.insert(t, b[i])
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
function pipeworks.may_configure(pos, player)
|
|
||||||
local name = player:get_player_name()
|
|
||||||
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 minetest.is_protected(pos, name)
|
|
||||||
end
|
|
||||||
|
|
||||||
function pipeworks.replace_name(tbl,tr,name)
|
|
||||||
local ntbl={}
|
|
||||||
for key,i in pairs(tbl) do
|
|
||||||
if type(i)=="string" then
|
|
||||||
ntbl[key]=string.gsub(i,tr,name)
|
|
||||||
elseif type(i)=="table" then
|
|
||||||
ntbl[key]=pipeworks.replace_name(i,tr,name)
|
|
||||||
else
|
|
||||||
ntbl[key]=i
|
|
||||||
end
|
|
||||||
end
|
|
||||||
return ntbl
|
|
||||||
end
|
|
||||||
|
|
||||||
pipeworks.logger = function(msg)
|
pipeworks.logger = function(msg)
|
||||||
minetest.log("action", "[pipeworks] "..msg)
|
minetest.log("action", "[pipeworks] "..msg)
|
||||||
end
|
end
|
||||||
@ -150,15 +58,29 @@ dofile(pipeworks.modpath.."/autoplace_tubes.lua")
|
|||||||
dofile(pipeworks.modpath.."/luaentity.lua")
|
dofile(pipeworks.modpath.."/luaentity.lua")
|
||||||
dofile(pipeworks.modpath.."/item_transport.lua")
|
dofile(pipeworks.modpath.."/item_transport.lua")
|
||||||
dofile(pipeworks.modpath.."/flowing_logic.lua")
|
dofile(pipeworks.modpath.."/flowing_logic.lua")
|
||||||
dofile(pipeworks.modpath.."/tube_registration.lua")
|
|
||||||
dofile(pipeworks.modpath.."/routing_tubes.lua")
|
|
||||||
dofile(pipeworks.modpath.."/sorting_tubes.lua")
|
|
||||||
dofile(pipeworks.modpath.."/signal_tubes.lua")
|
|
||||||
dofile(pipeworks.modpath.."/decorative_tubes.lua")
|
|
||||||
dofile(pipeworks.modpath.."/filter-injector.lua")
|
dofile(pipeworks.modpath.."/filter-injector.lua")
|
||||||
dofile(pipeworks.modpath.."/trashcan.lua")
|
dofile(pipeworks.modpath.."/trashcan.lua")
|
||||||
dofile(pipeworks.modpath.."/wielder.lua")
|
dofile(pipeworks.modpath.."/wielder.lua")
|
||||||
|
|
||||||
|
local materials = loadfile(pipeworks.modpath.."/materials.lua")()
|
||||||
|
|
||||||
|
dofile(pipeworks.modpath.."/tubes/registration.lua")
|
||||||
|
dofile(pipeworks.modpath.."/tubes/routing.lua")
|
||||||
|
dofile(pipeworks.modpath.."/tubes/sorting.lua")
|
||||||
|
dofile(pipeworks.modpath.."/tubes/signal.lua")
|
||||||
|
loadfile(pipeworks.modpath.."/tubes/embedded_tube.lua")(materials)
|
||||||
|
dofile(pipeworks.modpath.."/tubes/pane_embedded_tube.lua")
|
||||||
|
|
||||||
|
if pipeworks.enable_teleport_tube then
|
||||||
|
dofile(pipeworks.modpath.."/tubes/teleport.lua")
|
||||||
|
end
|
||||||
|
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
|
||||||
|
dofile(pipeworks.modpath.."/tubes/vacuum.lua")
|
||||||
|
end
|
||||||
|
|
||||||
local logicdir = "/pressure_logic/"
|
local logicdir = "/pressure_logic/"
|
||||||
|
|
||||||
-- note that even with these files the new flow logic is not yet default.
|
-- note that even with these files the new flow logic is not yet default.
|
||||||
@ -172,9 +94,6 @@ dofile(pipeworks.modpath..logicdir.."flowable_node_registry_install.lua")
|
|||||||
if pipeworks.enable_pipes then
|
if pipeworks.enable_pipes then
|
||||||
dofile(pipeworks.modpath.."/pipes.lua")
|
dofile(pipeworks.modpath.."/pipes.lua")
|
||||||
end
|
end
|
||||||
if pipeworks.enable_teleport_tube then
|
|
||||||
dofile(pipeworks.modpath.."/teleport_tube.lua")
|
|
||||||
end
|
|
||||||
if pipeworks.enable_pipe_devices then
|
if pipeworks.enable_pipe_devices then
|
||||||
dofile(pipeworks.modpath.."/devices.lua")
|
dofile(pipeworks.modpath.."/devices.lua")
|
||||||
end
|
end
|
||||||
@ -191,14 +110,8 @@ end
|
|||||||
if pipeworks.enable_autocrafter then
|
if pipeworks.enable_autocrafter then
|
||||||
dofile(pipeworks.modpath.."/autocrafter.lua")
|
dofile(pipeworks.modpath.."/autocrafter.lua")
|
||||||
end
|
end
|
||||||
if pipeworks.enable_lua_tube and minetest.get_modpath("mesecons") then
|
|
||||||
dofile(pipeworks.modpath.."/lua_tube.lua")
|
|
||||||
end
|
|
||||||
if pipeworks.enable_sand_tube or pipeworks.enable_mese_sand_tube then
|
|
||||||
dofile(pipeworks.modpath.."/vacuum_tubes.lua")
|
|
||||||
end
|
|
||||||
|
|
||||||
dofile(pipeworks.modpath.."/crafts.lua")
|
loadfile(pipeworks.modpath.."/crafts.lua")(materials)
|
||||||
|
|
||||||
minetest.register_alias("pipeworks:pipe", "pipeworks:pipe_110000_empty")
|
minetest.register_alias("pipeworks:pipe", "pipeworks:pipe_110000_empty")
|
||||||
|
|
||||||
|
67
materials.lua
Normal file
67
materials.lua
Normal file
@ -0,0 +1,67 @@
|
|||||||
|
local materials = {
|
||||||
|
stone = "default:stone",
|
||||||
|
desert_stone = "default:desert_stone",
|
||||||
|
desert_sand = "default:desert_sand",
|
||||||
|
chest = "default:chest",
|
||||||
|
copper_ingot = "default:copper_ingot",
|
||||||
|
steel_ingot = "default:steel_ingot",
|
||||||
|
gold_ingot = "default:gold_ingot",
|
||||||
|
mese = "default:mese",
|
||||||
|
mese_crystal = "default:mese_crystal",
|
||||||
|
mese_crystal_fragment = "default:mese_crystal_fragment",
|
||||||
|
teleporter = "default:mese",
|
||||||
|
glass = "default:glass"
|
||||||
|
}
|
||||||
|
|
||||||
|
if minetest.get_modpath("mcl_core") then
|
||||||
|
materials = {
|
||||||
|
stone = "mcl_core:stone",
|
||||||
|
desert_stone = "mcl_core:redsandstone",
|
||||||
|
desert_sand = "mcl_core:sand",
|
||||||
|
chest = "mcl_chests:chest",
|
||||||
|
steel_ingot = "mcl_core:iron_ingot",
|
||||||
|
gold_ingot = "mcl_core:gold_ingot",
|
||||||
|
mese = "mesecons_torch:redstoneblock",
|
||||||
|
mese_crystal = "mesecons:redstone",
|
||||||
|
mese_crystal_fragment = "mesecons:redstone",
|
||||||
|
teleporter = "mesecons_torch:redstoneblock",
|
||||||
|
copper_ingot = "mcl_copper:copper_ingot",
|
||||||
|
glass = "mcl_core:glass",
|
||||||
|
}
|
||||||
|
elseif minetest.get_modpath("fl_ores") and minetest.get_modpath("fl_stone") then
|
||||||
|
materials = {
|
||||||
|
stone = "fl_stone:stone",
|
||||||
|
desert_stone = "fl_stone:desert_stone",
|
||||||
|
desert_sand = "fl_stone:desert_sand",
|
||||||
|
chest = "fl_storage:wood_chest",
|
||||||
|
steel_ingot = "fl_ores:iron_ingot",
|
||||||
|
gold_ingot = "fl_ores:gold_ingot",
|
||||||
|
mese = "fl_ores:iron_ingot",
|
||||||
|
mese_crystal = "fl_ores:iron_ingot",
|
||||||
|
mese_crystal_fragment = "fl_ores:iron_ingot",
|
||||||
|
teleporter = "fl_ores:iron_ingot",
|
||||||
|
copper_ingot = "fl_ores:copper_ingot",
|
||||||
|
glass = "fl_glass:framed_glass",
|
||||||
|
}
|
||||||
|
elseif minetest.get_modpath("hades_core") then
|
||||||
|
materials = {
|
||||||
|
stone = "hades_core:stone",
|
||||||
|
desert_stone = "hades_core:stone_baked",
|
||||||
|
desert_sand = "hades_core:volcanic_sand",
|
||||||
|
chest = "hades_chests:chest";
|
||||||
|
steel_ingot = "hades_core:steel_ingot",
|
||||||
|
gold_ingot = "hades_core:gold_ingot",
|
||||||
|
mese = "hades_core:mese",
|
||||||
|
mese_crystal = "hades_core:mese_crystal",
|
||||||
|
mese_crystal_fragment = "hades_core:mese_crystal_fragment",
|
||||||
|
teleporter = "hades_materials:teleporter_device",
|
||||||
|
copper_ingot = "hades_core:copper_ingot",
|
||||||
|
tin_ingot = "hades_core:tin_ingot",
|
||||||
|
glass = "hades_core:glass",
|
||||||
|
}
|
||||||
|
if minetest.get_modpath("hades_default") then
|
||||||
|
materials.desert_sand = "hades_default:desert_sand"
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
return materials
|
68
tubes/embedded_tube.lua
Normal file
68
tubes/embedded_tube.lua
Normal file
@ -0,0 +1,68 @@
|
|||||||
|
local materials = ...
|
||||||
|
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 minetest.get_modpath("default") then steel_tex = "default_steel_block.png" end
|
||||||
|
|
||||||
|
-- register an embedded tube
|
||||||
|
function pipeworks.register_embedded_tube(nodename, opts)
|
||||||
|
minetest.register_node(nodename, {
|
||||||
|
description = opts.description,
|
||||||
|
tiles = {
|
||||||
|
opts.base_texture,
|
||||||
|
opts.base_texture,
|
||||||
|
opts.base_texture,
|
||||||
|
opts.base_texture,
|
||||||
|
opts.base_texture .. "^pipeworks_tube_connection_metallic.png",
|
||||||
|
opts.base_texture .. "^pipeworks_tube_connection_metallic.png",
|
||||||
|
},
|
||||||
|
paramtype = "light",
|
||||||
|
paramtype2 = "facedir",
|
||||||
|
groups = {
|
||||||
|
cracky = 1,
|
||||||
|
oddly_breakable_by_hand = 1,
|
||||||
|
tubedevice = 1,
|
||||||
|
dig_glass = 2,
|
||||||
|
pickaxey=1,
|
||||||
|
handy=1
|
||||||
|
},
|
||||||
|
_mcl_hardness = 0.8,
|
||||||
|
legacy_facedir_simple = true,
|
||||||
|
_sound_def = {
|
||||||
|
key = "node_sound_stone_defaults",
|
||||||
|
},
|
||||||
|
tube = {
|
||||||
|
connect_sides = {
|
||||||
|
front = 1,
|
||||||
|
back = 1
|
||||||
|
},
|
||||||
|
priority = 50,
|
||||||
|
can_go = straight,
|
||||||
|
can_insert = function(pos, node, stack, direction)
|
||||||
|
local dir = minetest.facedir_to_dir(node.param2)
|
||||||
|
return vector.equals(dir, direction) or vector.equals(vector.multiply(dir, -1), direction)
|
||||||
|
end
|
||||||
|
},
|
||||||
|
after_place_node = pipeworks.after_place,
|
||||||
|
after_dig_node = pipeworks.after_dig,
|
||||||
|
on_rotate = pipeworks.on_rotate,
|
||||||
|
})
|
||||||
|
|
||||||
|
minetest.register_craft( {
|
||||||
|
output = nodename .. " 1",
|
||||||
|
recipe = {
|
||||||
|
{ opts.base_ingredient, opts.base_ingredient, opts.base_ingredient },
|
||||||
|
{ opts.base_ingredient, "pipeworks:tube_1", opts.base_ingredient },
|
||||||
|
{ opts.base_ingredient, opts.base_ingredient, opts.base_ingredient }
|
||||||
|
},
|
||||||
|
})
|
||||||
|
pipeworks.ui_cat_tube_list[#pipeworks.ui_cat_tube_list+1] = nodename
|
||||||
|
end
|
||||||
|
|
||||||
|
-- steelblock embedded tube
|
||||||
|
pipeworks.register_embedded_tube("pipeworks:steel_block_embedded_tube", {
|
||||||
|
description = S("Airtight steelblock embedded tube"),
|
||||||
|
base_texture = steel_tex,
|
||||||
|
base_ingredient = materials.steel_ingot
|
||||||
|
})
|
@ -1,39 +1,6 @@
|
|||||||
local S = minetest.get_translator("pipeworks")
|
local S = minetest.get_translator("pipeworks")
|
||||||
|
|
||||||
local straight = function(pos, node, velocity, stack) return {velocity} end
|
local straight = function(pos, node, velocity, stack) return {velocity} end
|
||||||
local steel_tex = "[combine:16x16^[noalpha^[colorize:#D3D3D3"
|
|
||||||
if minetest.get_modpath("default") then steel_tex = "default_steel_block.png" end
|
|
||||||
|
|
||||||
minetest.register_node("pipeworks:steel_block_embedded_tube", {
|
|
||||||
description = S("Airtight steelblock embedded tube"),
|
|
||||||
tiles = {
|
|
||||||
steel_tex, steel_tex,
|
|
||||||
steel_tex, steel_tex,
|
|
||||||
steel_tex .. "^pipeworks_tube_connection_metallic.png",
|
|
||||||
steel_tex .. "^pipeworks_tube_connection_metallic.png",
|
|
||||||
},
|
|
||||||
paramtype = "light",
|
|
||||||
paramtype2 = "facedir",
|
|
||||||
groups = {cracky=1, oddly_breakable_by_hand = 1, tubedevice = 1, dig_glass = 2, pickaxey=1, handy=1},
|
|
||||||
_mcl_hardness=0.8,
|
|
||||||
legacy_facedir_simple = true,
|
|
||||||
_sound_def = {
|
|
||||||
key = "node_sound_stone_defaults",
|
|
||||||
},
|
|
||||||
tube = {
|
|
||||||
connect_sides = {front = 1, back = 1,},
|
|
||||||
priority = 50,
|
|
||||||
can_go = straight,
|
|
||||||
can_insert = function(pos, node, stack, direction)
|
|
||||||
local dir = minetest.facedir_to_dir(node.param2)
|
|
||||||
return vector.equals(dir, direction) or vector.equals(vector.multiply(dir, -1), direction)
|
|
||||||
end,
|
|
||||||
},
|
|
||||||
after_place_node = pipeworks.after_place,
|
|
||||||
after_dig_node = pipeworks.after_dig,
|
|
||||||
on_rotate = pipeworks.on_rotate,
|
|
||||||
})
|
|
||||||
pipeworks.ui_cat_tube_list[#pipeworks.ui_cat_tube_list+1] = "pipeworks:steel_block_embedded_tube"
|
|
||||||
|
|
||||||
local pane_box = {
|
local pane_box = {
|
||||||
type = "fixed",
|
type = "fixed",
|
Loading…
Reference in New Issue
Block a user