|
@ -0,0 +1 @@
|
|||
Subproject commit 2c4a79180503adfdb0ba6c4b0f893ebb16521bd3
|
|
@ -0,0 +1 @@
|
|||
Subproject commit 56ea862f8f6d8b4b50b48139ec4c808535be33b0
|
|
@ -1,48 +0,0 @@
|
|||
===FARMING MOD for MINETEST-C55===
|
||||
by PilzAdam
|
||||
|
||||
Extended Version
|
||||
|
||||
Introduction:
|
||||
This mod adds farming to Minetest.
|
||||
|
||||
How to install:
|
||||
Unzip the archive an place it in minetest-base-directory/mods/minetest/
|
||||
if you have a windows client or a linux run-in-place client. If you have
|
||||
a linux system-wide instalation place it in ~/.minetest/mods/minetest/.
|
||||
If you want to install this mod only in one world create the folder
|
||||
worldmods/ in your worlddirectory.
|
||||
For further information or help see:
|
||||
http://wiki.minetest.com/wiki/Installing_Mods
|
||||
|
||||
How to use the mod:
|
||||
Craft a wood/stone/steel hoe:
|
||||
material material
|
||||
stick
|
||||
stick
|
||||
Dig dirt with it and turn it to soil. Water the soil and plant the seeds
|
||||
you get by digging dirt with the hoe. Wait until the seeds are seasoned
|
||||
and harvest them. When harvesting you will get the product and new seeds.
|
||||
For further information or help see:
|
||||
http://minetest.net/forum/viewtopic.php?id=2787
|
||||
|
||||
License:
|
||||
Sourcecode: WTFPL (see below)
|
||||
Graphics: WTFPL (see below)
|
||||
|
||||
See also:
|
||||
http://minetest.net/
|
||||
|
||||
DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE
|
||||
Version 2, December 2004
|
||||
|
||||
Copyright (C) 2004 Sam Hocevar <sam@hocevar.net>
|
||||
|
||||
Everyone is permitted to copy and distribute verbatim or modified
|
||||
copies of this license document, and changing it is allowed as long
|
||||
as the name is changed.
|
||||
|
||||
DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE
|
||||
TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
|
||||
|
||||
0. You just DO WHAT THE FUCK YOU WANT TO.
|
|
@ -1,63 +0,0 @@
|
|||
minetest.register_node("farming_plus:banana_sapling", {
|
||||
description = "Banana Tree Sapling",
|
||||
drawtype = "plantlike",
|
||||
tiles = {"farming_banana_sapling.png"},
|
||||
inventory_image = "farming_banana_sapling.png",
|
||||
wield_image = "farming_banana_sapling.png",
|
||||
paramtype = "light",
|
||||
walkable = false,
|
||||
groups = {dig_immediate=3,flammable=2},
|
||||
sounds = default.node_sound_defaults(),
|
||||
})
|
||||
|
||||
minetest.register_node("farming_plus:banana_leaves", {
|
||||
drawtype = "allfaces_optional",
|
||||
tiles = {"farming_banana_leaves.png"},
|
||||
paramtype = "light",
|
||||
groups = {snappy=3, leafdecay=3, flammable=2, not_in_creative_inventory=1},
|
||||
drop = {
|
||||
max_items = 1,
|
||||
items = {
|
||||
{
|
||||
items = {'farming_plus:banana_sapling'},
|
||||
rarity = 20,
|
||||
},
|
||||
}
|
||||
},
|
||||
sounds = default.node_sound_leaves_defaults(),
|
||||
})
|
||||
|
||||
minetest.register_abm({
|
||||
nodenames = {"farming_plus:banana_sapling"},
|
||||
interval = 60,
|
||||
chance = 20,
|
||||
action = function(pos, node)
|
||||
farming:generate_tree(pos, "default:tree", "farming_plus:banana_leaves", {"default:dirt", "default:dirt_with_grass"}, {["farming_plus:banana"]=20})
|
||||
end
|
||||
})
|
||||
|
||||
minetest.register_on_generated(function(minp, maxp, blockseed)
|
||||
if math.random(1, 100) > 5 then
|
||||
return
|
||||
end
|
||||
local tmp = {x=(maxp.x-minp.x)/2+minp.x, y=(maxp.y-minp.y)/2+minp.y, z=(maxp.z-minp.z)/2+minp.z}
|
||||
local pos = minetest.env:find_node_near(tmp, maxp.x-minp.x, {"default:dirt_with_grass"})
|
||||
if pos ~= nil then
|
||||
farming:generate_tree({x=pos.x, y=pos.y+1, z=pos.z}, "default:tree", "farming_plus:banana_leaves", {"default:dirt", "default:dirt_with_grass"}, {["farming_plus:banana"]=10})
|
||||
end
|
||||
end)
|
||||
|
||||
minetest.register_node("farming_plus:banana", {
|
||||
description = "Banana",
|
||||
tiles = {"farming_banana.png"},
|
||||
inventory_image = "farming_banana.png",
|
||||
wield_image = "farming_banana.png",
|
||||
drawtype = "torchlike",
|
||||
paramtype = "light",
|
||||
sunlight_propagates = true,
|
||||
walkable = false,
|
||||
groups = {fleshy=3,dig_immediate=3,flammable=2},
|
||||
sounds = default.node_sound_defaults(),
|
||||
|
||||
on_use = minetest.item_eat(6),
|
||||
})
|
|
@ -1,89 +0,0 @@
|
|||
minetest.register_craftitem("farming_plus:carrot_seed", {
|
||||
description = "Carrot Seeds",
|
||||
inventory_image = "farming_carrot_seed.png",
|
||||
on_place = function(itemstack, placer, pointed_thing)
|
||||
local above = minetest.env:get_node(pointed_thing.above)
|
||||
if above.name == "air" then
|
||||
above.name = "farming_plus:carrot_1"
|
||||
minetest.env:set_node(pointed_thing.above, above)
|
||||
itemstack:take_item(1)
|
||||
return itemstack
|
||||
end
|
||||
end
|
||||
})
|
||||
|
||||
minetest.register_node("farming_plus:carrot_1", {
|
||||
paramtype = "light",
|
||||
walkable = false,
|
||||
drawtype = "plantlike",
|
||||
drop = "",
|
||||
tiles = {"farming_carrot_1.png"},
|
||||
selection_box = {
|
||||
type = "fixed",
|
||||
fixed = {
|
||||
{-0.5, -0.5, -0.5, 0.5, -0.5+3/16, 0.5}
|
||||
},
|
||||
},
|
||||
groups = {snappy=3, flammable=2, not_in_creative_inventory=1},
|
||||
sounds = default.node_sound_leaves_defaults(),
|
||||
})
|
||||
|
||||
minetest.register_node("farming_plus:carrot_2", {
|
||||
paramtype = "light",
|
||||
walkable = false,
|
||||
drawtype = "plantlike",
|
||||
drop = "",
|
||||
tiles = {"farming_carrot_2.png"},
|
||||
selection_box = {
|
||||
type = "fixed",
|
||||
fixed = {
|
||||
{-0.5, -0.5, -0.5, 0.5, -0.5+5/16, 0.5}
|
||||
},
|
||||
},
|
||||
groups = {snappy=3, flammable=2, not_in_creative_inventory=1},
|
||||
sounds = default.node_sound_leaves_defaults(),
|
||||
})
|
||||
|
||||
minetest.register_node("farming_plus:carrot_3", {
|
||||
paramtype = "light",
|
||||
walkable = false,
|
||||
drawtype = "plantlike",
|
||||
drop = "",
|
||||
tiles = {"farming_carrot_3.png"},
|
||||
selection_box = {
|
||||
type = "fixed",
|
||||
fixed = {
|
||||
{-0.5, -0.5, -0.5, 0.5, -0.5+12/16, 0.5}
|
||||
},
|
||||
},
|
||||
groups = {snappy=3, flammable=2, not_in_creative_inventory=1},
|
||||
sounds = default.node_sound_leaves_defaults(),
|
||||
})
|
||||
|
||||
minetest.register_node("farming_plus:carrot", {
|
||||
paramtype = "light",
|
||||
walkable = false,
|
||||
drawtype = "plantlike",
|
||||
tiles = {"farming_carrot_4.png"},
|
||||
drop = {
|
||||
max_items = 6,
|
||||
items = {
|
||||
{ items = {'farming_plus:carrot_seed'} },
|
||||
{ items = {'farming_plus:carrot_seed'}, rarity = 2},
|
||||
{ items = {'farming_plus:carrot_seed'}, rarity = 5},
|
||||
{ items = {'farming_plus:carrot_item'} },
|
||||
{ items = {'farming_plus:carrot_item'}, rarity = 2 },
|
||||
{ items = {'farming_plus:carrot_item'}, rarity = 5 }
|
||||
}
|
||||
},
|
||||
groups = {snappy=3, flammable=2, not_in_creative_inventory=1},
|
||||
sounds = default.node_sound_leaves_defaults(),
|
||||
})
|
||||
|
||||
minetest.register_craftitem("farming_plus:carrot_item", {
|
||||
description = "Carrot",
|
||||
inventory_image = "farming_carrot.png",
|
||||
on_use = minetest.item_eat(3),
|
||||
})
|
||||
|
||||
farming:add_plant("farming_plus:carrot", {"farming_plus:carrot_1", "farming_plus:carrot_2", "farming_plus:carrot_3"}, 50, 20)
|
|
@ -1,73 +0,0 @@
|
|||
minetest.register_node("farming_plus:cocoa_sapling", {
|
||||
description = "Cocoa Tree Sapling",
|
||||
drawtype = "plantlike",
|
||||
tiles = {"farming_cocoa_sapling.png"},
|
||||
inventory_image = "farming_cocoa_sapling.png",
|
||||
wield_image = "farming_cocoa_sapling.png",
|
||||
paramtype = "light",
|
||||
walkable = false,
|
||||
groups = {dig_immediate=3,flammable=2},
|
||||
sounds = default.node_sound_defaults(),
|
||||
})
|
||||
|
||||
minetest.register_node("farming_plus:cocoa_leaves", {
|
||||
drawtype = "allfaces_optional",
|
||||
tiles = {"farming_banana_leaves.png"},
|
||||
paramtype = "light",
|
||||
groups = {snappy=3, leafdecay=3, flammable=2, not_in_creative_inventory=1},
|
||||
drop = {
|
||||
max_items = 1,
|
||||
items = {
|
||||
{
|
||||
items = {'farming_plus:cocoa_sapling'},
|
||||
rarity = 20,
|
||||
},
|
||||
}
|
||||
},
|
||||
sounds = default.node_sound_leaves_defaults(),
|
||||
})
|
||||
|
||||
minetest.register_abm({
|
||||
nodenames = {"farming_plus:cocoa_sapling"},
|
||||
interval = 60,
|
||||
chance = 20,
|
||||
action = function(pos, node)
|
||||
farming:generate_tree(pos, "default:tree", "farming_plus:cocoa_leaves", {"default:sand", "default:desert_sand"}, {["farming_plus:cocoa"]=20})
|
||||
end
|
||||
})
|
||||
|
||||
minetest.register_on_generated(function(minp, maxp, blockseed)
|
||||
if math.random(1, 100) > 5 then
|
||||
return
|
||||
end
|
||||
local tmp = {x=(maxp.x-minp.x)/2+minp.x, y=(maxp.y-minp.y)/2+minp.y, z=(maxp.z-minp.z)/2+minp.z}
|
||||
local pos = minetest.env:find_node_near(tmp, maxp.x-minp.x, {"default:desert_sand"})
|
||||
if pos ~= nil then
|
||||
farming:generate_tree({x=pos.x, y=pos.y+1, z=pos.z}, "default:tree", "farming_plus:cocoa_leaves", {"default:sand", "default:desert_sand"}, {["farming_plus:cocoa"]=20})
|
||||
end
|
||||
end)
|
||||
|
||||
minetest.register_node("farming_plus:cocoa", {
|
||||
description = "Cocoa",
|
||||
tiles = {"farming_cocoa.png"},
|
||||
visual_scale = 0.5,
|
||||
inventory_image = "farming_cocoa.png",
|
||||
wield_image = "farming_cocoa.png",
|
||||
drawtype = "torchlike",
|
||||
paramtype = "light",
|
||||
sunlight_propagates = true,
|
||||
walkable = false,
|
||||
groups = {fleshy=3,dig_immediate=3,flammable=2},
|
||||
sounds = default.node_sound_defaults(),
|
||||
})
|
||||
|
||||
minetest.register_craftitem("farming_plus:cocoa_bean", {
|
||||
description = "Cocoa Bean",
|
||||
inventory_image = "farming_cocoa_bean.png",
|
||||
})
|
||||
|
||||
minetest.register_craft({
|
||||
output = "farming_plus:cocoa_bean 10",
|
||||
type = "shapeless",
|
||||
recipe = {"farming_plus:cocoa"},
|
||||
})
|
|
@ -1,4 +0,0 @@
|
|||
default
|
||||
bucket
|
||||
wool
|
||||
farming
|
|
@ -1,52 +0,0 @@
|
|||
farming.seeds = {
|
||||
["farming:wheat_seed"]=20,
|
||||
["farming:cotton_seed"]=30,
|
||||
["farming:pumpkin_seed"]=60,
|
||||
["farming_plus:strawberry_seed"]=30,
|
||||
["farming_plus:rhubarb_seed"]=30,
|
||||
["farming_plus:potatoe_seed"]=30,
|
||||
["farming_plus:tomato_seed"]=30,
|
||||
["farming_plus:orange_seed"]=30,
|
||||
["farming_plus:carrot_seed"]=30,
|
||||
}
|
||||
|
||||
-- ========= ALIASES FOR FARMING MOD BY SAPIER =========
|
||||
-- potatoe -> potatoe
|
||||
minetest.register_alias("farming:potatoe_node", "farming_plus:potatoe")
|
||||
--minetest.register_alias("farming:potatoe", "farming:potatoe_item") cant do this
|
||||
minetest.register_alias("farming:potatoe_straw", "farming_plus:potatoe")
|
||||
minetest.register_alias("farming:seed_potatoe", "farming_plus:potatoe_seed")
|
||||
for lvl = 1, 6, 1 do
|
||||
minetest.register_entity(":farming:potatoe_lvl"..lvl, {
|
||||
on_activate = function(self, staticdata)
|
||||
minetest.env:set_node(self.object:getpos(), {name="farming_plus:potatoe_1"})
|
||||
end
|
||||
})
|
||||
end
|
||||
|
||||
-- ========= RUBBER =========
|
||||
dofile(minetest.get_modpath("farming_plus").."/rubber.lua")
|
||||
|
||||
-- ========= STRAWBERRIES =========
|
||||
dofile(minetest.get_modpath("farming_plus").."/strawberries.lua")
|
||||
|
||||
-- ========= RHUBARB =========
|
||||
dofile(minetest.get_modpath("farming_plus").."/rhubarb.lua")
|
||||
|
||||
-- ========= POTATOES =========
|
||||
dofile(minetest.get_modpath("farming_plus").."/potatoes.lua")
|
||||
|
||||
-- ========= TOMATOES =========
|
||||
dofile(minetest.get_modpath("farming_plus").."/tomatoes.lua")
|
||||
|
||||
-- ========= ORANGES =========
|
||||
dofile(minetest.get_modpath("farming_plus").."/oranges.lua")
|
||||
|
||||
-- ========= BANANAS =========
|
||||
dofile(minetest.get_modpath("farming_plus").."/bananas.lua")
|
||||
|
||||
-- ========= CARROTS =========
|
||||
dofile(minetest.get_modpath("farming_plus").."/carrots.lua")
|
||||
|
||||
-- ========= COCOA =========
|
||||
dofile(minetest.get_modpath("farming_plus").."/cocoa.lua")
|
|
@ -1,89 +0,0 @@
|
|||
minetest.register_craftitem("farming_plus:orange_seed", {
|
||||
description = "Orange Seeds",
|
||||
inventory_image = "farming_orange_seed.png",
|
||||
on_place = function(itemstack, placer, pointed_thing)
|
||||
local above = minetest.env:get_node(pointed_thing.above)
|
||||
if above.name == "air" then
|
||||
above.name = "farming_plus:orange_1"
|
||||
minetest.env:set_node(pointed_thing.above, above)
|
||||
itemstack:take_item(1)
|
||||
return itemstack
|
||||
end
|
||||
end
|
||||
})
|
||||
|
||||
minetest.register_node("farming_plus:orange_1", {
|
||||
paramtype = "light",
|
||||
walkable = false,
|
||||
drawtype = "plantlike",
|
||||
drop = "",
|
||||
tiles = {"farming_orange_1.png"},
|
||||
selection_box = {
|
||||
type = "fixed",
|
||||
fixed = {
|
||||
{-0.5, -0.5, -0.5, 0.5, -0.5+3/16, 0.5}
|
||||
},
|
||||
},
|
||||
groups = {snappy=3, flammable=2, not_in_creative_inventory=1},
|
||||
sounds = default.node_sound_leaves_defaults(),
|
||||
})
|
||||
|
||||
minetest.register_node("farming_plus:orange_2", {
|
||||
paramtype = "light",
|
||||
walkable = false,
|
||||
drawtype = "plantlike",
|
||||
drop = "",
|
||||
tiles = {"farming_orange_2.png"},
|
||||
selection_box = {
|
||||
type = "fixed",
|
||||
fixed = {
|
||||
{-0.5, -0.5, -0.5, 0.5, -0.5+8/16, 0.5}
|
||||
},
|
||||
},
|
||||
groups = {snappy=3, flammable=2, not_in_creative_inventory=1},
|
||||
sounds = default.node_sound_leaves_defaults(),
|
||||
})
|
||||
|
||||
minetest.register_node("farming_plus:orange_3", {
|
||||
paramtype = "light",
|
||||
walkable = false,
|
||||
drawtype = "plantlike",
|
||||
drop = "",
|
||||
tiles = {"farming_orange_3.png"},
|
||||
selection_box = {
|
||||
type = "fixed",
|
||||
fixed = {
|
||||
{-0.5, -0.5, -0.5, 0.5, -0.5+14/16, 0.5}
|
||||
},
|
||||
},
|
||||
groups = {snappy=3, flammable=2, not_in_creative_inventory=1},
|
||||
sounds = default.node_sound_leaves_defaults(),
|
||||
})
|
||||
|
||||
minetest.register_node("farming_plus:orange", {
|
||||
paramtype = "light",
|
||||
walkable = false,
|
||||
drawtype = "plantlike",
|
||||
tiles = {"farming_orange_4.png"},
|
||||
drop = {
|
||||
max_items = 6,
|
||||
items = {
|
||||
{ items = {'farming_plus:orange_seed'} },
|
||||
{ items = {'farming_plus:orange_seed'}, rarity = 2},
|
||||
{ items = {'farming_plus:orange_seed'}, rarity = 5},
|
||||
{ items = {'farming_plus:orange_item'} },
|
||||
{ items = {'farming_plus:orange_item'}, rarity = 2 },
|
||||
{ items = {'farming_plus:orange_item'}, rarity = 5 }
|
||||
}
|
||||
},
|
||||
groups = {snappy=3, flammable=2, not_in_creative_inventory=1},
|
||||
sounds = default.node_sound_leaves_defaults(),
|
||||
})
|
||||
|
||||
minetest.register_craftitem("farming_plus:orange_item", {
|
||||
description = "Orange",
|
||||
inventory_image = "farming_orange.png",
|
||||
on_use = minetest.item_eat(4),
|
||||
})
|
||||
|
||||
farming:add_plant("farming_plus:orange", {"farming_plus:orange_1", "farming_plus:orange_2", "farming_plus:orange_3"}, 50, 20)
|
|
@ -1,72 +0,0 @@
|
|||
minetest.register_craftitem("farming_plus:potatoe_seed", {
|
||||
description = "Potatoe Seeds",
|
||||
inventory_image = "farming_potatoe_seed.png",
|
||||
on_place = function(itemstack, placer, pointed_thing)
|
||||
local above = minetest.env:get_node(pointed_thing.above)
|
||||
if above.name == "air" then
|
||||
above.name = "farming_plus:potatoe_1"
|
||||
minetest.env:set_node(pointed_thing.above, above)
|
||||
itemstack:take_item(1)
|
||||
return itemstack
|
||||
end
|
||||
end
|
||||
})
|
||||
|
||||
minetest.register_node("farming_plus:potatoe_1", {
|
||||
paramtype = "light",
|
||||
walkable = false,
|
||||
drawtype = "plantlike",
|
||||
drop = "",
|
||||
tiles = {"farming_potatoe_1.png"},
|
||||
selection_box = {
|
||||
type = "fixed",
|
||||
fixed = {
|
||||
{-0.5, -0.5, -0.5, 0.5, -0.5+6/16, 0.5}
|
||||
},
|
||||
},
|
||||
groups = {snappy=3, flammable=2, not_in_creative_inventory=1},
|
||||
sounds = default.node_sound_leaves_defaults(),
|
||||
})
|
||||
|
||||
minetest.register_node("farming_plus:potatoe_2", {
|
||||
paramtype = "light",
|
||||
walkable = false,
|
||||
drawtype = "plantlike",
|
||||
drop = "",
|
||||
tiles = {"farming_potatoe_2.png"},
|
||||
selection_box = {
|
||||
type = "fixed",
|
||||
fixed = {
|
||||
{-0.5, -0.5, -0.5, 0.5, -0.5+9/16, 0.5}
|
||||
},
|
||||
},
|
||||
groups = {snappy=3, flammable=2, not_in_creative_inventory=1},
|
||||
sounds = default.node_sound_leaves_defaults(),
|
||||
})
|
||||
|
||||
minetest.register_node("farming_plus:potatoe", {
|
||||
paramtype = "light",
|
||||
walkable = false,
|
||||
drawtype = "plantlike",
|
||||
tiles = {"farming_potatoe_3.png"},
|
||||
drop = {
|
||||
max_items = 6,
|
||||
items = {
|
||||
{ items = {'farming_plus:potatoe_seed'} },
|
||||
{ items = {'farming_plus:potatoe_seed'}, rarity = 2},
|
||||
{ items = {'farming_plus:potatoe_seed'}, rarity = 5},
|
||||
{ items = {'farming_plus:potatoe_item'} },
|
||||
{ items = {'farming_plus:potatoe_item'}, rarity = 2 },
|
||||
{ items = {'farming_plus:potatoe_item'}, rarity = 5 }
|
||||
}
|
||||
},
|
||||
groups = {snappy=3, flammable=2, not_in_creative_inventory=1},
|
||||
sounds = default.node_sound_leaves_defaults(),
|
||||
})
|
||||
|
||||
minetest.register_craftitem("farming_plus:potatoe_item", {
|
||||
description = "Potatoe",
|
||||
inventory_image = "farming_potatoe.png",
|
||||
})
|
||||
|
||||
farming:add_plant("farming_plus:potatoe", {"farming_plus:potatoe_1", "farming_plus:potatoe_2"}, 50, 20)
|
|
@ -1,482 +0,0 @@
|
|||
minetest.register_craftitem(":farming:pumpkin_seed", {
|
||||
description = "Pumpkin Seed",
|
||||
inventory_image = "farming_pumpkin_seed.png",
|
||||
on_place = function(itemstack, placer, pointed_thing)
|
||||
local above = minetest.env:get_node(pointed_thing.above)
|
||||
if above.name == "air" then
|
||||
above.name = "farming:pumpkin_1"
|
||||
minetest.env:set_node(pointed_thing.above, above)
|
||||
itemstack:take_item(1)
|
||||
return itemstack
|
||||
end
|
||||
end
|
||||
})
|
||||
|
||||
minetest.register_node(":farming:pumpkin_1", {
|
||||
paramtype = "light",
|
||||
sunlight_propagates = true,
|
||||
drawtype = "nodebox",
|
||||
drop = "",
|
||||
tiles = {"farming_pumpkin_top.png", "farming_pumpkin_top.png", "farming_pumpkin_side.png", "farming_pumpkin_side.png", "farming_pumpkin_side.png", "farming_pumpkin_side.png"},
|
||||
node_box = {
|
||||
type = "fixed",
|
||||
fixed = {
|
||||
{-0.2, -0.5, -0.2, 0.2, -0.1, 0.2}
|
||||
},
|
||||
},
|
||||
selection_box = {
|
||||
type = "fixed",
|
||||
fixed = {
|
||||
{-0.2, -0.5, -0.2, 0.2, -0.1, 0.2}
|
||||
},
|
||||
},
|
||||
groups = {choppy=2, oddly_breakable_by_hand=2, flammable=2, not_in_creative_inventory=1, plant=1},
|
||||
sounds = default.node_sound_wood_defaults(),
|
||||
})
|
||||
|
||||
minetest.register_node(":farming:pumpkin_2", {
|
||||
paramtype = "light",
|
||||
sunlight_propagates = true,
|
||||
drawtype = "nodebox",
|
||||
drop = "",
|
||||
tiles = {"farming_pumpkin_top.png", "farming_pumpkin_top.png", "farming_pumpkin_side.png", "farming_pumpkin_side.png", "farming_pumpkin_side.png", "farming_pumpkin_side.png"},
|
||||
node_box = {
|
||||
type = "fixed",
|
||||
fixed = {
|
||||
{-0.35, -0.5, -0.35, 0.35, 0.2, 0.35}
|
||||
},
|
||||
},
|
||||
selection_box = {
|
||||
type = "fixed",
|
||||
fixed = {
|
||||
{-0.35, -0.5, -0.35, 0.35, 0.2, 0.35}
|
||||
},
|
||||
},
|
||||
groups = {choppy=2, oddly_breakable_by_hand=2, flammable=2, not_in_creative_inventory=1, plant=1},
|
||||
sounds = default.node_sound_wood_defaults(),
|
||||
})
|
||||
|
||||
minetest.register_node(":farming:pumpkin", {
|
||||
description = "Pumpkin",
|
||||
paramtype2 = "facedir",
|
||||
tiles = {"farming_pumpkin_top.png", "farming_pumpkin_top.png", "farming_pumpkin_side.png", "farming_pumpkin_side.png", "farming_pumpkin_side.png", "farming_pumpkin_side.png"},
|
||||
groups = {choppy=2, oddly_breakable_by_hand=2, flammable=2, plant=1},
|
||||
sounds = default.node_sound_wood_defaults(),
|
||||
|
||||
on_punch = function(pos, node, puncher)
|
||||
local tool = puncher:get_wielded_item():get_name()
|
||||
if tool and tool == "default:sword_wood" or tool == "default:sword_stone" or tool == "default:sword_steel" then
|
||||
node.name = "farming:pumpkin_face"
|
||||
minetest.env:set_node(pos, node)
|
||||
puncher:get_inventory():add_item("main", ItemStack("farming:pumpkin_seed"))
|
||||
if math.random(1, 5) == 1 then
|
||||
puncher:get_inventory():add_item("main", ItemStack("farming:pumpkin_seed"))
|
||||
end
|
||||
end
|
||||
end
|
||||
})
|
||||
|
||||
farming:add_plant("farming:pumpkin", {"farming:pumpkin_1", "farming:pumpkin_2"}, 80, 20)
|
||||
|
||||
minetest.register_node(":farming:pumpkin_face", {
|
||||
description = "Pumpkin",
|
||||
paramtype2 = "facedir",
|
||||
tiles = {"farming_pumpkin_top.png", "farming_pumpkin_top.png", "farming_pumpkin_side.png", "farming_pumpkin_side.png", "farming_pumpkin_side.png", "farming_pumpkin_face.png"},
|
||||
groups = {choppy=2, oddly_breakable_by_hand=2, flammable=2},
|
||||
sounds = default.node_sound_wood_defaults(),
|
||||
})
|
||||
|
||||
minetest.register_node(":farming:pumpkin_face_light", {
|
||||
description = "Pumpkin",
|
||||
paramtype2 = "facedir",
|
||||
light_source = LIGHT_MAX-2,
|
||||
tiles = {"farming_pumpkin_top.png", "farming_pumpkin_top.png", "farming_pumpkin_side.png", "farming_pumpkin_side.png", "farming_pumpkin_side.png", "farming_pumpkin_face_light.png"},
|
||||
groups = {choppy=2, oddly_breakable_by_hand=2, flammable=2},
|
||||
sounds = default.node_sound_wood_defaults(),
|
||||
})
|
||||
|
||||
minetest.register_craft({
|
||||
type = "shapeless",
|
||||
output = "farming:pumpkin_face_light",
|
||||
recipe = {"farming:pumpkin_face", "default:torch"}
|
||||
})
|
||||
|
||||
-- ========= BIG PUMPKIN =========
|
||||
minetest.register_node(":farming:big_pumpkin", {
|
||||
description = "Big Pumpkin",
|
||||
paramtype2 = "facedir",
|
||||
tiles = {"farming_pumpkin_big_side.png"},
|
||||
selection_box = {
|
||||
type = "fixed",
|
||||
fixed = {
|
||||
{-1, -0.5, -1, 1, 1.5, 1}
|
||||
}
|
||||
},
|
||||
groups = {choppy=1, oddly_breakable_by_hand=1, flammable=2, plant=1},
|
||||
sounds = default.node_sound_wood_defaults(),
|
||||
|
||||
after_place_node = function(pos, placer)
|
||||
for dx=-1,1 do
|
||||
for dy=0,1 do
|
||||
for dz=-1,1 do
|
||||
pos.x = pos.x+dx
|
||||
pos.y = pos.y+dy
|
||||
pos.z = pos.z+dz
|
||||
if dx ~= 0 or dy ~= 0 or dz ~= 0 then
|
||||
if minetest.env:get_node(pos).name ~= "air" then
|
||||
pos.x = pos.x-dx
|
||||
pos.y = pos.y-dy
|
||||
pos.z = pos.z-dz
|
||||
minetest.env:remove_node(pos)
|
||||
minetest.after(0.1, function(placer)
|
||||
local inv = placer:get_inventory()
|
||||
local index = placer:get_wield_index()
|
||||
inv:set_stack("main", index, ItemStack("farming:big_pumpkin"))
|
||||
end, placer)
|
||||
return
|
||||
end
|
||||
end
|
||||
pos.x = pos.x-dx
|
||||
pos.y = pos.y-dy
|
||||
pos.z = pos.z-dz
|
||||
end
|
||||
end
|
||||
end
|
||||
for dy=0,1 do
|
||||
pos.y = pos.y+dy
|
||||
pos.z = pos.z+1
|
||||
minetest.env:set_node(pos, {name="farming:big_pumpkin_side", param2=2})
|
||||
pos.x = pos.x-1
|
||||
minetest.env:set_node(pos, {name="farming:big_pumpkin_corner", param2=2})
|
||||
pos.x = pos.x+1
|
||||
pos.z = pos.z-2
|
||||
minetest.env:set_node(pos, {name="farming:big_pumpkin_side", param2=4})
|
||||
pos.x = pos.x+1
|
||||
minetest.env:set_node(pos, {name="farming:big_pumpkin_corner", param2=4})
|
||||
pos.z = pos.z+1
|
||||
minetest.env:set_node(pos, {name="farming:big_pumpkin_side", param2=3})
|
||||
pos.z = pos.z+1
|
||||
minetest.env:set_node(pos, {name="farming:big_pumpkin_corner", param2=3})
|
||||
pos.z = pos.z-1
|
||||
pos.x = pos.x-2
|
||||
minetest.env:set_node(pos, {name="farming:big_pumpkin_side", param2=1})
|
||||
pos.z = pos.z-1
|
||||
minetest.env:set_node(pos, {name="farming:big_pumpkin_corner", param2=1})
|
||||
pos.z = pos.z+1
|
||||
pos.x = pos.x+1
|
||||
pos.y = pos.y-dy
|
||||
end
|
||||
pos.y = pos.y+1
|
||||
minetest.env:set_node(pos, {name="farming:big_pumpkin_top"})
|
||||
end,
|
||||
|
||||
after_destruct = function(pos, oldnode)
|
||||
for dx=-1,1 do
|
||||
for dy=0,1 do
|
||||
for dz=-1,1 do
|
||||
pos.x = pos.x+dx
|
||||
pos.y = pos.y+dy
|
||||
pos.z = pos.z+dz
|
||||
local name = minetest.env:get_node(pos).name
|
||||
if string.find(name, "farming:big_pumpkin") then
|
||||
minetest.env:remove_node(pos)
|
||||
end
|
||||
pos.x = pos.x-dx
|
||||
pos.y = pos.y-dy
|
||||
pos.z = pos.z-dz
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
})
|
||||
|
||||
minetest.register_node(":farming:big_pumpkin_side", {
|
||||
paramtype = "light",
|
||||
sunlight_propagates = true,
|
||||
paramtype2 = "facedir",
|
||||
tiles = {"farming_pumpkin_big_top_side.png", "farming_pumpkin_big_side.png"},
|
||||
drawtype = "nodebox",
|
||||
node_box = {
|
||||
type = "fixed",
|
||||
fixed = {
|
||||
{-0.5, -0.5, 0, 0.5, 0.5, 0.5}
|
||||
}
|
||||
},
|
||||
selection_box = {
|
||||
type = "fixed",
|
||||
fixed = {
|
||||
{0, 0, 0, 0, 0, 0}
|
||||
}
|
||||
},
|
||||
groups = {not_in_creative_inventory=1, plant=1},
|
||||
})
|
||||
minetest.register_node(":farming:big_pumpkin_corner", {
|
||||
paramtype = "light",
|
||||
sunlight_propagates = true,
|
||||
paramtype2 = "facedir",
|
||||
tiles = {"farming_pumpkin_big_top_corner.png", "farming_pumpkin_big_side.png"},
|
||||
drawtype = "nodebox",
|
||||
node_box = {
|
||||
type = "fixed",
|
||||
fixed = {
|
||||
{-0.5, -0.5, 0, 0, 0.5, 0.5}
|
||||
}
|
||||
},
|
||||
selection_box = {
|
||||
type = "fixed",
|
||||
fixed = {
|
||||
{0, 0, 0, 0, 0, 0}
|
||||
}
|
||||
},
|
||||
groups = {not_in_creative_inventory=1, plant=1},
|
||||
})
|
||||
|
||||
minetest.register_node(":farming:big_pumpkin_top", {
|
||||
paramtype = "light",
|
||||
sunlight_propagates = true,
|
||||
tiles = {"farming_pumpkin_big_top.png"},
|
||||
selection_box = {
|
||||
type = "fixed",
|
||||
fixed = {
|
||||
{0, 0, 0, 0, 0, 0}
|
||||
}
|
||||
},
|
||||
groups = {not_in_creative_inventory=1, plant=1},
|
||||
})
|
||||
|
||||
minetest.register_craft({
|
||||
type = "shapeless",
|
||||
output = "farming:big_pumpkin",
|
||||
recipe = {"bucket:bucket_water", "farming:pumpkin"},
|
||||
replacements = {
|
||||
{"bucket:bucket_water", "bucket:bucket_empty"}
|
||||
}
|
||||
})
|
||||
|
||||
-- ========= SCARECROW =========
|
||||
local box1 = {
|
||||
{-1, -8, -1, 1, 8, 1},
|
||||
}
|
||||
|
||||
local box2 = {
|
||||
{-1, -8, -1, 1, 8, 1},
|
||||
{-12, -8, -1, 12, -7, 1},
|
||||
{-5, -2, -5, 5, 8, 5}
|
||||
}
|
||||
|
||||
for j,list in ipairs(box1) do
|
||||
for i,int in ipairs(list) do
|
||||
list[i] = int/16
|
||||
end
|
||||
box1[j] = list
|
||||
end
|
||||
|
||||
for j,list in ipairs(box2) do
|
||||
for i,int in ipairs(list) do
|
||||
list[i] = int/16
|
||||
end
|
||||
box2[j] = list
|
||||
end
|
||||
|
||||
minetest.register_node(":farming:scarecrow", {
|
||||
description = "Scarecrow",
|
||||
paramtype = "light",
|
||||
sunlight_propagates = true,
|
||||
paramtype2 = "facedir",
|
||||
tiles = {"farming_scarecrow_top.png", "farming_scarecrow_top.png", "farming_scarecrow_side.png", "farming_scarecrow_side.png", "farming_scarecrow_side.png", "farming_scarecrow_front.png"},
|
||||
drawtype = "nodebox",
|
||||
node_box = {
|
||||
type = "fixed",
|
||||
fixed = box2
|
||||
},
|
||||
selection_box = {
|
||||
type = "fixed",
|
||||
fixed = {
|
||||
{-12/16, -1.5, -0.5, 12/16, 0.5, 0.5}
|
||||
}
|
||||
},
|
||||
groups = {choppy=2, oddly_breakable_by_hand=2, flammable=2},
|
||||
|
||||
after_place_node = function(pos, placer)
|
||||
local node = minetest.env:get_node(pos)
|
||||
local param2 = node.param2
|
||||
pos.y = pos.y+1
|
||||
if minetest.env:get_node(pos).name ~= "air" then
|
||||
pos.y = pos.y-1
|
||||
minetest.env:remove_node(pos)
|
||||
minetest.after(0.1, function(placer)
|
||||
local inv = placer:get_inventory()
|
||||
local index = placer:get_wield_index()
|
||||
inv:set_stack("main", index, ItemStack("farming:scarecrow"))
|
||||
end, placer)
|
||||
return
|
||||
end
|
||||
minetest.env:set_node(pos, node)
|
||||
pos.y = pos.y-1
|
||||
node.name = "farming:scarecrow_bottom"
|
||||
minetest.env:set_node(pos, node)
|
||||
end,
|
||||
|
||||
after_destruct = function(pos, oldnode)
|
||||
pos.y = pos.y-1
|
||||
if minetest.env:get_node(pos).name == "farming:scarecrow_bottom" then
|
||||
minetest.env:remove_node(pos)
|
||||
end
|
||||
end
|
||||
})
|
||||
|
||||
minetest.register_node(":farming:scarecrow_bottom", {
|
||||
paramtype = "light",
|
||||
sunlight_propagates = true,
|
||||
paramtype2 = "facedir",
|
||||
tiles = {"default_wood.png"},
|
||||
drawtype = "nodebox",
|
||||
node_box = {
|
||||
type = "fixed",
|
||||
fixed = box1
|
||||
},
|
||||
groups = {not_in_creative_inventory=1},
|
||||
selection_box = {
|
||||
type = "fixed",
|
||||
fixed = {
|
||||
{0, 0, 0, 0, 0, 0}
|
||||
}
|
||||
}
|
||||
})
|
||||
|
||||
minetest.register_craft({
|
||||
output = "farming:scarecrow",
|
||||
recipe = {
|
||||
{"", "farming:pumpkin_face", "",},
|
||||
{"default:stick", "default:stick", "default:stick",},
|
||||
{"", "default:stick", "",}
|
||||
}
|
||||
})
|
||||
|
||||
minetest.register_node(":farming:scarecrow_light", {
|
||||
description = "Scarecrow",
|
||||
paramtype = "light",
|
||||
sunlight_propagates = true,
|
||||
paramtype2 = "facedir",
|
||||
light_source = LIGHT_MAX-2,
|
||||
tiles = {"farming_scarecrow_top.png", "farming_scarecrow_top.png", "farming_scarecrow_side.png", "farming_scarecrow_side.png", "farming_scarecrow_side.png", "farming_scarecrow_front_light.png"},
|
||||
drawtype = "nodebox",
|
||||
node_box = {
|
||||
type = "fixed",
|
||||
fixed = box2
|
||||
},
|
||||
selection_box = {
|
||||
type = "fixed",
|
||||
fixed = {
|
||||
{-12/16, -1.5, -0.5, 12/16, 0.5, 0.5}
|
||||
}
|
||||
},
|
||||
groups = {choppy=2, oddly_breakable_by_hand=2, flammable=2},
|
||||
|
||||
after_place_node = function(pos, placer)
|
||||
local node = minetest.env:get_node(pos)
|
||||
local param2 = node.param2
|
||||
pos.y = pos.y+1
|
||||
if minetest.env:get_node(pos).name ~= "air" then
|
||||
pos.y = pos.y-1
|
||||
minetest.env:remove_node(pos)
|
||||
minetest.after(0.1, function(placer)
|
||||
local inv = placer:get_inventory()
|
||||
local index = placer:get_wield_index()
|
||||
inv:set_stack("main", index, ItemStack("farming:scarecrow_light"))
|
||||
end, placer)
|
||||
return
|
||||
end
|
||||
minetest.env:set_node(pos, node)
|
||||
pos.y = pos.y-1
|
||||
node.name = "farming:scarecrow_bottom"
|
||||
minetest.env:set_node(pos, node)
|
||||
end,
|
||||
|
||||
after_destruct = function(pos, oldnode)
|
||||
pos.y = pos.y-1
|
||||
if minetest.env:get_node(pos).name == "farming:scarecrow_bottom" then
|
||||
minetest.env:remove_node(pos)
|
||||
end
|
||||
end
|
||||
})
|
||||
|
||||
minetest.register_craft({
|
||||
output = "farming:scarecrow_light",
|
||||
recipe = {
|
||||
{"", "farming:pumpkin_face_light", "",},
|
||||
{"default:stick", "default:stick", "default:stick",},
|
||||
{"", "default:stick", "",}
|
||||
}
|
||||
})
|
||||
|
||||
--===============
|
||||
minetest.register_craftitem(":farming:pumpkin_bread", {
|
||||
description = "Pumpkin Bread",
|
||||
inventory_image = "farming_bread_pumpkin.png",
|
||||
stack_max = 1,
|
||||
on_use = minetest.item_eat(8)
|
||||
})
|
||||
|
||||
minetest.register_craftitem(":farming:pumpkin_flour", {
|
||||
description = "Pumpkin Flour",
|
||||
inventory_image = "farming_cake_mix_pumpkin.png",
|
||||
})
|
||||
minetest.register_alias("farming:pumpkin_cake_mix", "farming:pumpkin_flour")
|
||||
|
||||
minetest.register_craft({
|
||||
output = "farming:pumpkin_flour",
|
||||
type = "shapeless",
|
||||
recipe = {"farming:flour", "farming:pumpkin"}
|
||||
})
|
||||
|
||||
minetest.register_craft({
|
||||
type = "cooking",
|
||||
output = "farming:pumpkin_bread",
|
||||
recipe = "farming:pumpkin_flour",
|
||||
cooktime = 10
|
||||
})
|
||||
|
||||
|
||||
-- ========= FUEL =========
|
||||
minetest.register_craft({
|
||||
type = "fuel",
|
||||
recipe = "farming:pumpkin_seed",
|
||||
burntime = 1
|
||||
})
|
||||
|
||||
minetest.register_craft({
|
||||
type = "fuel",
|
||||
recipe = "farming:pumpkin",
|
||||
burntime = 5
|
||||
})
|
||||
|
||||
minetest.register_craft({
|
||||
type = "fuel",
|
||||
recipe = "farming:pumpkin_face",
|
||||
burntime = 5
|
||||
})
|
||||
|
||||
minetest.register_craft({
|
||||
type = "fuel",
|
||||
recipe = "farming:pumpkin_face_light",
|
||||
burntime = 7
|
||||
})
|
||||
|
||||
minetest.register_craft({
|
||||
type = "fuel",
|
||||
recipe = "farming:big_pumpkin",
|
||||
burntime = 10
|
||||
})
|
||||
|
||||
minetest.register_craft({
|
||||
type = "fuel",
|
||||
recipe = "farming:scarecrow",
|
||||
burntime = 5
|
||||
})
|
||||
|
||||
minetest.register_craft({
|
||||
type = "fuel",
|
||||
recipe = "farming:scarecrow_light",
|
||||
burntime = 5
|
||||
})
|
|
@ -1,72 +0,0 @@
|
|||
minetest.register_craftitem("farming_plus:rhubarb_seed", {
|
||||
description = "Rhubarb Seeds",
|
||||
inventory_image = "farming_rhubarb_seed.png",
|
||||
on_place = function(itemstack, placer, pointed_thing)
|
||||
local above = minetest.env:get_node(pointed_thing.above)
|
||||
if above.name == "air" then
|
||||
above.name = "farming_plus:rhubarb_1"
|
||||
minetest.env:set_node(pointed_thing.above, above)
|
||||
itemstack:take_item(1)
|
||||
return itemstack
|
||||
end
|
||||
end
|
||||
})
|
||||
|
||||
minetest.register_node("farming_plus:rhubarb_1", {
|
||||
paramtype = "light",
|
||||
walkable = false,
|
||||
drawtype = "plantlike",
|
||||
drop = "",
|
||||
tiles = {"farming_rhubarb_1.png"},
|
||||
selection_box = {
|
||||
type = "fixed",
|
||||
fixed = {
|
||||
{-0.5, -0.5, -0.5, 0.5, -0.5+5/16, 0.5}
|
||||
},
|
||||
},
|
||||
groups = {snappy=3, flammable=2, not_in_creative_inventory=1},
|
||||
sounds = default.node_sound_leaves_defaults(),
|
||||
})
|
||||
|
||||
minetest.register_node("farming_plus:rhubarb_2", {
|
||||
paramtype = "light",
|
||||
walkable = false,
|
||||
drawtype = "plantlike",
|
||||
drop = "",
|
||||
tiles = {"farming_rhubarb_2.png"},
|
||||
selection_box = {
|
||||
type = "fixed",
|
||||
fixed = {
|
||||
{-0.5, -0.5, -0.5, 0.5, -0.5+11/16, 0.5}
|
||||
},
|
||||
},
|
||||
groups = {snappy=3, flammable=2, not_in_creative_inventory=1},
|
||||
sounds = default.node_sound_leaves_defaults(),
|
||||
})
|
||||
|
||||
minetest.register_node("farming_plus:rhubarb", {
|
||||
paramtype = "light",
|
||||
walkable = false,
|
||||
drawtype = "plantlike",
|
||||
tiles = {"farming_rhubarb_3.png"},
|
||||
drop = {
|
||||
max_items = 6,
|
||||
items = {
|
||||
{ items = {'farming_plus:rhubarb_seed'} },
|
||||
{ items = {'farming_plus:rhubarb_seed'}, rarity = 2},
|
||||
{ items = {'farming_plus:rhubarb_seed'}, rarity = 5},
|
||||
{ items = {'farming_plus:rhubarb_item'} },
|
||||
{ items = {'farming_plus:rhubarb_item'}, rarity = 2 },
|
||||
{ items = {'farming_plus:rhubarb_item'}, rarity = 5 }
|
||||
}
|
||||
},
|
||||
groups = {snappy=3, flammable=2, not_in_creative_inventory=1},
|
||||
sounds = default.node_sound_leaves_defaults(),
|
||||
})
|
||||
|
||||
minetest.register_craftitem("farming_plus:rhubarb_item", {
|
||||
description = "Rhubarb",
|
||||
inventory_image = "farming_rhubarb.png",
|
||||
})
|
||||
|
||||
farming:add_plant("farming_plus:rhubarb", {"farming_plus:rhubarb_1", "farming_plus:rhubarb_2"}, 50, 20)
|
|
@ -1,104 +0,0 @@
|
|||
minetest.register_node("farming_plus:rubber_sapling", {
|
||||
description = "Rubber Tree Sapling",
|
||||
drawtype = "plantlike",
|
||||
tiles = {"farming_rubber_sapling.png"},
|
||||
inventory_image = "farming_rubber_sapling.png",
|
||||
wield_image = "farming_rubber_sapling.png",
|
||||
paramtype = "light",
|
||||
walkable = false,
|
||||
groups = {dig_immediate=3,flammable=2},
|
||||
sounds = default.node_sound_defaults(),
|
||||
})
|
||||
|
||||
minetest.register_node("farming_plus:rubber_tree_full", {
|
||||
description = "Rubber Tree",
|
||||
tiles = {"default_tree_top.png", "default_tree_top.png", "farming_rubber_tree_full.png"},
|
||||
groups = {tree=1,snappy=1,choppy=2,oddly_breakable_by_hand=1,flammable=2},
|
||||
drop = "default:tree",
|
||||
sounds = default.node_sound_wood_defaults(),
|
||||
|
||||
on_dig = function(pos, node, digger)
|
||||
minetest.node_dig(pos, node, digger)
|
||||
minetest.env:remove_node(pos)
|
||||
end,
|
||||
|
||||
after_destruct = function(pos, oldnode)
|
||||
oldnode.name = "farming_plus:rubber_tree_empty"
|
||||
minetest.env:set_node(pos, oldnode)
|
||||
end
|
||||
})
|
||||
|
||||
|
||||
minetest.register_node("farming_plus:rubber_tree_empty", {
|
||||
tiles = {"default_tree_top.png", "default_tree_top.png", "farming_rubber_tree_empty.png"},
|
||||
groups = {tree=1,snappy=1,choppy=2,oddly_breakable_by_hand=1,flammable=2, not_in_creative_inventory=1},
|
||||
drop = "default:tree",
|
||||
sounds = default.node_sound_wood_defaults(),
|
||||
})
|
||||
|
||||
minetest.register_abm({
|
||||
nodenames = {"farming_plus:rubber_tree_empty"},
|
||||
interval = 60,
|
||||
chance = 15,
|
||||
action = function(pos, node)
|
||||
node.name = "farming_plus:rubber_tree_full"
|
||||
minetest.env:set_node(pos, node)
|
||||
end
|
||||
})
|
||||
|
||||
minetest.register_node("farming_plus:rubber_leaves", {
|
||||
drawtype = "allfaces_optional",
|
||||
visual_scale = 1.3,
|
||||
tiles = {"default_leaves.png"},
|
||||
paramtype = "light",
|
||||
groups = {snappy=3, leafdecay=3, flammable=2, not_in_creative_inventory=1},
|
||||
drop = {
|
||||
max_items = 1,
|
||||
items = {
|
||||
{
|
||||
items = {'farming_plus:rubber_sapling'},
|
||||
rarity = 20,
|
||||
},
|
||||
}
|
||||
},
|
||||
sounds = default.node_sound_leaves_defaults(),
|
||||
})
|
||||
|
||||
minetest.register_abm({
|
||||
nodenames = {"farming_plus:rubber_sapling"},
|
||||
interval = 60,
|
||||
chance = 20,
|
||||
action = function(pos, node)
|
||||
farming:generate_tree(pos, "farming_plus:rubber_tree_full", "farming_plus:rubber_leaves", {"default:dirt", "default:dirt_with_grass"})
|
||||
end
|
||||
})
|
||||
|
||||
minetest.register_on_generated(function(minp, maxp, blockseed)
|
||||
if math.random(1, 100) > 5 then
|
||||
return
|
||||
end
|
||||
local tmp = {x=(maxp.x-minp.x)/2+minp.x, y=(maxp.y-minp.y)/2+minp.y, z=(maxp.z-minp.z)/2+minp.z}
|
||||
local pos = minetest.env:find_node_near(tmp, maxp.x-minp.x, {"default:dirt_with_grass"})
|
||||
if pos ~= nil then
|
||||
farming:generate_tree({x=pos.x, y=pos.y+1, z=pos.z}, "farming_plus:rubber_tree_full", "farming_plus:rubber_leaves", {"default:dirt", "default:dirt_with_grass"})
|
||||
end
|
||||
end)
|
||||
|
||||
minetest.register_craftitem("farming_plus:bucket_rubber", {
|
||||
description = "Bucket with Caoutchouc",
|
||||
inventory_image = "farming_bucket_rubber.png",
|
||||
stack_max = 1,
|
||||
})
|
||||
|
||||
local bucket_tmp = {
|
||||
source = "farming_plus:rubber_tree_full",
|
||||
itemname = "farming_plus:bucket_rubber"
|
||||
}
|
||||
bucket.liquids["farming_plus:rubber_tree_full"] = bucket_tmp
|
||||
|
||||
-- ========= FUEL =========
|
||||
minetest.register_craft({
|
||||
type = "fuel",
|
||||
recipe = "farming_plus:rubber_sapling",
|
||||
burntime = 10
|
||||
})
|
|
@ -1,89 +0,0 @@
|
|||
minetest.register_craftitem("farming_plus:strawberry_seed", {
|
||||
description = "Strawberry Seeds",
|
||||
inventory_image = "farming_strawberry_seed.png",
|
||||
on_place = function(itemstack, placer, pointed_thing)
|
||||
local above = minetest.env:get_node(pointed_thing.above)
|
||||
if above.name == "air" then
|
||||
above.name = "farming_plus:strawberry_1"
|
||||
minetest.env:set_node(pointed_thing.above, above)
|
||||
itemstack:take_item(1)
|
||||
return itemstack
|
||||
end
|
||||
end
|
||||
})
|
||||
|
||||
minetest.register_node("farming_plus:strawberry_1", {
|
||||
paramtype = "light",
|
||||
walkable = false,
|
||||
drawtype = "plantlike",
|
||||
drop = "",
|
||||
tiles = {"farming_strawberry_1.png"},
|
||||
selection_box = {
|
||||
type = "fixed",
|
||||
fixed = {
|
||||
{-0.5, -0.5, -0.5, 0.5, -0.5+9/16, 0.5}
|
||||
},
|
||||
},
|
||||
groups = {snappy=3, flammable=2, not_in_creative_inventory=1},
|
||||
sounds = default.node_sound_leaves_defaults(),
|
||||
})
|
||||
|
||||
minetest.register_node("farming_plus:strawberry_2", {
|
||||
paramtype = "light",
|
||||
walkable = false,
|
||||
drawtype = "plantlike",
|
||||
drop = "",
|
||||
tiles = {"farming_strawberry_2.png"},
|
||||
selection_box = {
|
||||
type = "fixed",
|
||||
fixed = {
|
||||
{-0.5, -0.5, -0.5, 0.5, -0.5+12/16, 0.5}
|
||||
},
|
||||
},
|
||||
groups = {snappy=3, flammable=2, not_in_creative_inventory=1},
|
||||
sounds = default.node_sound_leaves_defaults(),
|
||||
})
|
||||
|
||||
minetest.register_node("farming_plus:strawberry_3", {
|
||||
paramtype = "light",
|
||||
walkable = false,
|
||||
drawtype = "plantlike",
|
||||
drop = "",
|
||||
tiles = {"farming_strawberry_3.png"},
|
||||
selection_box = {
|
||||
type = "fixed",
|
||||
fixed = {
|
||||
{-0.5, -0.5, -0.5, 0.5, -0.5+14/16, 0.5}
|
||||
},
|
||||
},
|
||||
groups = {snappy=3, flammable=2, not_in_creative_inventory=1},
|
||||
sounds = default.node_sound_leaves_defaults(),
|
||||
})
|
||||
|
||||
minetest.register_node("farming_plus:strawberry", {
|
||||
paramtype = "light",
|
||||
walkable = false,
|
||||
drawtype = "plantlike",
|
||||
tiles = {"farming_strawberry_4.png"},
|
||||
drop = {
|
||||
max_items = 6,
|
||||
items = {
|
||||
{ items = {'farming_plus:strawberry_seed'} },
|
||||
{ items = {'farming_plus:strawberry_seed'}, rarity = 2},
|
||||
{ items = {'farming_plus:strawberry_seed'}, rarity = 5},
|
||||
{ items = {'farming_plus:strawberry_item'} },
|
||||
{ items = {'farming_plus:strawberry_item'}, rarity = 2 },
|
||||
{ items = {'farming_plus:strawberry_item'}, rarity = 5 }
|
||||
}
|
||||
},
|
||||
groups = {snappy=3, flammable=2, not_in_creative_inventory=1},
|
||||
sounds = default.node_sound_leaves_defaults(),
|
||||
})
|
||||
|
||||
minetest.register_craftitem("farming_plus:strawberry_item", {
|
||||
description = "Strawberry",
|
||||
inventory_image = "farming_strawberry.png",
|
||||
on_use = minetest.item_eat(2),
|
||||
})
|
||||
|
||||
farming:add_plant("farming_plus:strawberry", {"farming_plus:strawberry_1", "farming_plus:strawberry_2", "farming_plus:strawberry_3"}, 50, 20)
|
Before Width: | Height: | Size: 515 B |
Before Width: | Height: | Size: 621 B |
Before Width: | Height: | Size: 647 B |
Before Width: | Height: | Size: 511 B |
Before Width: | Height: | Size: 317 B |
Before Width: | Height: | Size: 343 B |
Before Width: | Height: | Size: 575 B |
Before Width: | Height: | Size: 438 B |
Before Width: | Height: | Size: 453 B |
Before Width: | Height: | Size: 507 B |
Before Width: | Height: | Size: 550 B |
Before Width: | Height: | Size: 476 B |
Before Width: | Height: | Size: 535 B |
Before Width: | Height: | Size: 184 B |
Before Width: | Height: | Size: 644 B |
Before Width: | Height: | Size: 504 B |
Before Width: | Height: | Size: 430 B |
Before Width: | Height: | Size: 468 B |
Before Width: | Height: | Size: 544 B |
Before Width: | Height: | Size: 540 B |
Before Width: | Height: | Size: 281 B |
Before Width: | Height: | Size: 525 B |
Before Width: | Height: | Size: 473 B |
Before Width: | Height: | Size: 502 B |
Before Width: | Height: | Size: 292 B |
Before Width: | Height: | Size: 221 B |
Before Width: | Height: | Size: 525 B |
Before Width: | Height: | Size: 473 B |
Before Width: | Height: | Size: 502 B |
Before Width: | Height: | Size: 292 B |
Before Width: | Height: | Size: 221 B |
Before Width: | Height: | Size: 600 B |
Before Width: | Height: | Size: 600 B |
Before Width: | Height: | Size: 289 B |
Before Width: | Height: | Size: 378 B |
Before Width: | Height: | Size: 622 B |
Before Width: | Height: | Size: 632 B |
Before Width: | Height: | Size: 312 B |
Before Width: | Height: | Size: 627 B |
Before Width: | Height: | Size: 623 B |
Before Width: | Height: | Size: 502 B |
Before Width: | Height: | Size: 530 B |
Before Width: | Height: | Size: 365 B |
Before Width: | Height: | Size: 301 B |
Before Width: | Height: | Size: 219 B |
Before Width: | Height: | Size: 333 B |
Before Width: | Height: | Size: 835 B |
Before Width: | Height: | Size: 808 B |
Before Width: | Height: | Size: 634 B |
Before Width: | Height: | Size: 641 B |
Before Width: | Height: | Size: 613 B |
Before Width: | Height: | Size: 639 B |
Before Width: | Height: | Size: 250 B |
Before Width: | Height: | Size: 356 B |
Before Width: | Height: | Size: 342 B |
Before Width: | Height: | Size: 357 B |
Before Width: | Height: | Size: 400 B |
Before Width: | Height: | Size: 212 B |
Before Width: | Height: | Size: 581 B |
Before Width: | Height: | Size: 482 B |
Before Width: | Height: | Size: 506 B |
Before Width: | Height: | Size: 578 B |
Before Width: | Height: | Size: 591 B |
Before Width: | Height: | Size: 221 B |
Before Width: | Height: | Size: 591 B |
|
@ -1,89 +0,0 @@
|
|||
minetest.register_craftitem("farming_plus:tomato_seed", {
|
||||
description = "Tomato Seeds",
|
||||
inventory_image = "farming_tomato_seed.png",
|
||||
on_place = function(itemstack, placer, pointed_thing)
|
||||
local above = minetest.env:get_node(pointed_thing.above)
|
||||
if above.name == "air" then
|
||||
above.name = "farming_plus:tomato_1"
|
||||
minetest.env:set_node(pointed_thing.above, above)
|
||||
itemstack:take_item(1)
|
||||
return itemstack
|
||||
end
|
||||
end
|
||||
})
|
||||
|
||||
minetest.register_node("farming_plus:tomato_1", {
|
||||
paramtype = "light",
|
||||
walkable = false,
|
||||
drawtype = "plantlike",
|
||||
drop = "",
|
||||
tiles = {"farming_tomato_1.png"},
|
||||
selection_box = {
|
||||
type = "fixed",
|
||||
fixed = {
|
||||
{-0.5, -0.5, -0.5, 0.5, -0.5+5/16, 0.5}
|
||||
},
|
||||
},
|
||||
groups = {snappy=3, flammable=2, not_in_creative_inventory=1},
|
||||
sounds = default.node_sound_leaves_defaults(),
|
||||
})
|
||||
|
||||
minetest.register_node("farming_plus:tomato_2", {
|
||||
paramtype = "light",
|
||||
walkable = false,
|
||||
drawtype = "plantlike",
|
||||
drop = "",
|
||||
tiles = {"farming_tomato_2.png"},
|
||||
selection_box = {
|
||||
type = "fixed",
|
||||
fixed = {
|
||||
{-0.5, -0.5, -0.5, 0.5, -0.5+8/16, 0.5}
|
||||
},
|
||||
},
|
||||
groups = {snappy=3, flammable=2, not_in_creative_inventory=1},
|
||||
sounds = default.node_sound_leaves_defaults(),
|
||||
})
|
||||
|
||||
minetest.register_node("farming_plus:tomato_3", {
|
||||
paramtype = "light",
|
||||
walkable = false,
|
||||
drawtype = "plantlike",
|
||||
drop = "",
|
||||
tiles = {"farming_tomato_3.png"},
|
||||
selection_box = {
|
||||
type = "fixed",
|
||||
fixed = {
|
||||
{-0.5, -0.5, -0.5, 0.5, -0.5+13/16, 0.5}
|
||||
},
|
||||
},
|
||||
groups = {snappy=3, flammable=2, not_in_creative_inventory=1},
|
||||
sounds = default.node_sound_leaves_defaults(),
|
||||
})
|
||||
|
||||
minetest.register_node("farming_plus:tomato", {
|
||||
paramtype = "light",
|
||||
walkable = false,
|
||||
drawtype = "plantlike",
|
||||
tiles = {"farming_tomato_4.png"},
|
||||
drop = {
|
||||
max_items = 6,
|
||||
items = {
|
||||
{ items = {'farming_plus:tomato_seed'} },
|
||||
{ items = {'farming_plus:tomato_seed'}, rarity = 2},
|
||||
{ items = {'farming_plus:tomato_seed'}, rarity = 5},
|
||||
{ items = {'farming_plus:tomato_item'} },
|
||||
{ items = {'farming_plus:tomato_item'}, rarity = 2 },
|
||||
{ items = {'farming_plus:tomato_item'}, rarity = 5 }
|
||||
}
|
||||
},
|
||||
groups = {snappy=3, flammable=2, not_in_creative_inventory=1},
|
||||
sounds = default.node_sound_leaves_defaults(),
|
||||
})
|
||||
|
||||
minetest.register_craftitem("farming_plus:tomato_item", {
|
||||
description = "Tomato",
|
||||
inventory_image = "farming_tomato.png",
|
||||
on_use = minetest.item_eat(4),
|
||||
})
|
||||
|
||||
farming:add_plant("farming_plus:tomato", {"farming_plus:tomato_1", "farming_plus:tomato_2", "farming_plus:tomato_3"}, 50, 20)
|
|
@ -1,40 +0,0 @@
|
|||
minetest.register_node(":farming:weed", {
|
||||
description = "Weed",
|
||||
paramtype = "light",
|
||||
sunlight_propagates = true,
|
||||
walkable = false,
|
||||
drawtype = "plantlike",
|
||||
tiles = {"farming_weed.png"},
|
||||
inventory_image = "farming_weed.png",
|
||||
selection_box = {
|
||||
type = "fixed",
|
||||
fixed = {
|
||||
{-0.5, -0.5, -0.5, 0.5, -0.5+4/16, 0.5}
|
||||
},
|
||||
},
|
||||
groups = {snappy=3, flammable=2, plant=1},
|
||||
sounds = default.node_sound_leaves_defaults()
|
||||
})
|
||||
|
||||
minetest.register_abm({
|
||||
nodenames = {"farming:soil_wet", "farming:soil"},
|
||||
interval = 50,
|
||||
chance = 10,
|
||||
action = function(pos, node)
|
||||
if minetest.env:find_node_near(pos, 4, {"farming:scarecrow", "farming:scarecrow_light"}) ~= nil then
|
||||
return
|
||||
end
|
||||
pos.y = pos.y+1
|
||||
if minetest.env:get_node(pos).name == "air" then
|
||||
node.name = "farming:weed"
|
||||
minetest.env:set_node(pos, node)
|
||||
end
|
||||
end
|
||||
})
|
||||
|
||||
-- ========= FUEL =========
|
||||
minetest.register_craft({
|
||||
type = "fuel",
|
||||
recipe = "farming:weed",
|
||||
burntime = 1
|
||||
})
|
|
@ -0,0 +1 @@
|
|||
Subproject commit 476a60b848e6776574b86da2daa8889f2c787d7b
|
|
@ -1 +0,0 @@
|
|||
*~
|
|
@ -1,17 +0,0 @@
|
|||
DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE
|
||||
Version 2, December 2004
|
||||
|
||||
Copyright (C) 2004 Sam Hocevar <sam@hocevar.net>
|
||||
|
||||
Everyone is permitted to copy and distribute verbatim or modified
|
||||
copies of this license document, and changing it is allowed as long
|
||||
as the name is changed.
|
||||
|
||||
DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE
|
||||
TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
|
||||
|
||||
0. You just DO WHAT THE FUCK YOU WANT TO.
|
||||
|
||||
----------
|
||||
|
||||
This license is commonly known as "WTFPL".
|
|
@ -1,22 +0,0 @@
|
|||
This mod uses nodeboxes to supply a complete set of 3D pipes and tubes,
|
||||
along devices that work with them.
|
||||
|
||||
See http://vanessae.github.io/pipeworks/ for detailed information about usage of this mod.
|
||||
|
||||
Unlike the previous version of this mod, these pipes are rounded, and when
|
||||
placed, they'll automatically join together as needed. Pipes can go vertically
|
||||
or horizontally, and there are enough nodes defined to allow for all possible
|
||||
connections. Valves and pumps can only be placed horizontally, and will
|
||||
automatically rotate and join with neighboring pipes as objects are added, as
|
||||
well as joining with each other under certain circumstances.
|
||||
|
||||
Pipes come in two variants: one type bears one or more dark windows on each
|
||||
pipe, suggesting they're empty, while the other type bears green-tinted
|
||||
windows, as if full (the two colors should also be easy to select if you want
|
||||
to change them in a paint program). These windows only appear on straight
|
||||
lengths and on certain junctions.
|
||||
|
||||
This mod is a work in progress.
|
||||
|
||||
Please note that owing to the nature of this mod, I have opted to use 64px
|
||||
textures. Anything less just looks terrible.
|
|
@ -1,131 +0,0 @@
|
|||
local autocrafterCache = {} -- caches some recipe data to avoid to call the slow function minetest.get_craft_result() every second
|
||||
|
||||
local function make_inventory_cache(invlist)
|
||||
local l = {}
|
||||
for _, stack in ipairs(invlist) do
|
||||
l[stack:get_name()] = (l[stack:get_name()] or 0) + stack:get_count()
|
||||
end
|
||||
return l
|
||||
end
|
||||
|
||||
local function autocraft(inventory, pos)
|
||||
local recipe = inventory:get_list("recipe")
|
||||
local recipe_last
|
||||
local result
|
||||
local new
|
||||
|
||||
if autocrafterCache[minetest.hash_node_position(pos)] == nil then
|
||||
recipe_last = {}
|
||||
for i = 1, 9 do
|
||||
recipe_last[i] = recipe[i]
|
||||
recipe[i] = ItemStack({name = recipe[i]:get_name(), count = 1})
|
||||
end
|
||||
result, new = minetest.get_craft_result({method = "normal", width = 3, items = recipe})
|
||||
autocrafterCache[minetest.hash_node_position(pos)] = {["recipe"] = recipe, ["result"] = result, ["new"] = new}
|
||||
else
|
||||
local autocrafterCacheEntry = autocrafterCache[minetest.hash_node_position(pos)]
|
||||
recipe_last = autocrafterCacheEntry["recipe"]
|
||||
result = autocrafterCacheEntry["result"]
|
||||
new = autocrafterCacheEntry["new"]
|
||||
local recipeUnchanged = true
|
||||
for i = 1, 9 do
|
||||
if recipe[i]:get_name() ~= recipe_last[i]:get_name() then
|
||||
recipeUnchanged = false
|
||||
break
|
||||
end
|
||||
if recipe[i]:get_count() ~= recipe_last[i]:get_count() then
|
||||
recipeUnchanged = false
|
||||
break
|
||||
end
|
||||
end
|
||||
if recipeUnchanged then
|
||||
else
|
||||
for i = 1, 9 do
|
||||
recipe_last[i] = recipe[i]
|
||||
recipe[i] = ItemStack({name = recipe[i]:get_name(), count = 1})
|
||||
end
|
||||
result, new = minetest.get_craft_result({method = "normal", width = 3, items = recipe})
|
||||
autocrafterCache[minetest.hash_node_position(pos)] = {["recipe"] = recipe, ["result"] = result, ["new"] = new}
|
||||
end
|
||||
end
|
||||
|
||||
if result.item:is_empty() then return end
|
||||
result = result.item
|
||||
if not inventory:room_for_item("dst", result) then return end
|
||||
local to_use = {}
|
||||
for _, item in ipairs(recipe) do
|
||||
if item~= nil and not item:is_empty() then
|
||||
if to_use[item:get_name()] == nil then
|
||||
to_use[item:get_name()] = 1
|
||||
else
|
||||
to_use[item:get_name()] = to_use[item:get_name()]+1
|
||||
end
|
||||
end
|
||||
end
|
||||
local invcache = make_inventory_cache(inventory:get_list("src"))
|
||||
for itemname, number in pairs(to_use) do
|
||||
if (not invcache[itemname]) or invcache[itemname] < number then return end
|
||||
end
|
||||
for itemname, number in pairs(to_use) do
|
||||
for i = 1, number do -- We have to do that since remove_item does not work if count > stack_max
|
||||
inventory:remove_item("src", ItemStack(itemname))
|
||||
end
|
||||
end
|
||||
inventory:add_item("dst", result)
|
||||
for i = 1, 9 do
|
||||
inventory:add_item("dst", new.items[i])
|
||||
end
|
||||
end
|
||||
|
||||
minetest.register_node("pipeworks:autocrafter", {
|
||||
description = "Autocrafter",
|
||||
drawtype = "normal",
|
||||
tiles = {"pipeworks_autocrafter.png"},
|
||||
groups = {snappy = 3, tubedevice = 1, tubedevice_receiver = 1},
|
||||
tube = {insert_object = function(pos, node, stack, direction)
|
||||
local meta = minetest.get_meta(pos)
|
||||
local inv = meta:get_inventory()
|
||||
return inv:add_item("src", stack)
|
||||
end,
|
||||
can_insert = function(pos, node, stack, direction)
|
||||
local meta = minetest.get_meta(pos)
|
||||
local inv = meta:get_inventory()
|
||||
return inv:room_for_item("src", stack)
|
||||
end,
|
||||
input_inventory = "dst",
|
||||
connect_sides = {left = 1, right = 1, front = 1, back = 1, top = 1, bottom = 1}},
|
||||
on_construct = function(pos)
|
||||
local meta = minetest.get_meta(pos)
|
||||
meta:set_string("formspec",
|
||||
"size[8,11]"..
|
||||
"list[current_name;recipe;0,0;3,3;]"..
|
||||
"list[current_name;src;0,3.5;8,3;]"..
|
||||
"list[current_name;dst;4,0;4,3;]"..
|
||||
"list[current_player;main;0,7;8,4;]")
|
||||
meta:set_string("infotext", "Autocrafter")
|
||||
local inv = meta:get_inventory()
|
||||
inv:set_size("src", 3*8)
|
||||
inv:set_size("recipe", 3*3)
|
||||
inv:set_size("dst", 4*3)
|
||||
end,
|
||||
can_dig = function(pos, player)
|
||||
local meta = minetest.get_meta(pos);
|
||||
local inv = meta:get_inventory()
|
||||
return (inv:is_empty("src") and inv:is_empty("recipe") and inv:is_empty("dst"))
|
||||
end,
|
||||
after_place_node = function(pos)
|
||||
pipeworks.scan_for_tube_objects(pos)
|
||||
end,
|
||||
after_dig_node = function(pos)
|
||||
pipeworks.scan_for_tube_objects(pos)
|
||||
autocrafterCache[minetest.hash_node_position(pos)] = nil
|
||||
end
|
||||
})
|
||||
|
||||
minetest.register_abm({nodenames = {"pipeworks:autocrafter"}, interval = 1, chance = 1,
|
||||
action = function(pos, node)
|
||||
local meta = minetest.get_meta(pos)
|
||||
local inv = meta:get_inventory()
|
||||
autocraft(inv, pos)
|
||||
end
|
||||
})
|
|
@ -1,200 +0,0 @@
|
|||
-- autorouting for pipes
|
||||
local tube_table = {[0] = 1, 2, 2, 4, 2, 4, 4, 5, 2, 3, 4, 6, 4, 6, 5, 7, 2, 4, 3, 6, 4, 5, 6, 7, 4, 6, 6, 8, 5, 7, 7, 9, 2, 4, 4, 5, 3, 6, 6, 7, 4, 6, 5, 7, 6, 8, 7, 9, 4, 5, 6, 7, 6, 7, 8, 9, 5, 7, 7, 9, 7, 9, 9, 10}
|
||||
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 = 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
|
||||
minetest.add_node(pos, {name = "pipeworks:pipe_"..tube_table[nsurround]..state,
|
||||
param2 = tube_table_facedirs[nsurround]})
|
||||
end
|
||||
|
||||
function pipeworks.scan_for_pipe_objects(pos)
|
||||
autoroute_pipes({ x=pos.x-1, y=pos.y , z=pos.z })
|
||||
autoroute_pipes({ x=pos.x+1, y=pos.y , z=pos.z })
|
||||
autoroute_pipes({ x=pos.x , y=pos.y-1, z=pos.z })
|
||||
autoroute_pipes({ x=pos.x , y=pos.y+1, z=pos.z })
|
||||
autoroute_pipes({ x=pos.x , y=pos.y , z=pos.z-1 })
|
||||
autoroute_pipes({ x=pos.x , y=pos.y , z=pos.z+1 })
|
||||
autoroute_pipes(pos)
|
||||
end
|
||||
|
||||
-- auto-rotation code for various devices the tubes attach to
|
||||
|
||||
function pipeworks.scan_pipe_surroundings(pos)
|
||||
local pxm=0
|
||||
local pxp=0
|
||||
local pym=0
|
||||
local pyp=0
|
||||
local pzm=0
|
||||
local pzp=0
|
||||
|
||||
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 })
|
||||
|
||||
if (string.find(nxm.name, "pipeworks:pipe_") ~= nil) then pxm=1 end
|
||||
if (string.find(nxp.name, "pipeworks:pipe_") ~= nil) then pxp=1 end
|
||||
if (string.find(nym.name, "pipeworks:pipe_") ~= nil) then pym=1 end
|
||||
if (string.find(nyp.name, "pipeworks:pipe_") ~= nil) then pyp=1 end
|
||||
if (string.find(nzm.name, "pipeworks:pipe_") ~= nil) then pzm=1 end
|
||||
if (string.find(nzp.name, "pipeworks:pipe_") ~= nil) then pzp=1 end
|
||||
|
||||
-- Special handling for valves...
|
||||
|
||||
if (string.find(nxm.name, "pipeworks:valve") ~= nil)
|
||||
and (nxm.param2 == 0 or nxm.param2 == 2) then
|
||||
pxm=1
|
||||
end
|
||||
|
||||
if (string.find(nxp.name, "pipeworks:valve") ~= nil)
|
||||
and (nxp.param2 == 0 or nxp.param2 == 2) then
|
||||
pxp=1
|
||||
end
|
||||
|
||||
if (string.find(nzm.name, "pipeworks:valve") ~= nil)
|
||||
and (nzm.param2 == 1 or nzm.param2 == 3) then
|
||||
pzm=1
|
||||
end
|
||||
|
||||
if (string.find(nzp.name, "pipeworks:valve") ~= nil)
|
||||
and (nzp.param2 == 1 or nzp.param2 == 3) then
|
||||
pzp=1
|
||||
end
|
||||
|
||||
-- ...flow sensors...
|
||||
|
||||
if (string.find(nxm.name, "pipeworks:flow_sensor") ~= nil)
|
||||
and (nxm.param2 == 0 or nxm.param2 == 2) then
|
||||
pxm=1
|
||||
end
|
||||
|
||||
if (string.find(nxp.name, "pipeworks:flow_sensor") ~= nil)
|
||||
and (nxp.param2 == 0 or nxp.param2 == 2) then
|
||||
pxp=1
|
||||
end
|
||||
|
||||
if (string.find(nzm.name, "pipeworks:flow_sensor") ~= nil)
|
||||
and (nzm.param2 == 1 or nzm.param2 == 3) then
|
||||
pzm=1
|
||||
end
|
||||
|
||||
if (string.find(nzp.name, "pipeworks:flow_sensor") ~= nil)
|
||||
and (nzp.param2 == 1 or nzp.param2 == 3) then
|
||||
pzp=1
|
||||
end
|
||||
|
||||
-- ...spigots...
|
||||
|
||||
if (string.find(nxm.name, "pipeworks:spigot") ~= nil)
|
||||
and nxm.param2 == 1 then
|
||||
pxm=1
|
||||
end
|
||||
|
||||
if (string.find(nxp.name, "pipeworks:spigot") ~= nil)
|
||||
and nxp.param2 == 3 then
|
||||
pxp=1
|
||||
end
|
||||
|
||||
if (string.find(nzm.name, "pipeworks:spigot") ~= nil)
|
||||
and nzm.param2 == 0 then
|
||||
pzm=1
|
||||
end
|
||||
|
||||
if (string.find(nzp.name, "pipeworks:spigot") ~= nil)
|
||||
and nzp.param2 == 2 then
|
||||
pzp=1
|
||||
end
|
||||
|
||||
-- ...sealed pipe entry/exit...
|
||||
|
||||
if (string.find(nxm.name, "pipeworks:entry_panel") ~= nil)
|
||||
and (nxm.param2 == 1 or nxm.param2 == 3) then
|
||||
pxm=1
|
||||
end
|
||||
|
||||
if (string.find(nxp.name, "pipeworks:entry_panel") ~= nil)
|
||||
and (nxp.param2 == 1 or nxp.param2 == 3) then
|
||||
pxp=1
|
||||
end
|
||||
|
||||
if (string.find(nzm.name, "pipeworks:entry_panel") ~= nil)
|
||||
and (nzm.param2 == 0 or nzm.param2 == 2) then
|
||||
pzm=1
|
||||
end
|
||||
|
||||
if (string.find(nzp.name, "pipeworks:entry_panel") ~= nil)
|
||||
and (nzp.param2 == 0 or nzp.param2 == 2) then
|
||||
pzp=1
|
||||
end
|
||||
|
||||
if (string.find(nym.name, "pipeworks:entry_panel") ~= nil)
|
||||
and nym.param2 == 13 then
|
||||
pym=1
|
||||
end
|
||||
|
||||
if (string.find(nyp.name, "pipeworks:entry_panel") ~= nil)
|
||||
and nyp.param2 == 13 then
|
||||
pyp=1
|
||||
end
|
||||
|
||||
|
||||
-- ...pumps, grates...
|
||||
|
||||
if (string.find(nym.name, "pipeworks:grating") ~= nil) or
|
||||
(string.find(nym.name, "pipeworks:pump") ~= nil) then
|
||||
pym=1
|
||||
end
|
||||
|
||||
-- ...fountainheads...
|
||||
|
||||
if (string.find(nyp.name, "pipeworks:fountainhead") ~= nil) then
|
||||
pyp=1
|
||||
end
|
||||
|
||||
-- ... and storage tanks.
|
||||
|
||||
if (string.find(nym.name, "pipeworks:storage_tank_") ~= nil) then
|
||||
pym=1
|
||||
end
|
||||
|
||||
if (string.find(nyp.name, "pipeworks:storage_tank_") ~= nil) then
|
||||
pyp=1
|
||||
end
|
||||
|
||||
-- ...extra devices specified via the function's parameters
|
||||
-- ...except that this part is not implemented yet
|
||||
--
|
||||
-- xxx = nxm, nxp, nym, nyp, nzm, or nzp depending on the direction to check
|
||||
-- yyy = pxm, pxp, pym, pyp, pzm, or pzp accordingly.
|
||||
--
|
||||
-- if string.find(xxx.name, "modname:nodename") ~= nil then
|
||||
-- yyy = 1
|
||||
-- end
|
||||
--
|
||||
-- for example:
|
||||
--
|
||||
-- if string.find(nym.name, "aero:outlet") ~= nil then
|
||||
-- pym = 1
|
||||
-- end
|
||||
--
|
||||
|
||||
return pxm+8*pxp+2*pym+16*pyp+4*pzm+32*pzp
|
||||
end
|
||||
|
||||
function pipeworks.look_for_stackable_tanks(pos)
|
||||
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
|
||||
minetest.add_node(pos, { name = "pipeworks:expansion_tank_0", param2 = tym.param2})
|
||||
end
|
||||
end
|
||||
|
|
@ -1,168 +0,0 @@
|
|||
-- autorouting for pneumatic tubes
|
||||
|
||||
local function in_table(table,element)
|
||||
for _,el in ipairs(table) do
|
||||
if el==element then return true end
|
||||
end
|
||||
return false
|
||||
end
|
||||
|
||||
local function is_tube(nodename)
|
||||
return in_table(pipeworks.tubenodes,nodename)
|
||||
end
|
||||
|
||||
if pipeworks == nil then
|
||||
pipeworks = {}
|
||||
end
|
||||
|
||||
--a function for determining which side of the node we are on
|
||||
local function nodeside(node, tubedir)
|
||||
if node and (node.param2 < 0 or node.param2 > 23) then node.param2 = 0 end
|
||||
|
||||
--get a vector pointing back
|
||||
local backdir = minetest.facedir_to_dir(node.param2)
|
||||
|
||||
--check whether the vector is equivalent to the tube direction; if it is, the tube's on the backside
|
||||
if backdir.x == tubedir.x and backdir.y == tubedir.y and backdir.z == tubedir.z then
|
||||
return "back"
|
||||
end
|
||||
|
||||
--check whether the vector is antiparallel with the tube direction; that indicates the front
|
||||
if backdir.x == -tubedir.x and backdir.y == -tubedir.y and backdir.z == -tubedir.z then
|
||||
return "front"
|
||||
end
|
||||
|
||||
--facedir is defined in terms of the top-bottom axis of the node; we'll take advantage of that
|
||||
local topdir = ({[0]={x=0, y=1, z=0},
|
||||
{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}})[math.floor(node.param2/4)]
|
||||
|
||||
--is this the top?
|
||||
if topdir.x == tubedir.x and topdir.y == tubedir.y and topdir.z == tubedir.z then
|
||||
return "top"
|
||||
end
|
||||
|
||||
--or the bottom?
|
||||
if topdir.x == -tubedir.x and topdir.y == -tubedir.y and topdir.z == -tubedir.z then
|
||||
return "bottom"
|
||||
end
|
||||
|
||||
--we shall apply some maths to obtain the right-facing vector
|
||||
local rightdir = {x=topdir.y*backdir.z - backdir.y*topdir.z,
|
||||
y=topdir.z*backdir.x - backdir.z*topdir.x,
|
||||
z=topdir.x*backdir.y - backdir.x*topdir.y}
|
||||
|
||||
--is this the right side?
|
||||
if rightdir.x == tubedir.x and rightdir.y == tubedir.y and rightdir.z == tubedir.z then
|
||||
return "right"
|
||||
end
|
||||
|
||||
--or the left?
|
||||
if rightdir.x == -tubedir.x and rightdir.y == -tubedir.y and rightdir.z == -tubedir.z then
|
||||
return "left"
|
||||
end
|
||||
|
||||
--we should be done by now; initiate panic mode
|
||||
minetest.log("error", "nodeside has been confused by its parameters; see pipeworks autoplace_tubes.lua, line 78")
|
||||
end
|
||||
|
||||
local vts = {0, 3, 1, 4, 2, 5}
|
||||
local tube_table = {[0] = 1, 2, 2, 4, 2, 4, 4, 5, 2, 3, 4, 6, 4, 6, 5, 7, 2, 4, 3, 6, 4, 5, 6, 7, 4, 6, 6, 8, 5, 7, 7, 9, 2, 4, 4, 5, 3, 6, 6, 7, 4, 6, 5, 7, 6, 8, 7, 9, 4, 5, 6, 7, 6, 7, 8, 9, 5, 7, 7, 9, 7, 9, 9, 10}
|
||||
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 = minetest.get_node(pos)
|
||||
if not is_tube(nctr.name) then return end
|
||||
|
||||
local adjustments = {
|
||||
{ x=-1, y=0, z=0 },
|
||||
{ x=1, y=0, z=0 },
|
||||
{ x=0, y=-1, z=0 },
|
||||
{ x=0, y=1, z=0 },
|
||||
{ x=0, y=0, z=-1 },
|
||||
{ x=0, y=0, z=1 }
|
||||
}
|
||||
-- xm = 1, xp = 2, ym = 3, yp = 4, zm = 5, zp = 6
|
||||
|
||||
local positions = {}
|
||||
local nodes = {}
|
||||
for i,adj in ipairs(adjustments) do
|
||||
positions[i] = {x=pos.x+adj.x, y=pos.y+adj.y, z=pos.z+adj.z}
|
||||
nodes[i] = minetest.get_node(positions[i])
|
||||
end
|
||||
|
||||
for i,node in ipairs(nodes) do
|
||||
local idef = minetest.registered_nodes[node.name]
|
||||
-- handle the tubes themselves
|
||||
if is_tube(node.name) then
|
||||
active[i] = 1
|
||||
-- handle new style connectors
|
||||
elseif idef and idef.tube and idef.tube.connect_sides then
|
||||
local dir = adjustments[i]
|
||||
if idef.tube.connect_sides[nodeside(node, {x=-dir.x, y=-dir.y, z=-dir.z})] then active[i] = 1 end
|
||||
end
|
||||
end
|
||||
|
||||
-- all sides checked, now figure which tube to use.
|
||||
|
||||
local nodedef = minetest.registered_nodes[nctr.name]
|
||||
local basename = nodedef.basename
|
||||
local newname
|
||||
if nodedef.style == "old" then
|
||||
local nsurround = ""
|
||||
for i,n in ipairs(active) do
|
||||
nsurround = nsurround .. n
|
||||
end
|
||||
nctr.name = basename.."_"..nsurround
|
||||
elseif nodedef.style == "6d" then
|
||||
local s = 0
|
||||
for i,n in ipairs(active) do
|
||||
if n == 1 then
|
||||
s = s+2^vts[i]
|
||||
end
|
||||
end
|
||||
nctr.name = basename.."_"..tube_table[s]
|
||||
nctr.param2 = tube_table_facedirs[s]
|
||||
end
|
||||
minetest.swap_node(pos, nctr)
|
||||
end
|
||||
|
||||
function pipeworks.scan_for_tube_objects(pos)
|
||||
if not pos or not pos.x or not pos.y or not pos.z then return end
|
||||
tube_autoroute({ x=pos.x-1, y=pos.y , z=pos.z })
|
||||
tube_autoroute({ x=pos.x+1, y=pos.y , z=pos.z })
|
||||
tube_autoroute({ x=pos.x , y=pos.y-1, z=pos.z })
|
||||
tube_autoroute({ x=pos.x , y=pos.y+1, z=pos.z })
|
||||
tube_autoroute({ x=pos.x , y=pos.y , z=pos.z-1 })
|
||||
tube_autoroute({ x=pos.x , y=pos.y , z=pos.z+1 })
|
||||
tube_autoroute(pos)
|
||||
end
|
||||
|
||||
minetest.register_on_placenode(function(pos, newnode, placer, oldnode, itemstack)
|
||||
if minetest.registered_items[newnode.name]
|
||||
and minetest.registered_items[newnode.name].tube
|
||||
and minetest.registered_items[newnode.name].tube.connect_sides then
|
||||
pipeworks.scan_for_tube_objects(pos)
|
||||
end
|
||||
end)
|
||||
|
||||
minetest.register_on_dignode(function(pos, oldnode, digger)
|
||||
if minetest.registered_items[oldnode.name]
|
||||
and minetest.registered_items[oldnode.name].tube
|
||||
and minetest.registered_items[oldnode.name].tube.connect_sides then
|
||||
pipeworks.scan_for_tube_objects(pos)
|
||||
end
|
||||
end)
|
||||
|
||||
if minetest.get_modpath("mesecons_mvps") ~= nil then
|
||||
mesecon:register_on_mvps_move(function(moved_nodes)
|
||||
for _, n in ipairs(moved_nodes) do
|
||||
pipeworks.scan_for_tube_objects(n.pos)
|
||||
pipeworks.scan_for_tube_objects(n.oldpos)
|
||||
end
|
||||
end)
|
||||
end
|
||||
|
|
@ -1,93 +0,0 @@
|
|||
Changelog
|
||||
---------
|
||||
|
||||
2013-01-13: Tubes can transport items now! Namely, I added Novatux/Nore's item
|
||||
transport mod as a default part of this mod, to make tubes do something useful!
|
||||
Thanks to Nore and RealBadAngel for the code contributions!
|
||||
|
||||
2013-01-05: made storage tanks connect from top/bottom, made storage tank and
|
||||
pipe textures use the ^ combine operator so they can show the actual liquid
|
||||
going through the pipes/tanks.
|
||||
|
||||
2013-01-04 (a bit later): Made pipes able to carry water! It was just a minor
|
||||
logic error resulting from moving the water flowing code into it's own file
|
||||
when I originally imported it. Many thanks to Mauvebic for writing it!
|
||||
|
||||
2013-01-04: First stage of integrating Mauvebic's water flowing code. This is
|
||||
experimental and doesn't move water yet - but at least it doesn't break
|
||||
anything :-)
|
||||
|
||||
2013-01-01: Various minor tweaks to textures, facedir settings, some other
|
||||
stuff. Changed crafting recipes to account for revamped pumps, valves, etc.
|
||||
Now requires the moreores mod and most recent git (for mese crystal fragments)
|
||||
to craft a pump. Added a "sealed" entry/exit panel (really just a horizontal
|
||||
pipe with a metal panel overlayed into the middle). Also, tweaked pipes to
|
||||
always drop the empty ones. Revamped pumps so that now they should sit in/on
|
||||
liquid and be connected only from the top, relegated grates to decorational-
|
||||
only, added outlet spigot. Got rid of a few obsolete textures. Got rid of
|
||||
that whole _x and _z naming thing - now all directional devices (pumps, valves,
|
||||
spigots, tanks) use facedir. Valves, spigots no longer auto-rotate to find
|
||||
nearby pipes.
|
||||
|
||||
2012-09-17: Added test object for pneumatic tube autorouting code, made tubes
|
||||
connect to it and any object that bears groups={tubedevice=1} (connects to any
|
||||
side)
|
||||
|
||||
2012-09-05: All recipes doubled except for junglegrass -> plastic sheet (since
|
||||
that is derived from home decor)
|
||||
|
||||
2012-09-02: Fixed plastic sheeting recipe. Added crafting recipes for various
|
||||
objects, with options: If homedecor is installed, use the plastic sheeting
|
||||
therein. If not, we define it manually. If the Technic mod is installed,
|
||||
don't define any recipes at all. Also removed the extra "loaded!" messages and
|
||||
tweaked the default pipe alias to point to something that is actually visible
|
||||
:-)
|
||||
|
||||
2012-09-01: flattened wielded pipe segment.
|
||||
|
||||
2012-08-24: Added square-ish pneumatic tubes with their own autoplace code
|
||||
(does not connect to steel pipes or pipe-oriented devices), then revised their
|
||||
textures shortly after. Fixed a recursion bug that sometimes caused a stack
|
||||
overflow. Old pipes were overriding the pipeworks:pipe defintion that belongs
|
||||
with the new pipes.
|
||||
|
||||
2012-08-22: Added outlet grate, made it participate in autoplace algorithm.
|
||||
Extended storage tank to show fill level in 10% steps (0% to 100%). Added
|
||||
"expansion tank" that appears if the user stacks tanks upwards. (Downwards is
|
||||
not checked).
|
||||
|
||||
2012-08-21: Made storage tank participate in autoplace algorithm. Tuned API a
|
||||
little to allow for more flexible placement. Re-organized code a bit to allow
|
||||
for some upcoming rules changes. Made storage tanks' upper/lower fittins and
|
||||
intake grate participate in autoplace algorithm.
|
||||
|
||||
2012-08-20: Added temporary nodes for storage tank and intake grating, but
|
||||
without autoplace.
|
||||
|
||||
2012-08-19: Pumps and valves now fully participate in the
|
||||
auto-rotate/auto-place algorithm.
|
||||
|
||||
2012-08-18: Total rewrite again. All pipes are now nice and round-looking, and
|
||||
they auto-connect! Also added temporary nodes for pump and valve (each with an
|
||||
on/off setting - punch to change). No crafting recipes yet and the pipes still
|
||||
don't do anything useful yet. Soon.
|
||||
|
||||
2012-08-06: Moved this changelog off the forum post and into a separate file.
|
||||
|
||||
2012-08-05 (multiple updates): Rewrote pipeworks to use loops and tables to
|
||||
create the nodes. Requires far less code now. Added -X, +X, -Y, +Y, -Z, +Z
|
||||
capped stubs and a short centered horizontal segment. Changed node definitions
|
||||
so that the aforementioned "short centered" segment is given on dig/drop.
|
||||
Renamed it to just "pipeworks:pipe" (and pipe_loaded). Added empty/loaded
|
||||
indicator images to the capped ends, removed some redundant comments. Made the
|
||||
empty/loaded indication at the capped end more prominent.
|
||||
|
||||
2012-07-21: Added screenshot showing pipes as they look now that nodebox
|
||||
texture rotation is fixed.
|
||||
|
||||
2012-07-18: Changed the mod name and all internals to 'pipeworks' instead of
|
||||
'pipes'... after a couple of mistakes :-)
|
||||
|
||||
2012-07-12: moved project to github.
|
||||
|
||||
2012-06-23: Initial release, followed by reworking the textures a bit.
|
|
@ -1,158 +0,0 @@
|
|||
-- this bit of code modifies the default chests and furnaces to be compatible
|
||||
-- with pipeworks.
|
||||
|
||||
function pipeworks.clone_node(name)
|
||||
local node2 = {}
|
||||
local node = minetest.registered_nodes[name]
|
||||
for k, v in pairs(node) do
|
||||
node2[k] = v
|
||||
end
|
||||
return node2
|
||||
end
|
||||
|
||||
local furnace = pipeworks.clone_node("default:furnace")
|
||||
furnace.tiles[1] = "default_furnace_top.png^pipeworks_tube_connection_stony.png"
|
||||
furnace.tiles[2] = "default_furnace_bottom.png^pipeworks_tube_connection_stony.png"
|
||||
furnace.tiles[3] = "default_furnace_side.png^pipeworks_tube_connection_stony.png"
|
||||
furnace.tiles[4] = "default_furnace_side.png^pipeworks_tube_connection_stony.png"
|
||||
furnace.tiles[5] = "default_furnace_side.png^pipeworks_tube_connection_stony.png"
|
||||
-- note we don't redefine entry 6 ( front)
|
||||
furnace.groups.tubedevice = 1
|
||||
furnace.groups.tubedevice_receiver = 1
|
||||
furnace.tube = {
|
||||
insert_object = function(pos, node, stack, direction)
|
||||
local meta = minetest.get_meta(pos)
|
||||
local inv = meta:get_inventory()
|
||||
if direction.y == 1 then
|
||||
return inv:add_item("fuel",stack)
|
||||
else
|
||||
return inv:add_item("src",stack)
|
||||
end
|
||||
end,
|
||||
can_insert = function(pos,node,stack,direction)
|
||||
local meta = minetest.get_meta(pos)
|
||||
local inv = meta:get_inventory()
|
||||
if direction.y == 1 then
|
||||
return inv:room_for_item("fuel", stack)
|
||||
else
|
||||
return inv:room_for_item("src", stack)
|
||||
end
|
||||
end,
|
||||
input_inventory = "dst",
|
||||
connect_sides = {left=1, right=1, back=1, front=1, bottom=1, top=1}
|
||||
}
|
||||
furnace.after_place_node = function(pos)
|
||||
pipeworks.scan_for_tube_objects(pos)
|
||||
end
|
||||
furnace.after_dig_node = function(pos)
|
||||
pipeworks.scan_for_tube_objects(pos)
|
||||
end
|
||||
|
||||
minetest.register_node(":default:furnace", furnace)
|
||||
|
||||
local furnace_active = pipeworks.clone_node("default:furnace_active")
|
||||
furnace_active.tiles[1] = "default_furnace_top.png^pipeworks_tube_connection_stony.png"
|
||||
furnace_active.tiles[2] = "default_furnace_bottom.png^pipeworks_tube_connection_stony.png"
|
||||
furnace_active.tiles[3] = "default_furnace_side.png^pipeworks_tube_connection_stony.png"
|
||||
furnace_active.tiles[4] = "default_furnace_side.png^pipeworks_tube_connection_stony.png"
|
||||
furnace_active.tiles[5] = "default_furnace_side.png^pipeworks_tube_connection_stony.png"
|
||||
-- note we don't redefine entry 6 (front)
|
||||
furnace_active.groups.tubedevice = 1
|
||||
furnace_active.groups.tubedevice_receiver = 1
|
||||
furnace_active.tube = {
|
||||
insert_object = function(pos,node,stack,direction)
|
||||
local meta = minetest.get_meta(pos)
|
||||
local inv = meta:get_inventory()
|
||||
if direction.y == 1 then
|
||||
return inv:add_item("fuel", stack)
|
||||
else
|
||||
return inv:add_item("src", stack)
|
||||
end
|
||||
end,
|
||||
can_insert = function(pos, node, stack, direction)
|
||||
local meta = minetest.get_meta(pos)
|
||||
local inv = meta:get_inventory()
|
||||
if direction.y == 1 then
|
||||
return inv:room_for_item("fuel", stack)
|
||||
else
|
||||
return inv:room_for_item("src", stack)
|
||||
end
|
||||
end,
|
||||
input_inventory = "dst",
|
||||
connect_sides = {left=1, right=1, back=1, front=1, bottom=1, top=1}
|
||||
}
|
||||
furnace_active.after_place_node= function(pos)
|
||||
pipeworks.scan_for_tube_objects(pos)
|
||||
end
|
||||
furnace_active.after_dig_node = function(pos)
|
||||
pipeworks.scan_for_tube_objects(pos)
|
||||
end
|
||||
|
||||
minetest.register_node(":default:furnace_active", furnace_active)
|
||||
|
||||
|
||||
local chest = pipeworks.clone_node("default:chest")
|
||||
chest.tiles[1] = "default_chest_top.png^pipeworks_tube_connection_wooden.png"
|
||||
chest.tiles[2] = "default_chest_top.png^pipeworks_tube_connection_wooden.png"
|
||||
chest.tiles[3] = "default_chest_side.png^pipeworks_tube_connection_wooden.png"
|
||||
chest.tiles[4] = "default_chest_side.png^pipeworks_tube_connection_wooden.png"
|
||||
chest.tiles[5] = "default_chest_side.png^pipeworks_tube_connection_wooden.png"
|
||||
-- note we don't redefine entry 6 (front).
|
||||
chest.groups.tubedevice = 1
|
||||
chest.groups.tubedevice_receiver = 1
|
||||
chest.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()
|
||||
return inv:room_for_item("main", stack)
|
||||
end,
|
||||
input_inventory = "main",
|
||||
connect_sides = {left=1, right=1, back=1, front=1, bottom=1, top=1}
|
||||
}
|
||||
chest.after_place_node = function(pos)
|
||||
pipeworks.scan_for_tube_objects(pos)
|
||||
end
|
||||
chest.after_dig_node = function(pos)
|
||||
pipeworks.scan_for_tube_objects(pos)
|
||||
end
|
||||
|
||||
minetest.register_node(":default:chest", chest)
|
||||
|
||||
|
||||
local chest_locked = pipeworks.clone_node("default:chest_locked")
|
||||
chest_locked.tiles[1] = "default_chest_top.png^pipeworks_tube_connection_wooden.png"
|
||||
chest_locked.tiles[2] = "default_chest_top.png^pipeworks_tube_connection_wooden.png"
|
||||
chest_locked.tiles[3] = "default_chest_side.png^pipeworks_tube_connection_wooden.png"
|
||||
chest_locked.tiles[4] = "default_chest_side.png^pipeworks_tube_connection_wooden.png"
|
||||
chest_locked.tiles[5] = "default_chest_side.png^pipeworks_tube_connection_wooden.png"
|
||||
-- note we don't redefine entry 6 (front).
|
||||
chest_locked.groups.tubedevice = 1
|
||||
chest_locked.groups.tubedevice_receiver = 1
|
||||
chest_locked.tube = {
|
||||
insert_object = function(pos, node, stack, direction)
|
||||
local meta = minetest.env: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.env:get_meta(pos)
|
||||
local inv = meta:get_inventory()
|
||||
return inv:room_for_item("main", stack)
|
||||
end,
|
||||
connect_sides = {left=1, right=1, back=1, front=1, bottom=1, top=1}
|
||||
}
|
||||
local old_after_place = minetest.registered_nodes["default:chest_locked"].after_place_node
|
||||
chest_locked.after_place_node = function(pos, placer)
|
||||
pipeworks.scan_for_tube_objects(pos)
|
||||
old_after_place(pos, placer)
|
||||
end
|
||||
chest_locked.after_dig_node = function(pos)
|
||||
pipeworks.scan_for_tube_objects(pos)
|
||||
end
|
||||
|
||||
minetest.register_node(":default:chest_locked", chest_locked)
|
|
@ -1,303 +0,0 @@
|
|||
-- Crafting recipes for pipes
|
||||
|
||||
minetest.register_craft( {
|
||||
output = "pipeworks:pipe_1_empty 12",
|
||||
recipe = {
|
||||
{ "default:steel_ingot", "default:steel_ingot", "default:steel_ingot" },
|
||||
{ "", "", "" },
|
||||
{ "default:steel_ingot", "default:steel_ingot", "default:steel_ingot" }
|
||||
},
|
||||
})
|
||||
|
||||
minetest.register_craft( {
|
||||
output = "pipeworks:spigot 3",
|
||||
recipe = {
|
||||
{ "pipeworks:pipe_1_empty", "" },
|
||||
{ "", "pipeworks:pipe_1_empty" },
|
||||
},
|
||||
})
|
||||
|
||||
minetest.register_craft( {
|
||||
output = "pipeworks:entry_panel_empty 2",
|
||||
recipe = {
|
||||
{ "", "default:steel_ingot", "" },
|
||||
{ "", "pipeworks:pipe_1_empty", "" },
|
||||
{ "", "default:steel_ingot", "" },
|
||||
},
|
||||
})
|
||||
|
||||
-- Various ancillary pipe devices
|
||||
|
||||
minetest.register_craft( {
|
||||
output = "pipeworks:pump_off 2",
|
||||
recipe = {
|
||||
{ "default:stone", "default:steel_ingot", "default:stone" },
|
||||
{ "moreores:copper_ingot", "default:mese_crystal_fragment", "moreores:copper_ingot" },
|
||||
{ "default:steel_ingot", "default:steel_ingot", "default:steel_ingot" }
|
||||
},
|
||||
})
|
||||
|
||||
minetest.register_craft( {
|
||||
output = "pipeworks:valve_off_empty 2",
|
||||
recipe = {
|
||||
{ "", "default:stick", "" },
|
||||
{ "default:steel_ingot", "default:steel_ingot", "default:steel_ingot" },
|
||||
{ "", "default:steel_ingot", "" }
|
||||
},
|
||||
})
|
||||
|
||||
minetest.register_craft( {
|
||||
output = "pipeworks:storage_tank_0 2",
|
||||
recipe = {
|
||||
{ "", "default:steel_ingot", "default:steel_ingot" },
|
||||
{ "default:steel_ingot", "default:glass", "default:steel_ingot" },
|
||||
{ "default:steel_ingot", "default:steel_ingot", "" }
|
||||
},
|
||||
})
|
||||
|
||||
minetest.register_craft( {
|
||||
output = "pipeworks:grating 2",
|
||||
recipe = {
|
||||
{ "default:steel_ingot", "", "default:steel_ingot" },
|
||||
{ "", "pipeworks:pipe_1_empty", "" },
|
||||
{ "default:steel_ingot", "", "default:steel_ingot" }
|
||||
},
|
||||
})
|
||||
|
||||
minetest.register_craft( {
|
||||
output = "pipeworks:flow_sensor_empty 2",
|
||||
recipe = {
|
||||
{ "pipeworks:pipe_1_empty", "mesecons:mesecon", "pipeworks:pipe_1_empty" },
|
||||
},
|
||||
})
|
||||
|
||||
minetest.register_craft( {
|
||||
output = "pipeworks:fountainhead 2",
|
||||
recipe = {
|
||||
{ "pipeworks:pipe_1_empty" },
|
||||
{ "pipeworks:pipe_1_empty" }
|
||||
},
|
||||
})
|
||||
|
||||
|
||||
-- Crafting recipes for pneumatic tubes
|
||||
|
||||
-- If homedecor is not installed, we need to register its crafting chain for
|
||||
-- plastic sheeting so that pipeworks remains compatible with it.
|
||||
|
||||
if minetest.get_modpath("homedecor") == nil then
|
||||
|
||||
minetest.register_craftitem(":homedecor:plastic_sheeting", {
|
||||
description = "Plastic sheet",
|
||||
inventory_image = "homedecor_plastic_sheeting.png",
|
||||
})
|
||||
|
||||
minetest.register_craftitem(":homedecor:plastic_base", {
|
||||
description = "Unprocessed Plastic base",
|
||||
wield_image = "homedecor_plastic_base.png",
|
||||
inventory_image = "homedecor_plastic_base_inv.png",
|
||||
})
|
||||
|
||||
minetest.register_craft({
|
||||
type = "shapeless",
|
||||
output = 'homedecor:plastic_base 4',
|
||||
recipe = { "group:leaves",
|
||||
"group:leaves",
|
||||
"group:leaves",
|
||||
"group:leaves",
|
||||
"group:leaves",
|
||||
"group:leaves"
|
||||
}
|
||||
})
|
||||
|
||||
minetest.register_craft({
|
||||
type = "cooking",
|
||||
output = "homedecor:plastic_sheeting",
|
||||
recipe = "homedecor:plastic_base",
|
||||
})
|
||||
|
||||
minetest.register_craft({
|
||||
type = 'fuel',
|
||||
recipe = 'homedecor:plastic_base',
|
||||
burntime = 30,
|
||||
})
|
||||
|
||||
minetest.register_craft({
|
||||
type = 'fuel',
|
||||
recipe = 'homedecor:plastic_sheeting',
|
||||
burntime = 30,
|
||||
})
|
||||
|
||||
end
|
||||
|
||||
minetest.register_craft( {
|
||||
output = "pipeworks:one_way_tube 2",
|
||||
recipe = {
|
||||
{ "homedecor:plastic_sheeting", "homedecor:plastic_sheeting", "homedecor:plastic_sheeting" },
|
||||
{ "default:stick", "default:mese_crystal", "homedecor:plastic_sheeting" },
|
||||
{ "homedecor:plastic_sheeting", "homedecor:plastic_sheeting", "homedecor:plastic_sheeting" }
|
||||
},
|
||||
})
|
||||
|
||||
|
||||
minetest.register_craft( {
|
||||
output = "pipeworks:tube_1 6",
|
||||
recipe = {
|
||||
{ "homedecor:plastic_sheeting", "homedecor:plastic_sheeting", "homedecor:plastic_sheeting" },
|
||||
{ "", "", "" },
|
||||
{ "homedecor:plastic_sheeting", "homedecor:plastic_sheeting", "homedecor:plastic_sheeting" }
|
||||
},
|
||||
})
|
||||
|
||||
minetest.register_craft( {
|
||||
output = "pipeworks:mese_tube_1 2",
|
||||
recipe = {
|
||||
{ "homedecor:plastic_sheeting", "homedecor:plastic_sheeting", "homedecor:plastic_sheeting" },
|
||||
{ "", "default:mese_crystal", "" },
|
||||
{ "homedecor:plastic_sheeting", "homedecor:plastic_sheeting", "homedecor:plastic_sheeting" }
|
||||
},
|
||||
})
|
||||
|
||||
minetest.register_craft( {
|
||||
type = "shapeless",
|
||||
output = "pipeworks:mese_tube_000000",
|
||||
recipe = {
|
||||
"pipeworks:tube_1",
|
||||
"default:mese_crystal_fragment",
|
||||
"default:mese_crystal_fragment",
|
||||
"default:mese_crystal_fragment",
|
||||
"default:mese_crystal_fragment"
|
||||
},
|
||||
})
|
||||
|
||||
minetest.register_craft( {
|
||||
output = "pipeworks:conductor_tube_off_1 6",
|
||||
recipe = {
|
||||
{ "homedecor:plastic_sheeting", "homedecor:plastic_sheeting", "homedecor:plastic_sheeting" },
|
||||
{ "mesecons:mesecon", "mesecons:mesecon", "mesecons:mesecon" },
|
||||
{ "homedecor:plastic_sheeting", "homedecor:plastic_sheeting", "homedecor:plastic_sheeting" }
|
||||
},
|
||||
})
|
||||
|
||||
minetest.register_craft( {
|
||||
output = "pipeworks:detector_tube_off_1 2",
|
||||
recipe = {
|
||||
{ "homedecor:plastic_sheeting", "homedecor:plastic_sheeting", "homedecor:plastic_sheeting" },
|
||||
{ "mesecons:mesecon", "mesecons_materials:silicon", "mesecons:mesecon" },
|
||||
{ "homedecor:plastic_sheeting", "homedecor:plastic_sheeting", "homedecor:plastic_sheeting" }
|
||||
},
|
||||
})
|
||||
|
||||
minetest.register_craft( {
|
||||
output = "pipeworks:accelerator_tube_1 2",
|
||||
recipe = {
|
||||
{ "homedecor:plastic_sheeting", "homedecor:plastic_sheeting", "homedecor:plastic_sheeting" },
|
||||
{ "default:mese_crystal_fragment", "default:steel_ingot", "default:mese_crystal_fragment" },
|
||||
{ "homedecor:plastic_sheeting", "homedecor:plastic_sheeting", "homedecor:plastic_sheeting" }
|
||||
},
|
||||
})
|
||||
|
||||
minetest.register_craft( {
|
||||
output = "pipeworks:teleport_tube_1 2",
|
||||
recipe = {
|
||||
{ "homedecor:plastic_sheeting", "homedecor:plastic_sheeting", "homedecor:plastic_sheeting" },
|
||||
{ "default:desert_stone", "default:mese_block", "default:desert_stone" },
|
||||
{ "homedecor:plastic_sheeting", "homedecor:plastic_sheeting", "homedecor:plastic_sheeting" }
|
||||
},
|
||||
})
|
||||
|
||||
minetest.register_craft( {
|
||||
output = "pipeworks:sand_tube_1 2",
|
||||
recipe = {
|
||||
{ "homedecor:plastic_sheeting", "homedecor:plastic_sheeting", "homedecor:plastic_sheeting" },
|
||||
{ "default:sand", "default:sand", "default:sand" },
|
||||
{ "homedecor:plastic_sheeting", "homedecor:plastic_sheeting", "homedecor:plastic_sheeting" }
|
||||
},
|
||||
})
|
||||
|
||||
minetest.register_craft( {
|
||||
output = "pipeworks:sand_tube_1 2",
|
||||
recipe = {
|
||||
{ "homedecor:plastic_sheeting", "homedecor:plastic_sheeting", "homedecor:plastic_sheeting" },
|
||||
{ "default:desert_sand", "default:desert_sand", "default:desert_sand" },
|
||||
{ "homedecor:plastic_sheeting", "homedecor:plastic_sheeting", "homedecor:plastic_sheeting" }
|
||||
},
|
||||
})
|
||||
|
||||
minetest.register_craft( {
|
||||
output = "pipeworks:sand_tube_1",
|
||||
recipe = {
|
||||
{ "default:desert_sand", "pipeworks:tube_1", "default:desert_sand" },
|
||||
},
|
||||
})
|
||||
|
||||
minetest.register_craft( {
|
||||
output = "pipeworks:mese_sand_tube_1 2",
|
||||
recipe = {
|
||||
{ "homedecor:plastic_sheeting", "homedecor:plastic_sheeting", "homedecor:plastic_sheeting" },
|
||||
{ "default:sand", "default:mese_crystal", "default:sand" },
|
||||
{ "homedecor:plastic_sheeting", "homedecor:plastic_sheeting", "homedecor:plastic_sheeting" }
|
||||
},
|
||||
})
|
||||
|
||||
minetest.register_craft( {
|
||||
output = "pipeworks:mese_sand_tube_1 2",
|
||||
recipe = {
|
||||
{ "homedecor:plastic_sheeting", "homedecor:plastic_sheeting", "homedecor:plastic_sheeting" },
|
||||
{ "default:desert_sand", "default:mese_crystal", "default:desert_sand" },
|
||||
{ "homedecor:plastic_sheeting", "homedecor:plastic_sheeting", "homedecor:plastic_sheeting" }
|
||||
},
|
||||
})
|
||||
|
||||
minetest.register_craft( {
|
||||
output = "pipeworks:crossing_tube_1 5",
|
||||
recipe = {
|
||||
{ "", "pipeworks:tube_1", "" },
|
||||
{ "pipeworks:tube_1", "pipeworks:tube_1", "pipeworks:tube_1" },
|
||||
{ "", "pipeworks:tube_1", "" }
|
||||
},
|
||||
})
|
||||
|
||||
|
||||
minetest.register_craft( {
|
||||
type = "shapeless",
|
||||
output = "pipeworks:mese_sand_tube_1",
|
||||
recipe = {
|
||||
"pipeworks:sand_tube_1",
|
||||
"default:mese_crystal_fragment",
|
||||
"default:mese_crystal_fragment",
|
||||
"default:mese_crystal_fragment",
|
||||
"default:mese_crystal_fragment"
|
||||
},
|
||||
})
|
||||
|
||||
-- Various ancillary tube devices
|
||||
|
||||
minetest.register_craft( {
|
||||
output = "pipeworks:filter 2",
|
||||
recipe = {
|
||||
{ "default:steel_ingot", "default:steel_ingot", "homedecor:plastic_sheeting" },
|
||||
{ "default:stick", "default:mese_crystal", "homedecor:plastic_sheeting" },
|
||||
{ "default:steel_ingot", "default:steel_ingot", "homedecor:plastic_sheeting" }
|
||||
},
|
||||
})
|
||||
|
||||
minetest.register_craft( {
|
||||
output = "pipeworks:mese_filter 2",
|
||||
recipe = {
|
||||
{ "default:steel_ingot", "default:steel_ingot", "homedecor:plastic_sheeting" },
|
||||
{ "default:stick", "default:mese", "homedecor:plastic_sheeting" },
|
||||
{ "default:steel_ingot", "default:steel_ingot", "homedecor:plastic_sheeting" }
|
||||
},
|
||||
})
|
||||
|
||||
minetest.register_craft( {
|
||||
output = "pipeworks:autocrafter 2",
|
||||
recipe = {
|
||||
{ "default:steel_ingot", "default:mese_crystal", "default:steel_ingot" },
|
||||
{ "homedecor:plastic_sheeting", "default:steel_ingot", "homedecor:plastic_sheeting" },
|
||||
{ "default:steel_ingot", "default:mese_crystal", "default:steel_ingot" }
|
||||
},
|
||||
})
|
||||
|
||||
|
|
@ -1,18 +0,0 @@
|
|||
-- Various settings
|
||||
|
||||
pipeworks.enable_pipes = true
|
||||
pipeworks.enable_autocrafter = true
|
||||
pipeworks.enable_deployer = true
|
||||
pipeworks.enable_node_breaker = true
|
||||
pipeworks.enable_teleport_tube = true
|
||||
pipeworks.enable_pipe_devices = true
|
||||
pipeworks.enable_redefines = true
|
||||
pipeworks.enable_mese_tube = true
|
||||
pipeworks.enable_detector_tube = true
|
||||
pipeworks.enable_conductor_tube = true
|
||||
pipeworks.enable_accelerator_tube = true
|
||||
pipeworks.enable_crossing_tube = true
|
||||
pipeworks.enable_sand_tube = true
|
||||
pipeworks.enable_mese_sand_tube = true
|
||||
pipeworks.enable_one_way_tube = true
|
||||
pipeworks.enable_cyclic_mode = true
|
|
@ -1,3 +0,0 @@
|
|||
default
|
||||
mesecons?
|
||||
mesecons_mvps?
|
|
@ -1,288 +0,0 @@
|
|||
|
||||
--register 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")
|
||||
|
||||
minetest.register_craft({
|
||||
output = 'pipeworks:deployer_off 1',
|
||||
recipe = {
|
||||
{'group:wood', 'default:chest','group:wood'},
|
||||
{'default:stone', 'mesecons:piston','default:stone'},
|
||||
{'default:stone', 'mesecons:mesecon','default:stone'},
|
||||
}
|
||||
})
|
||||
|
||||
local function swap_node(pos, name)
|
||||
local node = minetest.get_node(pos)
|
||||
if node.name == name then
|
||||
return
|
||||
end
|
||||
node.name = name
|
||||
minetest.swap_node(pos, node)
|
||||
end
|
||||
|
||||
local function delay(x)
|
||||
return (function() return x end)
|
||||
end
|
||||
|
||||
local function deployer_on(pos, node)
|
||||
if node.name ~= "pipeworks:deployer_off" then
|
||||
return
|
||||
end
|
||||
|
||||
--locate the above and under positions
|
||||
local dir = minetest.facedir_to_dir(node.param2)
|
||||
local pos_under, pos_above = {x = pos.x - dir.x, y = pos.y - dir.y, z = pos.z - dir.z}, {x = pos.x - 2*dir.x, y = pos.y - 2*dir.y, z = pos.z - 2*dir.z}
|
||||
|
||||
swap_node(pos, "pipeworks:deployer_on")
|
||||
nodeupdate(pos)
|
||||
|
||||
local meta = minetest.get_meta(pos)
|
||||
local inv = meta:get_inventory()
|
||||
local invlist = inv:get_list("main")
|
||||
for i, stack in ipairs(invlist) do
|
||||
if stack:get_name() ~= nil and stack:get_name() ~= "" then--and minetest.get_node(pos_under).name == "air" then --obtain the first non-empty item slot
|
||||
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 placer = {
|
||||
get_inventory_formspec = delay(meta:get_string("formspec")),
|
||||
get_look_dir = delay({x = -dir.x, y = -dir.y, z = -dir.z}),
|
||||
get_look_pitch = delay(pitch),
|
||||
get_look_yaw = delay(yaw),
|
||||
get_player_control = delay({jump=false, right=false, left=false, LMB=false, RMB=false, sneak=false, aux1=false, down=false, up=false}),
|
||||
get_player_control_bits = delay(0),
|
||||
get_player_name = delay(meta:get_string("owner")),
|
||||
is_player = delay(true),
|
||||
set_inventory_formspec = delay(),
|
||||
getpos = delay({x = pos.x, y = pos.y - 1.5, z = pos.z}), -- Player height
|
||||
get_hp = delay(20),
|
||||
get_inventory = delay(inv),
|
||||
get_wielded_item = delay(stack),
|
||||
get_wield_index = delay(i),
|
||||
get_wield_list = delay("main"),
|
||||
moveto = delay(),
|
||||
punch = delay(),
|
||||
remove = delay(),
|
||||
right_click = delay(),
|
||||
setpos = delay(),
|
||||
set_hp = delay(),
|
||||
set_properties = delay(),
|
||||
set_wielded_item = function(self, item) inv:set_stack("main", i, item) end,
|
||||
set_animation = delay(),
|
||||
set_attach = delay(),
|
||||
set_detach = delay(),
|
||||
set_bone_position = delay(),
|
||||
}
|
||||
local pointed_thing = {type="node", under=pos_under, above=pos_above}
|
||||
local stack2
|
||||
if minetest.registered_items[stack:get_name()] then
|
||||
stack2 = minetest.registered_items[stack:get_name()].on_place(stack, placer, pointed_thing)
|
||||
end
|
||||
--if minetest.setting_getbool("creative_mode") and not minetest.get_modpath("unified_inventory") then --infinite stacks ahoy!
|
||||
-- stack2:take_item()
|
||||
--end
|
||||
inv:set_stack("main", i, stack2)
|
||||
return
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
local deployer_off = function(pos, node)
|
||||
if node.name == "pipeworks:deployer_on" then
|
||||
swap_node(pos, "pipeworks:deployer_off")
|
||||
nodeupdate(pos)
|
||||
end
|
||||
end
|
||||
|
||||
minetest.register_node("pipeworks:deployer_off", {
|
||||
description = "Deployer",
|
||||
tile_images = {"pipeworks_deployer_top.png","pipeworks_deployer_bottom.png","pipeworks_deployer_side2.png","pipeworks_deployer_side1.png",
|
||||
"pipeworks_deployer_back.png","pipeworks_deployer_front_off.png"},
|
||||
mesecons = {effector={rules=pipeworks.rules_all,action_on=deployer_on,action_off=deployer_off}},
|
||||
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()
|
||||
return inv:room_for_item("main",stack)
|
||||
end,
|
||||
input_inventory="main",
|
||||
connect_sides={back=1},
|
||||
can_remove = function(pos, node, stack, dir)
|
||||
return stack:get_count()
|
||||
end},
|
||||
is_ground_content = true,
|
||||
paramtype2 = "facedir",
|
||||
groups = {snappy=2,choppy=2,oddly_breakable_by_hand=2, mesecon = 2,tubedevice=1, tubedevice_receiver=1},
|
||||
sounds = default.node_sound_stone_defaults(),
|
||||
on_construct = function(pos)
|
||||
local meta = minetest.get_meta(pos)
|
||||
meta:set_string("formspec",
|
||||
"invsize[8,9;]"..
|
||||
"label[0,0;Deployer]"..
|
||||
"list[current_name;main;4,1;3,3;]"..
|
||||
"list[current_player;main;0,5;8,4;]")
|
||||
meta:set_string("infotext", "Deployer")
|
||||
local inv = meta:get_inventory()
|
||||
inv:set_size("main", 3*3)
|
||||
end,
|
||||
can_dig = function(pos,player)
|
||||
local meta = minetest.get_meta(pos);
|
||||
local inv = meta:get_inventory()
|
||||
return inv:is_empty("main")
|
||||
end,
|
||||
after_place_node = function (pos, placer)
|
||||
pipeworks.scan_for_tube_objects(pos, placer)
|
||||
local placer_pos = placer:getpos()
|
||||
|
||||
--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)
|
||||
minetest.log("action", "real (6d) facedir: " .. node.param2)
|
||||
end
|
||||
|
||||
minetest.get_meta(pos):set_string("owner", placer:get_player_name())
|
||||
end,
|
||||
after_dig_node = pipeworks.scan_for_tube_objects,
|
||||
allow_metadata_inventory_move = function(pos, from_list, from_index, to_list, to_index, count, player)
|
||||
local meta = minetest.get_meta(pos)
|
||||
if player:get_player_name() ~= meta:get_string("owner") and meta:get_string("owner") ~= "" then
|
||||
return 0
|
||||
end
|
||||
return count
|
||||
end,
|
||||
allow_metadata_inventory_put = function(pos, listname, index, stack, player)
|
||||
local meta = minetest.get_meta(pos)
|
||||
if player:get_player_name() ~= meta:get_string("owner") and meta:get_string("owner") ~= "" then
|
||||
return 0
|
||||
end
|
||||
return stack:get_count()
|
||||
end,
|
||||
allow_metadata_inventory_take = function(pos, listname, index, stack, player)
|
||||
local meta = minetest.get_meta(pos)
|
||||
if player:get_player_name() ~= meta:get_string("owner") and meta:get_string("owner") ~= "" then
|
||||
return 0
|
||||
end
|
||||
return stack:get_count()
|
||||
end
|
||||
})
|
||||
|
||||
minetest.register_node("pipeworks:deployer_on", {
|
||||
description = "Deployer",
|
||||
tile_images = {"pipeworks_deployer_top.png","pipeworks_deployer_bottom.png","pipeworks_deployer_side2.png","pipeworks_deployer_side1.png",
|
||||
"pipeworks_deployer_back.png","pipeworks_deployer_front_on.png"},
|
||||
mesecons = {effector={rules=pipeworks.rules_all,action_on=deployer_on,action_off=deployer_off}},
|
||||
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()
|
||||
return inv:room_for_item("main",stack)
|
||||
end,
|
||||
input_inventory="main",
|
||||
connect_sides={back=1},
|
||||
can_remove = function(pos, node, stack, dir)
|
||||
return stack:get_count()
|
||||
end},
|
||||
is_ground_content = true,
|
||||
paramtype2 = "facedir",
|
||||
tubelike=1,
|
||||
drop = "pipeworks:deployer_off",
|
||||
groups = {snappy=2,choppy=2,oddly_breakable_by_hand=2, mesecon = 2,tubedevice=1, tubedevice_receiver=1,not_in_creative_inventory=1},
|
||||
sounds = default.node_sound_stone_defaults(),
|
||||
on_construct = function(pos)
|
||||
local meta = minetest.get_meta(pos)
|
||||
meta:set_string("formspec",
|
||||
"invsize[8,9;]"..
|
||||
"label[0,0;Deployer]"..
|
||||
"list[current_name;main;4,1;3,3;]"..
|
||||
"list[current_player;main;0,5;8,4;]")
|
||||
meta:set_string("infotext", "Deployer")
|
||||
local inv = meta:get_inventory()
|
||||
inv:set_size("main", 3*3)
|
||||
end,
|
||||
can_dig = function(pos,player)
|
||||
local meta = minetest.get_meta(pos);
|
||||
local inv = meta:get_inventory()
|
||||
return inv:is_empty("main")
|
||||
end,
|
||||
after_place_node = function (pos, placer)
|
||||
pipeworks.scan_for_tube_objects(pos, placer)
|
||||
local placer_pos = placer:getpos()
|
||||
|
||||
--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)
|
||||
minetest.log("action", "real (6d) facedir: " .. node.param2)
|
||||
end
|
||||
|
||||
minetest.get_meta(pos):set_string("owner", placer:get_player_name())
|
||||
end,
|
||||
after_dig_node = pipeworks.scan_for_tube_objects,
|
||||
allow_metadata_inventory_move = function(pos, from_list, from_index, to_list, to_index, count, player)
|
||||
local meta = minetest.get_meta(pos)
|
||||
if player:get_player_name() ~= meta:get_string("owner") and meta:get_string("owner") ~= "" then
|
||||
return 0
|
||||
end
|
||||
return count
|
||||
end,
|
||||
allow_metadata_inventory_put = function(pos, listname, index, stack, player)
|
||||
local meta = minetest.get_meta(pos)
|
||||
if player:get_player_name() ~= meta:get_string("owner") and meta:get_string("owner") ~= "" then
|
||||
return 0
|
||||
end
|
||||
return stack:get_count()
|
||||
end,
|
||||
allow_metadata_inventory_take = function(pos, listname, index, stack, player)
|
||||
local meta = minetest.get_meta(pos)
|
||||
if player:get_player_name() ~= meta:get_string("owner") and meta:get_string("owner") ~= "" then
|
||||
return 0
|
||||
end
|
||||
return stack:get_count()
|
||||
end
|
||||
})
|
|
@ -1,701 +0,0 @@
|
|||
-- List of devices that should participate in the autoplace algorithm
|
||||
|
||||
local pipereceptor_on = nil
|
||||
local pipereceptor_off = nil
|
||||
|
||||
if mesecon then
|
||||
pipereceptor_on = {
|
||||
receptor = {
|
||||
state = mesecon.state.on,
|
||||
rules = pipeworks.mesecons_rules
|
||||
}
|
||||
}
|
||||
|
||||
pipereceptor_off = {
|
||||
receptor = {
|
||||
state = mesecon.state.off,
|
||||
rules = pipeworks.mesecons_rules
|
||||
}
|
||||
}
|
||||
end
|
||||
|
||||
local pipes_devicelist = {
|
||||
"pump",
|
||||
"valve",
|
||||
"storage_tank_0",
|
||||
"storage_tank_1",
|
||||
"storage_tank_2",
|
||||
"storage_tank_3",
|
||||
"storage_tank_4",
|
||||
"storage_tank_5",
|
||||
"storage_tank_6",
|
||||
"storage_tank_7",
|
||||
"storage_tank_8",
|
||||
"storage_tank_9",
|
||||
"storage_tank_10"
|
||||
}
|
||||
|
||||
-- Now define the nodes.
|
||||
|
||||
local states = { "on", "off" }
|
||||
local dgroups = ""
|
||||
local pumpboxes = {}
|
||||
|
||||
for s in ipairs(states) do
|
||||
|
||||
if states[s] == "off" then
|
||||
dgroups = {snappy=3, pipe=1}
|
||||
else
|
||||
dgroups = {snappy=3, pipe=1, not_in_creative_inventory=1}
|
||||
end
|
||||
|
||||
pumpboxes = {}
|
||||
|
||||
pipeworks.add_node_box(pumpboxes, pipeworks.pipe_pumpbody)
|
||||
pipeworks.add_node_box(pumpboxes, pipeworks.pipe_topstub)
|
||||
|
||||
minetest.register_node("pipeworks:pump_"..states[s], {
|
||||
description = "Pump/Intake Module",
|
||||
drawtype = "nodebox",
|
||||
tiles = {
|
||||
"pipeworks_pump_top.png",
|
||||
"pipeworks_pump_bottom.png",
|
||||
"pipeworks_pump_sides.png",
|
||||
"pipeworks_pump_sides.png",
|
||||
"pipeworks_pump_sides.png",
|
||||
"pipeworks_pump_"..states[s]..".png"
|
||||
},
|
||||
paramtype = "light",
|
||||
paramtype2 = "facedir",
|
||||
selection_box = {
|
||||
type = "fixed",
|
||||
fixed = { -0.5, -0.5, -0.5, 0.5, 0.5, 0.5 }
|
||||
},
|
||||
node_box = {
|
||||
type = "fixed",
|
||||
fixed = pumpboxes
|
||||
},
|
||||
groups = dgroups,
|
||||
sounds = default.node_sound_wood_defaults(),
|
||||
walkable = true,
|
||||
after_place_node = function(pos)
|
||||
pipeworks.scan_for_pipe_objects(pos)
|
||||
end,
|
||||
after_dig_node = function(pos)
|
||||
pipeworks.scan_for_pipe_objects(pos)
|
||||
end,
|
||||
drop = "pipeworks:pump_off",
|
||||
mesecons = {effector = {
|
||||
action_on = function (pos, node)
|
||||
minetest.add_node(pos,{name="pipeworks:pump_on", param2 = node.param2})
|
||||
end,
|
||||
action_off = function (pos, node)
|
||||
minetest.add_node(pos,{name="pipeworks:pump_off", param2 = node.param2})
|
||||
end
|
||||
}},
|
||||
on_punch = function(pos, node, puncher)
|
||||
local fdir = minetest.get_node(pos).param2
|
||||
minetest.add_node(pos, { name = "pipeworks:pump_"..states[3-s], param2 = fdir })
|
||||
end
|
||||
})
|
||||
|
||||
local valveboxes = {}
|
||||
pipeworks.add_node_box(valveboxes, pipeworks.pipe_leftstub)
|
||||
pipeworks.add_node_box(valveboxes, pipeworks.pipe_valvebody)
|
||||
if states[s] == "off" then
|
||||
pipeworks.add_node_box(valveboxes, pipeworks.pipe_valvehandle_off)
|
||||
else
|
||||
pipeworks.add_node_box(valveboxes, pipeworks.pipe_valvehandle_on)
|
||||
end
|
||||
pipeworks.add_node_box(valveboxes, pipeworks.pipe_rightstub)
|
||||
local tilex = "pipeworks_valvebody_ends.png"
|
||||
local tilez = "pipeworks_valvebody_sides.png"
|
||||
|
||||
minetest.register_node("pipeworks:valve_"..states[s].."_empty", {
|
||||
description = "Valve",
|
||||
drawtype = "nodebox",
|
||||
tiles = {
|
||||
"pipeworks_valvebody_top_"..states[s]..".png",
|
||||
"pipeworks_valvebody_bottom.png",
|
||||
tilex,
|
||||
tilex,
|
||||
tilez,
|
||||
tilez,
|
||||
},
|
||||
sunlight_propagates = true,
|
||||
paramtype = "light",
|
||||
paramtype2 = "facedir",
|
||||
selection_box = {
|
||||
type = "fixed",
|
||||
fixed = { -8/16, -4/16, -5/16, 8/16, 5/16, 5/16 }
|
||||
},
|
||||
node_box = {
|
||||
type = "fixed",
|
||||
fixed = valveboxes
|
||||
},
|
||||
groups = dgroups,
|
||||
sounds = default.node_sound_wood_defaults(),
|
||||
walkable = true,
|
||||
after_place_node = function(pos)
|
||||
pipeworks.scan_for_pipe_objects(pos)
|
||||
end,
|
||||
after_dig_node = function(pos)
|
||||
pipeworks.scan_for_pipe_objects(pos)
|
||||
end,
|
||||
drop = "pipeworks:valve_off_empty",
|
||||
mesecons = {effector = {
|
||||
action_on = function (pos, node)
|
||||
minetest.add_node(pos,{name="pipeworks:valve_on_empty", param2 = node.param2})
|
||||
end,
|
||||
action_off = function (pos, node)
|
||||
minetest.add_node(pos,{name="pipeworks:valve_off_empty", param2 = node.param2})
|
||||
end
|
||||
}},
|
||||
on_punch = function(pos, node, puncher)
|
||||
local fdir = minetest.get_node(pos).param2
|
||||
minetest.add_node(pos, { name = "pipeworks:valve_"..states[3-s].."_empty", param2 = fdir })
|
||||
end
|
||||
})
|
||||
end
|
||||
|
||||
local valveboxes = {}
|
||||
pipeworks.add_node_box(valveboxes, pipeworks.pipe_leftstub)
|
||||
pipeworks.add_node_box(valveboxes, pipeworks.pipe_valvebody)
|
||||
pipeworks.add_node_box(valveboxes, pipeworks.pipe_rightstub)
|
||||
pipeworks.add_node_box(valveboxes, pipeworks.pipe_valvehandle_on)
|
||||
|
||||
minetest.register_node("pipeworks:valve_on_loaded", {
|
||||
description = "Valve",
|
||||
drawtype = "nodebox",
|
||||
tiles = {
|
||||
"pipeworks_valvebody_top_on.png",
|
||||
"pipeworks_valvebody_bottom.png",
|
||||
"pipeworks_valvebody_ends.png",
|
||||
"pipeworks_valvebody_ends.png",
|
||||
"pipeworks_valvebody_sides.png",
|
||||
"pipeworks_valvebody_sides.png",
|
||||
},
|
||||
sunlight_propagates = true,
|
||||
paramtype = "light",
|
||||
paramtype2 = "facedir",
|
||||
selection_box = {
|
||||
type = "fixed",
|
||||
fixed = { -8/16, -4/16, -5/16, 8/16, 5/16, 5/16 }
|
||||
},
|
||||
node_box = {
|
||||
type = "fixed",
|
||||
fixed = valveboxes
|
||||
},
|
||||
groups = {snappy=3, pipe=1, not_in_creative_inventory=1},
|
||||
sounds = default.node_sound_wood_defaults(),
|
||||
walkable = true,
|
||||
after_place_node = function(pos)
|
||||
pipeworks.scan_for_pipe_objects(pos)
|
||||
end,
|
||||
after_dig_node = function(pos)
|
||||
pipeworks.scan_for_pipe_objects(pos)
|
||||
end,
|
||||
drop = "pipeworks:valve_off_empty",
|
||||
mesecons = {effector = {
|
||||
action_on = function (pos, node)
|
||||
minetest.add_node(pos,{name="pipeworks:valve_on_empty", param2 = node.param2})
|
||||
end,
|
||||
action_off = function (pos, node)
|
||||
minetest.add_node(pos,{name="pipeworks:valve_off_empty", param2 = node.param2})
|
||||
end
|
||||
}},
|
||||
on_punch = function(pos, node, puncher)
|
||||
local fdir = minetest.get_node(pos).param2
|
||||
minetest.add_node(pos, { name = "pipeworks:valve_off_empty", param2 = fdir })
|
||||
end
|
||||
})
|
||||
|
||||
-- grating
|
||||
|
||||
minetest.register_node("pipeworks:grating", {
|
||||
description = "Decorative grating",
|
||||
tiles = {
|
||||
"pipeworks_grating_top.png",
|
||||
"pipeworks_grating_sides.png",
|
||||
"pipeworks_grating_sides.png",
|
||||
"pipeworks_grating_sides.png",
|
||||
"pipeworks_grating_sides.png",
|
||||
"pipeworks_grating_sides.png"
|
||||
},
|
||||
sunlight_propagates = true,
|
||||
paramtype = "light",
|
||||
groups = {snappy=3, pipe=1},
|
||||
sounds = default.node_sound_wood_defaults(),
|
||||
walkable = true,
|
||||
after_place_node = function(pos)
|
||||
pipeworks.scan_for_pipe_objects(pos)
|
||||
end,
|
||||
after_dig_node = function(pos)
|
||||
pipeworks.scan_for_pipe_objects(pos)
|
||||
end,
|
||||
})
|
||||
|
||||
-- outlet spigot
|
||||
|
||||
local spigotboxes = {}
|
||||
pipeworks.add_node_box(spigotboxes, pipeworks.pipe_backstub)
|
||||
pipeworks.add_node_box(spigotboxes, pipeworks.spigot_bottomstub)
|
||||
pipeworks.add_node_box(spigotboxes, pipeworks.pipe_bendsphere)
|
||||
|
||||
local spigotboxes_pouring = {}
|
||||
pipeworks.add_node_box(spigotboxes_pouring, pipeworks.spigot_stream)
|
||||
pipeworks.add_node_box(spigotboxes_pouring, pipeworks.pipe_backstub)
|
||||
pipeworks.add_node_box(spigotboxes_pouring, pipeworks.spigot_bottomstub)
|
||||
pipeworks.add_node_box(spigotboxes_pouring, pipeworks.pipe_bendsphere)
|
||||
|
||||
minetest.register_node("pipeworks:spigot", {
|
||||
description = "Spigot outlet",
|
||||
drawtype = "nodebox",
|
||||
tiles = {
|
||||
"pipeworks_spigot_sides.png",
|
||||
"pipeworks_pipe_end_empty.png",
|
||||
"pipeworks_spigot_sides.png",
|
||||
"pipeworks_spigot_sides.png",
|
||||
"pipeworks_pipe_end_empty.png",
|
||||
"pipeworks_spigot_sides.png"
|
||||
},
|
||||
sunlight_propagates = true,
|
||||
paramtype = "light",
|
||||
paramtype2 = "facedir",
|
||||
groups = {snappy=3, pipe=1},
|
||||
sounds = default.node_sound_wood_defaults(),
|
||||
walkable = true,
|
||||
after_place_node = function(pos)
|
||||
pipeworks.scan_for_pipe_objects(pos)
|
||||
end,
|
||||
after_dig_node = function(pos)
|
||||
pipeworks.scan_for_pipe_objects(pos)
|
||||
end,
|
||||
node_box = {
|
||||
type = "fixed",
|
||||
fixed = spigotboxes,
|
||||
},
|
||||
selection_box = {
|
||||
type = "fixed",
|
||||
fixed = { -2/16, -6/16, -2/16, 2/16, 2/16, 8/16 }
|
||||
}
|
||||
})
|
||||
|
||||
minetest.register_node("pipeworks:spigot_pouring", {
|
||||
description = "Spigot outlet",
|
||||
drawtype = "nodebox",
|
||||
tiles = {
|
||||
"pipeworks_spigot_sides.png",
|
||||
"default_water.png^pipeworks_spigot_bottom2.png",
|
||||
{ name = "default_water_flowing_animated.png^pipeworks_spigot_sides2.png",
|
||||
animation = {
|
||||
type = "vertical_frames",
|
||||
aspect_w=16,
|
||||
aspect_h=16,
|
||||
length=0.8
|
||||
}
|
||||
},
|
||||
{ name = "default_water_flowing_animated.png^pipeworks_spigot_sides2.png",
|
||||
animation = {
|
||||
type = "vertical_frames",
|
||||
aspect_w=16,
|
||||
aspect_h=16,
|
||||
length=0.8
|
||||
}
|
||||
},
|
||||
{ name = "default_water_flowing_animated.png^pipeworks_spigot_sides2.png",
|
||||
animation = {
|
||||
type = "vertical_frames",
|
||||
aspect_w=16,
|
||||
aspect_h=16,
|
||||
length=0.8
|
||||
}
|
||||
},
|
||||
{ name = "default_water_flowing_animated.png^pipeworks_spigot_sides2.png",
|
||||
animation = {
|
||||
type = "vertical_frames",
|
||||
aspect_w=16,
|
||||
aspect_h=16,
|
||||
length=0.8
|
||||
}
|
||||
},
|
||||
},
|
||||
sunlight_propagates = true,
|
||||
paramtype = "light",
|
||||
paramtype2 = "facedir",
|
||||
groups = {snappy=3, pipe=1, not_in_creative_inventory=1},
|
||||
sounds = default.node_sound_wood_defaults(),
|
||||
walkable = true,
|
||||
after_place_node = function(pos)
|
||||
pipeworks.scan_for_pipe_objects(pos)
|
||||
end,
|
||||
after_dig_node = function(pos)
|
||||
pipeworks.scan_for_pipe_objects(pos)
|
||||
end,
|
||||
node_box = {
|
||||
type = "fixed",
|
||||
fixed = spigotboxes_pouring,
|
||||
},
|
||||
selection_box = {
|
||||
type = "fixed",
|
||||
fixed = { -2/16, -6/16, -2/16, 2/16, 2/16, 8/16 }
|
||||
},
|
||||
drop = "pipeworks:spigot",
|
||||
})
|
||||
|
||||
-- sealed pipe entry/exit (horizontal pipe passing through a metal
|
||||
-- wall, for use in places where walls should look like they're airtight)
|
||||
|
||||
local airtightboxes = {}
|
||||
pipeworks.add_node_box(airtightboxes, pipeworks.pipe_frontstub)
|
||||
pipeworks.add_node_box(airtightboxes, pipeworks.pipe_backstub)
|
||||
pipeworks.add_node_box(airtightboxes, pipeworks.entry_panel)
|
||||
|
||||
minetest.register_node("pipeworks:entry_panel_empty", {
|
||||
description = "Airtight Pipe entry/exit",
|
||||
drawtype = "nodebox",
|
||||
tiles = {
|
||||
"pipeworks_plain.png",
|
||||
"pipeworks_plain.png",
|
||||
"pipeworks_plain.png",
|
||||
"pipeworks_plain.png",
|
||||
"pipeworks_pipe_end_empty.png",
|
||||
"pipeworks_pipe_end_empty.png"
|
||||
},
|
||||
paramtype = "light",
|
||||
paramtype2 = "facedir",
|
||||
groups = {snappy=3, pipe=1},
|
||||
sounds = default.node_sound_wood_defaults(),
|
||||
walkable = true,
|
||||
after_place_node = function(pos)
|
||||
pipeworks.scan_for_pipe_objects(pos)
|
||||
end,
|
||||
after_dig_node = function(pos)
|
||||
pipeworks.scan_for_pipe_objects(pos)
|
||||
end,
|
||||
node_box = {
|
||||
type = "fixed",
|
||||
fixed = airtightboxes,
|
||||
},
|
||||
selection_box = {
|
||||
type = "fixed",
|
||||
fixed = {
|
||||
{ -2/16, -2/16, -8/16, 2/16, 2/16, 8/16 },
|
||||
{ -8/16, -8/16, -1/16, 8/16, 8/16, 1/16 }
|
||||
}
|
||||
},
|
||||
on_place = function(itemstack, placer, pointed_thing)
|
||||
if not pipeworks.node_is_owned(pointed_thing.under, placer)
|
||||
and not pipeworks.node_is_owned(pointed_thing.above, placer) then
|
||||
local node = minetest.get_node(pointed_thing.under)
|
||||
|
||||
if not minetest.registered_nodes[node.name]
|
||||
or not minetest.registered_nodes[node.name].on_rightclick then
|
||||
local pitch = placer:get_look_pitch()
|
||||
local above = pointed_thing.above
|
||||
local under = pointed_thing.under
|
||||
local fdir = minetest.dir_to_facedir(placer:get_look_dir())
|
||||
local undernode = minetest.get_node(under)
|
||||
local abovenode = minetest.get_node(above)
|
||||
local uname = undernode.name
|
||||
local aname = abovenode.name
|
||||
local isabove = (above.x == under.x) and (above.z == under.z) and (pitch > 0)
|
||||
local pos1 = above
|
||||
|
||||
if above.x == under.x
|
||||
and above.z == under.z
|
||||
and ( string.find(uname, "pipeworks:pipe_")
|
||||
or string.find(uname, "pipeworks:storage_")
|
||||
or string.find(uname, "pipeworks:expansion_")
|
||||
or ( string.find(uname, "pipeworks:grating") and not isabove )
|
||||
or ( string.find(uname, "pipeworks:pump_") and not isabove )
|
||||
or ( string.find(uname, "pipeworks:entry_panel")
|
||||
and undernode.param2 == 13 )
|
||||
)
|
||||
then
|
||||
fdir = 13
|
||||
end
|
||||
|
||||
if minetest.registered_nodes[uname]["buildable_to"] then
|
||||
pos1 = under
|
||||
end
|
||||
|
||||
if not minetest.registered_nodes[minetest.get_node(pos1).name]["buildable_to"] then return end
|
||||
|
||||
minetest.add_node(pos1, {name = "pipeworks:entry_panel_empty", param2 = fdir })
|
||||
pipeworks.scan_for_pipe_objects(pos1)
|
||||
|
||||
if not pipeworks.expect_infinite_stacks then
|
||||
itemstack:take_item()
|
||||
end
|
||||
|
||||
else
|
||||
minetest.registered_nodes[node.name].on_rightclick(pointed_thing.under, node, placer, itemstack)
|
||||
end
|
||||
end
|
||||
return itemstack
|
||||
end
|
||||
})
|
||||
|
||||
minetest.register_node("pipeworks:entry_panel_loaded", {
|
||||
description = "Airtight Pipe entry/exit",
|
||||
drawtype = "nodebox",
|
||||
tiles = {
|
||||
"pipeworks_plain.png",
|
||||
"pipeworks_plain.png",
|
||||
"pipeworks_plain.png",
|
||||
"pipeworks_plain.png",
|
||||
"pipeworks_pipe_end_empty.png",
|
||||
"pipeworks_pipe_end_empty.png"
|
||||
},
|
||||
paramtype = "light",
|
||||
paramtype2 = "facedir",
|
||||
groups = {snappy=3, pipe=1, not_in_creative_inventory=1},
|
||||
sounds = default.node_sound_wood_defaults(),
|
||||
walkable = true,
|
||||
after_place_node = function(pos)
|
||||
pipeworks.scan_for_pipe_objects(pos)
|
||||
end,
|
||||
after_dig_node = function(pos)
|
||||
pipeworks.scan_for_pipe_objects(pos)
|
||||
end,
|
||||
node_box = {
|
||||
type = "fixed",
|
||||
fixed = airtightboxes,
|
||||
},
|
||||
selection_box = {
|
||||
type = "fixed",
|
||||
fixed = {
|
||||
{ -2/16, -2/16, -8/16, 2/16, 2/16, 8/16 },
|
||||
{ -8/16, -8/16, -1/16, 8/16, 8/16, 1/16 }
|
||||
}
|
||||
},
|
||||
drop = "pipeworks:entry_panel_empty"
|
||||
})
|
||||
|
||||
local sensorboxes = {}
|
||||
pipeworks.add_node_box(sensorboxes, pipeworks.pipe_leftstub)
|
||||
pipeworks.add_node_box(sensorboxes, pipeworks.pipe_sensorbody)
|
||||
pipeworks.add_node_box(sensorboxes, pipeworks.pipe_rightstub)
|
||||
|
||||
minetest.register_node("pipeworks:flow_sensor_empty", {
|
||||
description = "Flow Sensor",
|
||||
drawtype = "nodebox",
|
||||
tiles = {
|
||||
"pipeworks_plain.png",
|
||||
"pipeworks_plain.png",
|
||||
"pipeworks_plain.png",
|
||||
"pipeworks_plain.png",
|
||||
"pipeworks_windowed_empty.png",
|
||||
"pipeworks_windowed_empty.png"
|
||||
},
|
||||
sunlight_propagates = true,
|
||||
paramtype = "light",
|
||||
paramtype2 = "facedir",
|
||||
groups = {snappy=3, pipe=1},
|
||||
sounds = default.node_sound_wood_defaults(),
|
||||
walkable = true,
|
||||
after_place_node = function(pos)
|
||||
pipeworks.scan_for_pipe_objects(pos)
|
||||
end,
|
||||
after_dig_node = function(pos)
|
||||
pipeworks.scan_for_pipe_objects(pos)
|
||||
end,
|
||||
on_construct = function(pos)
|
||||
if mesecon then
|
||||
mesecon:receptor_off(pos, rules)
|
||||
end
|
||||
end,
|
||||
node_box = {
|
||||
type = "fixed",
|
||||
fixed = sensorboxes,
|
||||
},
|
||||
selection_box = {
|
||||
type = "fixed",
|
||||
fixed = {
|
||||
{ -8/16, -2/16, -2/16, 8/16, 2/16, 2/16 },
|
||||
}
|
||||
},
|
||||
mesecons = pipereceptor_off
|
||||
})
|
||||
|
||||
minetest.register_node("pipeworks:flow_sensor_loaded", {
|
||||
description = "Flow sensor (on)",
|
||||
drawtype = "nodebox",
|
||||
tiles = {
|
||||
"pipeworks_plain.png",
|
||||
"pipeworks_plain.png",
|
||||
"pipeworks_plain.png",
|
||||
"pipeworks_plain.png",
|
||||
"pipeworks_sensor_sides_on.png",
|
||||
"pipeworks_sensor_sides_on.png"
|
||||
},
|
||||
sunlight_propagates = true,
|
||||
paramtype = "light",
|
||||
paramtype2 = "facedir",
|
||||
groups = {snappy=3, pipe=1, not_in_creative_inventory=1},
|
||||
sounds = default.node_sound_wood_defaults(),
|
||||
walkable = true,
|
||||
after_place_node = function(pos)
|
||||
pipeworks.scan_for_pipe_objects(pos)
|
||||
end,
|
||||
after_dig_node = function(pos)
|
||||
pipeworks.scan_for_pipe_objects(pos)
|
||||
end,
|
||||
on_construct = function(pos)
|
||||
if mesecon then
|
||||
mesecon:receptor_on(pos, rules)
|
||||
end
|
||||
end,
|
||||
node_box = {
|
||||
type = "fixed",
|
||||
fixed = sensorboxes,
|
||||
},
|
||||
selection_box = {
|
||||
type = "fixed",
|
||||
fixed = {
|
||||
{ -8/16, -2/16, -2/16, 8/16, 2/16, 2/16 },
|
||||
}
|
||||
},
|
||||
drop = "pipeworks:flow_sensor_empty",
|
||||
mesecons = pipereceptor_on
|
||||
})
|
||||
|
||||
-- tanks
|
||||
|
||||
for fill = 0, 10 do
|
||||
local filldesc="empty"
|
||||
local sgroups = {snappy=3, pipe=1, tankfill=fill+1}
|
||||
local image = nil
|
||||
|
||||
if fill ~= 0 then
|
||||
filldesc=fill.."0% full"
|
||||
sgroups = {snappy=3, pipe=1, tankfill=fill+1, not_in_creative_inventory=1}
|
||||
image = "pipeworks_storage_tank_fittings.png"
|
||||
end
|
||||
|
||||
minetest.register_node("pipeworks:expansion_tank_"..fill, {
|
||||
description = "Expansion Tank ("..filldesc..")... You hacker, you.",
|
||||
tiles = {
|
||||
"pipeworks_storage_tank_fittings.png",
|
||||
"pipeworks_storage_tank_fittings.png",
|
||||
"pipeworks_storage_tank_back.png",
|
||||
"pipeworks_storage_tank_back.png",
|
||||
"pipeworks_storage_tank_back.png",
|
||||
pipeworks.liquid_texture.."^pipeworks_storage_tank_front_"..fill..".png"
|
||||
},
|
||||
inventory_image = image,
|
||||
paramtype = "light",
|
||||
paramtype2 = "facedir",
|
||||
groups = {snappy=3, pipe=1, tankfill=fill+1, not_in_creative_inventory=1},
|
||||
sounds = default.node_sound_wood_defaults(),
|
||||
walkable = true,
|
||||
drop = "pipeworks:storage_tank_"..fill,
|
||||
after_place_node = function(pos)
|
||||
pipeworks.look_for_stackable_tanks(pos)
|
||||
pipeworks.scan_for_pipe_objects(pos)
|
||||
end,
|
||||
after_dig_node = function(pos)
|
||||
pipeworks.scan_for_pipe_objects(pos)
|
||||
end,
|
||||
})
|
||||
|
||||
minetest.register_node("pipeworks:storage_tank_"..fill, {
|
||||
description = "Fluid Storage Tank ("..filldesc..")",
|
||||
tiles = {
|
||||
"pipeworks_storage_tank_fittings.png",
|
||||
"pipeworks_storage_tank_fittings.png",
|
||||
"pipeworks_storage_tank_back.png",
|
||||
"pipeworks_storage_tank_back.png",
|
||||
"pipeworks_storage_tank_back.png",
|
||||
pipeworks.liquid_texture.."^pipeworks_storage_tank_front_"..fill..".png"
|
||||
},
|
||||
inventory_image = image,
|
||||
paramtype = "light",
|
||||
paramtype2 = "facedir",
|
||||
groups = sgroups,
|
||||
sounds = default.node_sound_wood_defaults(),
|
||||
walkable = true,
|
||||
after_place_node = function(pos)
|
||||
pipeworks.look_for_stackable_tanks(pos)
|
||||
pipeworks.scan_for_pipe_objects(pos)
|
||||
end,
|
||||
after_dig_node = function(pos)
|
||||
pipeworks.scan_for_pipe_objects(pos)
|
||||
end,
|
||||
})
|
||||
end
|
||||
|
||||
-- fountainhead
|
||||
|
||||
minetest.register_node("pipeworks:fountainhead", {
|
||||
description = "Fountainhead",
|
||||
drawtype = "nodebox",
|
||||
tiles = {
|
||||
"pipeworks_fountainhead_top.png",
|
||||
"pipeworks_pipe_end.png",
|
||||
"pipeworks_plain.png",
|
||||
},
|
||||
sunlight_propagates = true,
|
||||
paramtype = "light",
|
||||
groups = {snappy=3, pipe=1},
|
||||
sounds = default.node_sound_wood_defaults(),
|
||||
walkable = true,
|
||||
after_place_node = function(pos)
|
||||
pipeworks.scan_for_pipe_objects(pos)
|
||||
end,
|
||||
after_dig_node = function(pos)
|
||||
pipeworks.scan_for_pipe_objects(pos)
|
||||
end,
|
||||
on_construct = function(pos)
|
||||
if mesecon then
|
||||
mesecon:receptor_on(pos, rules)
|
||||
end
|
||||
end,
|
||||
node_box = {
|
||||
type = "fixed",
|
||||
fixed = pipeworks.fountainhead_model ,
|
||||
},
|
||||
selection_box = {
|
||||
type = "fixed",
|
||||
fixed = { -2/16, -8/16, -2/16, 2/16, 8/16, 2/16 }
|
||||
},
|
||||
})
|
||||
|
||||
minetest.register_node("pipeworks:fountainhead_pouring", {
|
||||
description = "Fountainhead",
|
||||
drawtype = "nodebox",
|
||||
tiles = {
|
||||
"pipeworks_fountainhead_top.png",
|
||||
"pipeworks_pipe_end.png",
|
||||
"pipeworks_plain.png",
|
||||
},
|
||||
sunlight_propagates = true,
|
||||
paramtype = "light",
|
||||
groups = {snappy=3, pipe=1, not_in_creative_inventory=1},
|
||||
sounds = default.node_sound_wood_defaults(),
|
||||
walkable = true,
|
||||
after_place_node = function(pos)
|
||||
pipeworks.scan_for_pipe_objects(pos)
|
||||
end,
|
||||
after_dig_node = function(pos)
|
||||
pipeworks.scan_for_pipe_objects(pos)
|
||||
end,
|
||||
on_construct = function(pos)
|
||||
if mesecon then
|
||||
mesecon:receptor_on(pos, rules)
|
||||
end
|
||||
end,
|
||||
node_box = {
|
||||
type = "fixed",
|
||||
fixed = pipeworks.fountainhead_model,
|
||||
},
|
||||
selection_box = {
|
||||
type = "fixed",
|
||||
fixed = { -2/16, -8/16, -2/16, 2/16, 8/16, 2/16 },
|
||||
},
|
||||
drop = "pipeworks:fountainhead"
|
||||
})
|
||||
|
||||
minetest.register_alias("pipeworks:valve_off_loaded", "pipeworks:valve_off_empty")
|
||||
|
|
@ -1,121 +0,0 @@
|
|||
-- This file provides the actual flow and pathfinding logic that makes water
|
||||
-- move through the pipes.
|
||||
--
|
||||
-- Contributed by mauvebic, 2013-01-03, rewritten a bit by Vanessa Ezekowitz
|
||||
--
|
||||
|
||||
local finitewater = minetest.setting_getbool("liquid_finite")
|
||||
|
||||
pipeworks.check_for_liquids = function(pos)
|
||||
local coords = {
|
||||
{x=pos.x,y=pos.y-1,z=pos.z},
|
||||
{x=pos.x,y=pos.y+1,z=pos.z},
|
||||
{x=pos.x-1,y=pos.y,z=pos.z},
|
||||
{x=pos.x+1,y=pos.y,z=pos.z},
|
||||
{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 = minetest.get_node(coords[i]).name
|
||||
if name and string.find(name,"water") then
|
||||
if finitewater then minetest.remove_node(coords[i]) end
|
||||
return true
|
||||
end
|
||||
end
|
||||
return false
|
||||
end
|
||||
|
||||
pipeworks.check_for_inflows = function(pos,node)
|
||||
local coords = {
|
||||
{x=pos.x,y=pos.y-1,z=pos.z},
|
||||
{x=pos.x,y=pos.y+1,z=pos.z},
|
||||
{x=pos.x-1,y=pos.y,z=pos.z},
|
||||
{x=pos.x+1,y=pos.y,z=pos.z},
|
||||
{x=pos.x,y=pos.y,z=pos.z-1},
|
||||
{x=pos.x,y=pos.y,z=pos.z+1}, }
|
||||
local newnode = false
|
||||
local source = false
|
||||
for i =1,6 do
|
||||
if newnode then break end
|
||||
local name = minetest.get_node(coords[i]).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 = minetest.get_meta(coords[i]):get_string("source")
|
||||
if source == minetest.pos_to_string(pos) then break end
|
||||
end
|
||||
newnode = string.gsub(node.name,"empty","loaded")
|
||||
source = {x=coords[i].x,y=coords[i].y,z=coords[i].z}
|
||||
end
|
||||
end
|
||||
if newnode then
|
||||
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 = minetest.string_to_pos(minetest.get_meta(pos):get_string("source"))
|
||||
if not sourcepos then return end
|
||||
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
|
||||
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 = minetest.get_node({x=pos.x,y=pos.y-1,z=pos.z}).name
|
||||
if belowname and (belowname == "air" or belowname == "default:water_flowing" or belowname == "default:water_source") then
|
||||
local spigotname = minetest.get_node(pos).name
|
||||
local fdir=node.param2
|
||||
local check = {
|
||||
{x=pos.x,y=pos.y,z=pos.z+1},
|
||||
{x=pos.x+1,y=pos.y,z=pos.z},
|
||||
{x=pos.x,y=pos.y,z=pos.z-1},
|
||||
{x=pos.x-1,y=pos.y,z=pos.z}
|
||||
}
|
||||
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
|
||||
minetest.add_node(pos,{name = "pipeworks:spigot_pouring", param2 = fdir})
|
||||
if finitewater or belowname ~= "default:water_source" then
|
||||
minetest.add_node({x=pos.x,y=pos.y-1,z=pos.z},{name = "default:water_source"})
|
||||
end
|
||||
end
|
||||
else
|
||||
if spigotname == "pipeworks:spigot_pouring" then
|
||||
minetest.add_node({x=pos.x,y=pos.y,z=pos.z},{name = "pipeworks:spigot", param2 = fdir})
|
||||
if belowname == "default:water_source" and not finitewater then
|
||||
minetest.remove_node({x=pos.x,y=pos.y-1,z=pos.z})
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
pipeworks.fountainhead_check = function(pos, node)
|
||||
local abovename = minetest.get_node({x=pos.x,y=pos.y+1,z=pos.z}).name
|
||||
if abovename and (abovename == "air" or abovename == "default:water_flowing" or abovename == "default:water_source") then
|
||||
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
|
||||
minetest.add_node(pos,{name = "pipeworks:fountainhead_pouring"})
|
||||
if finitewater or abovename ~= "default:water_source" then
|
||||
minetest.add_node({x=pos.x,y=pos.y+1,z=pos.z},{name = "default:water_source"})
|
||||
end
|
||||
end
|
||||
else
|
||||
if fountainhead_name == "pipeworks:fountainhead_pouring" then
|
||||
minetest.add_node({x=pos.x,y=pos.y,z=pos.z},{name = "pipeworks:fountainhead"})
|
||||
if abovename == "default:water_source" and not finitewater then
|
||||
minetest.remove_node({x=pos.x,y=pos.y+1,z=pos.z})
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
|
@ -1,128 +0,0 @@
|
|||
-- Pipeworks mod by Vanessa Ezekowitz - 2013-07-13
|
||||
--
|
||||
-- This mod supplies various steel pipes and plastic pneumatic tubes
|
||||
-- and devices that they can connect to.
|
||||
--
|
||||
-- License: WTFPL
|
||||
--
|
||||
|
||||
pipeworks = {}
|
||||
|
||||
local DEBUG = false
|
||||
|
||||
pipeworks.worldpath = minetest.get_worldpath()
|
||||
pipeworks.modpath = minetest.get_modpath("pipeworks")
|
||||
|
||||
dofile(pipeworks.modpath.."/default_settings.txt")
|
||||
|
||||
-- Read the external config file if it exists.
|
||||
if io.open(pipeworks.worldpath.."/pipeworks_settings.txt","r") then
|
||||
dofile(pipeworks.worldpath.."/pipeworks_settings.txt")
|
||||
io.close()
|
||||
end
|
||||
|
||||
-- Random variables
|
||||
|
||||
pipeworks.expect_infinite_stacks = true
|
||||
if minetest.get_modpath("unified_inventory") or not minetest.setting_getbool("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.liquid_texture = "default_water.png"
|
||||
|
||||
-- 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
|
||||
|
||||
function pipeworks.add_node_box(t, b)
|
||||
for i in ipairs(b)
|
||||
do table.insert(t, b[i])
|
||||
end
|
||||
end
|
||||
|
||||
function pipeworks.node_is_owned(pos, placer)
|
||||
local ownername = false
|
||||
if type(IsPlayerNodeOwner) == "function" then -- node_ownership mod
|
||||
if HasOwner(pos, placer) then -- returns true if the node is owned
|
||||
if not IsPlayerNodeOwner(pos, placer:get_player_name()) then
|
||||
if type(getLastOwner) == "function" then -- ...is an old version
|
||||
ownername = getLastOwner(pos)
|
||||
elseif type(GetNodeOwnerName) == "function" then -- ...is a recent version
|
||||
ownername = GetNodeOwnerName(pos)
|
||||
else
|
||||
ownername = S("someone")
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
elseif type(isprotect)=="function" then -- glomie's protection mod
|
||||
if not isprotect(5, pos, placer) then
|
||||
ownername = S("someone")
|
||||
end
|
||||
elseif type(protector)=="table" and type(protector.can_dig)=="function" then -- Zeg9's protection mod
|
||||
if not protector.can_dig(5, pos, placer) then
|
||||
ownername = S("someone")
|
||||
end
|
||||
end
|
||||
|
||||
if ownername ~= false then
|
||||
minetest.chat_send_player( placer:get_player_name(), S("Sorry, %s owns that spot."):format(ownername) )
|
||||
return true
|
||||
else
|
||||
return false
|
||||
end
|
||||
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
|
||||
|
||||
-------------------------------------------
|
||||
-- Load the various other parts of the mod
|
||||
|
||||
dofile(pipeworks.modpath.."/models.lua")
|
||||
dofile(pipeworks.modpath.."/autoplace_pipes.lua")
|
||||
dofile(pipeworks.modpath.."/autoplace_tubes.lua")
|
||||
dofile(pipeworks.modpath.."/item_transport.lua")
|
||||
dofile(pipeworks.modpath.."/flowing_logic.lua")
|
||||
dofile(pipeworks.modpath.."/crafts.lua")
|
||||
dofile(pipeworks.modpath.."/tubes.lua")
|
||||
|
||||
if pipeworks.enable_pipes then dofile(pipeworks.modpath.."/pipes.lua") end
|
||||
if pipeworks.enable_teleport_tube then dofile(pipeworks.modpath.."/teleport_tube.lua") end
|
||||
if pipeworks.enable_pipe_devices then dofile(pipeworks.modpath.."/devices.lua") end
|
||||
if pipeworks.enable_redefines then dofile(pipeworks.modpath.."/compat.lua") end
|
||||
if pipeworks.enable_autocrafter then dofile(pipeworks.modpath.."/autocrafter.lua") end
|
||||
if pipeworks.enable_deployer then dofile(pipeworks.modpath.."/deployer.lua") end
|
||||
if pipeworks.enable_node_breaker then dofile(pipeworks.modpath.."/node_breaker.lua") end
|
||||
|
||||
minetest.register_alias("pipeworks:pipe", "pipeworks:pipe_110000_empty")
|
||||
|
||||
print("Pipeworks loaded!")
|
||||
|
|
@ -1,546 +0,0 @@
|
|||
dofile(pipeworks.modpath.."/compat.lua")
|
||||
|
||||
--and an extra function for getting the right-facing vector
|
||||
local function facedir_to_right_dir(facedir)
|
||||
|
||||
--find the other directions
|
||||
local backdir = minetest.facedir_to_dir(facedir)
|
||||
local topdir = ({[0]={x=0, y=1, z=0},
|
||||
{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}})[math.floor(facedir/4)]
|
||||
|
||||
--return a cross product
|
||||
return {x=topdir.y*backdir.z - backdir.y*topdir.z,
|
||||
y=topdir.z*backdir.x - backdir.z*topdir.x,
|
||||
z=topdir.x*backdir.y - backdir.x*topdir.y}
|
||||
end
|
||||
|
||||
minetest.register_craftitem("pipeworks:filter", {
|
||||
description = "Filter",
|
||||
stack_max = 99,
|
||||
})
|
||||
|
||||
local fakePlayer = {
|
||||
get_player_name = function() return ":pipeworks" end,
|
||||
-- any other player functions called by allow_metadata_inventory_take anywhere...
|
||||
-- perhaps a custom metaclass that errors specially when fakePlayer.<property> is not found?
|
||||
}
|
||||
|
||||
function pipeworks.tube_item(pos, item)
|
||||
-- Take item in any format
|
||||
local stack = ItemStack(item)
|
||||
local obj = minetest.add_entity(pos, "pipeworks:tubed_item")
|
||||
obj:get_luaentity():set_item(stack:to_string())
|
||||
return obj
|
||||
end
|
||||
|
||||
-- adding two tube functions
|
||||
-- can_remove(pos,node,stack,dir) returns the maximum number of items of that stack that can be removed
|
||||
-- remove_items(pos,node,stack,dir,count) removes count items and returns them
|
||||
-- both optional w/ sensible defaults and fallback to normal allow_* function
|
||||
-- XXX: possibly change insert_object to insert_item
|
||||
|
||||
-- sname = the current name to allow for, or nil if it allows anything
|
||||
|
||||
local function grabAndFire(frominv,frominvname,frompos,fromnode,sname,tube,idef,dir,all)
|
||||
for spos,stack in ipairs(frominv:get_list(frominvname)) do
|
||||
if (sname == nil and stack:get_name() ~= "") or stack:get_name() == sname then
|
||||
local doRemove = stack:get_count()
|
||||
if tube.can_remove then
|
||||
doRemove = tube.can_remove(frompos, fromnode, stack, dir)
|
||||
elseif idef.allow_metadata_inventory_take then
|
||||
doRemove = idef.allow_metadata_inventory_take(frompos, frominvname,spos, stack, fakePlayer)
|
||||
end
|
||||
-- stupid lack of continue statements grumble
|
||||
if doRemove > 0 then
|
||||
local item
|
||||
local count
|
||||
if all then
|
||||
count = math.min(stack:get_count(), doRemove)
|
||||
else
|
||||
count = 1
|
||||
end
|
||||
if tube.remove_items then
|
||||
-- it could be the entire stack...
|
||||
item = tube.remove_items(frompos, fromnode, stack, dir, count)
|
||||
else
|
||||
item = stack:take_item(count)
|
||||
frominv:set_stack(frominvname, spos, stack)
|
||||
if idef.on_metadata_inventory_take then
|
||||
idef.on_metadata_inventory_take(frompos, frominvname, spos, item, fakePlayer)
|
||||
end
|
||||
end
|
||||
local item1 = pipeworks.tube_item(vector.add(frompos, vector.multiply(dir, 1.4)), item)
|
||||
item1:get_luaentity().start_pos = vector.add(frompos, dir)
|
||||
item1:setvelocity(dir)
|
||||
item1:setacceleration({x=0, y=0, z=0})
|
||||
return true-- only fire one item, please
|
||||
end
|
||||
end
|
||||
end
|
||||
return false
|
||||
end
|
||||
|
||||
minetest.register_node("pipeworks:filter", {
|
||||
description = "Filter",
|
||||
tiles = {"pipeworks_filter_top.png", "pipeworks_filter_top.png", "pipeworks_filter_output.png",
|
||||
"pipeworks_filter_input.png", "pipeworks_filter_side.png", "pipeworks_filter_top.png"},
|
||||
paramtype2 = "facedir",
|
||||
groups = {snappy=2,choppy=2,oddly_breakable_by_hand=2,tubedevice=1,mesecon=2},
|
||||
legacy_facedir_simple = true,
|
||||
sounds = default.node_sound_wood_defaults(),
|
||||
on_construct = function(pos)
|
||||
local meta = minetest.get_meta(pos)
|
||||
meta:set_string("formspec",
|
||||
"invsize[8,6.5;]"..
|
||||
"list[current_name;main;0,0;8,2;]"..
|
||||
"list[current_player;main;0,2.5;8,4;]")
|
||||
meta:set_string("infotext", "Filter")
|
||||
local inv = meta:get_inventory()
|
||||
inv:set_size("main", 8*4)
|
||||
end,
|
||||
can_dig = function(pos,player)
|
||||
local meta = minetest.get_meta(pos);
|
||||
local inv = meta:get_inventory()
|
||||
return inv:is_empty("main")
|
||||
end,
|
||||
after_place_node = function(pos)
|
||||
pipeworks.scan_for_tube_objects(pos)
|
||||
end,
|
||||
after_dig_node = function(pos)
|
||||
pipeworks.scan_for_tube_objects(pos)
|
||||
end,
|
||||
mesecons={effector={action_on=function(pos,node)
|
||||
minetest.registered_nodes[node.name].on_punch(pos,node,nil)
|
||||
end}},
|
||||
tube={connect_sides={right=1}},
|
||||
on_punch = function (pos, node, puncher)
|
||||
local meta = minetest.get_meta(pos);
|
||||
local inv = meta:get_inventory()
|
||||
local dir = facedir_to_right_dir(node.param2)
|
||||
local frompos = {x=pos.x - dir.x, y=pos.y - dir.y, z=pos.z - dir.z}
|
||||
local fromnode=minetest.get_node(frompos)
|
||||
if not fromnode then return end
|
||||
local idef = minetest.registered_nodes[fromnode.name]
|
||||
-- assert(idef)
|
||||
local tube = idef.tube
|
||||
if not (tube and tube.input_inventory) then
|
||||
return
|
||||
end
|
||||
if tube.before_filter then
|
||||
tube.before_filter(frompos)
|
||||
end
|
||||
local frommeta = minetest.get_meta(frompos)
|
||||
local frominv = frommeta:get_inventory()
|
||||
|
||||
local function from_inventory(frominvname)
|
||||
local sname
|
||||
for _,filter in ipairs(inv:get_list("main")) do
|
||||
sname = filter:get_name()
|
||||
if sname ~= "" then
|
||||
-- XXX: that's a lot of parameters
|
||||
if grabAndFire(frominv, frominvname, frompos, fromnode, sname, tube, idef, dir) then
|
||||
return true
|
||||
end
|
||||
end
|
||||
end
|
||||
if inv:is_empty("main") then
|
||||
grabAndFire(frominv, frominvname, frompos, fromnode, nil, tube, idef, dir)
|
||||
return true
|
||||
end
|
||||
return false
|
||||
end
|
||||
|
||||
if type(tube.input_inventory) == "table" then
|
||||
for _, i in ipairs(tube.input_inventory) do
|
||||
if from_inventory(i) then -- fired an item
|
||||
break
|
||||
end
|
||||
end
|
||||
else
|
||||
from_inventory(tube.input_inventory)
|
||||
end
|
||||
|
||||
if tube.after_filter then
|
||||
tube.after_filter(frompos)
|
||||
end
|
||||
end,
|
||||
})
|
||||
|
||||
minetest.register_craftitem("pipeworks:mese_filter", {
|
||||
description = "Mese filter",
|
||||
stack_max = 99,
|
||||
})
|
||||
|
||||
minetest.register_node("pipeworks:mese_filter", {
|
||||
description = "Mese filter",
|
||||
tiles = {"pipeworks_mese_filter_top.png", "pipeworks_mese_filter_top.png", "pipeworks_mese_filter_output.png",
|
||||
"pipeworks_mese_filter_input.png", "pipeworks_mese_filter_side.png", "pipeworks_mese_filter_top.png"},
|
||||
paramtype2 = "facedir",
|
||||
groups = {snappy=2,choppy=2,oddly_breakable_by_hand=2,tubedevice=1,mesecon=2},
|
||||
legacy_facedir_simple = true,
|
||||
sounds = default.node_sound_wood_defaults(),
|
||||
on_construct = function(pos)
|
||||
local meta = minetest.get_meta(pos)
|
||||
meta:set_string("formspec",
|
||||
"invsize[8,6.5;]"..
|
||||
"list[current_name;main;0,0;8,2;]"..
|
||||
"list[current_player;main;0,2.5;8,4;]")
|
||||
meta:set_string("infotext", "Mese filter")
|
||||
local inv = meta:get_inventory()
|
||||
inv:set_size("main", 8*4)
|
||||
end,
|
||||
can_dig = function(pos,player)
|
||||
local meta = minetest.get_meta(pos);
|
||||
local inv = meta:get_inventory()
|
||||
return inv:is_empty("main")
|
||||
end,
|
||||
after_place_node = function(pos)
|
||||
pipeworks.scan_for_tube_objects(pos)
|
||||
end,
|
||||
after_dig_node = function(pos)
|
||||
pipeworks.scan_for_tube_objects(pos)
|
||||
end,
|
||||
mesecons={effector={action_on=function(pos,node)
|
||||
minetest.registered_nodes[node.name].on_punch(pos,node,nil)
|
||||
end}},
|
||||
tube={connect_sides={right=1}},
|
||||
on_punch = function (pos, node, puncher)
|
||||
local meta = minetest.get_meta(pos);
|
||||
local inv = meta:get_inventory()
|
||||
local dir = facedir_to_right_dir(node.param2)
|
||||
local frompos = {x=pos.x - dir.x, y=pos.y - dir.y, z=pos.z - dir.z}
|
||||
local fromnode=minetest.get_node(frompos)
|
||||
local idef = minetest.registered_nodes[fromnode.name]
|
||||
-- assert(idef)
|
||||
local tube = idef.tube
|
||||
if not (tube and tube.input_inventory) then
|
||||
return
|
||||
end
|
||||
|
||||
if tube.before_filter then
|
||||
tube.before_filter(frompos)
|
||||
end
|
||||
local frommeta = minetest.get_meta(frompos)
|
||||
local frominv = frommeta:get_inventory()
|
||||
|
||||
local function from_inventory(frominvname)
|
||||
local sname
|
||||
for _,filter in ipairs(inv:get_list("main")) do
|
||||
sname = filter:get_name()
|
||||
if sname ~= "" then
|
||||
-- XXX: that's a lot of parameters
|
||||
if grabAndFire(frominv, frominvname, frompos, fromnode, sname, tube, idef, dir, true) then
|
||||
return true
|
||||
end
|
||||
end
|
||||
end
|
||||
if inv:is_empty("main") then
|
||||
grabAndFire(frominv, frominvname, frompos, fromnode, nil, tube, idef, dir, true)
|
||||
return true
|
||||
end
|
||||
return false
|
||||
end
|
||||
|
||||
if type(tube.input_inventory) == "table" then
|
||||
for _, i in ipairs(tube.input_inventory) do
|
||||
if from_inventory(i) then -- fired an item
|
||||
break
|
||||
end
|
||||
end
|
||||
else
|
||||
from_inventory(tube.input_inventory)
|
||||
end
|
||||
|
||||
if tube.after_filter then
|
||||
tube.after_filter(frompos)
|
||||
end
|
||||
end,
|
||||
})
|
||||
|
||||
local function roundpos(pos)
|
||||
return {x=math.floor(pos.x+0.5),y=math.floor(pos.y+0.5),z=math.floor(pos.z+0.5)}
|
||||
end
|
||||
|
||||
local function addVect(pos,vect)
|
||||
return {x=pos.x+vect.x,y=pos.y+vect.y,z=pos.z+vect.z}
|
||||
end
|
||||
|
||||
local adjlist={{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}}
|
||||
|
||||
function pipeworks.notvel(tbl, vel)
|
||||
local tbl2={}
|
||||
for _,val in ipairs(tbl) do
|
||||
if val.x ~= -vel.x or val.y ~= -vel.y or val.z ~= -vel.z then table.insert(tbl2, val) end
|
||||
end
|
||||
return tbl2
|
||||
end
|
||||
|
||||
local function go_next(pos, velocity, stack)
|
||||
local chests = {}
|
||||
local tubes = {}
|
||||
local cnode = minetest.get_node(pos)
|
||||
local cmeta = minetest.get_meta(pos)
|
||||
local n
|
||||
local can_go
|
||||
local speed = math.abs(velocity.x + velocity.y + velocity.z)
|
||||
local vel = {x = velocity.x/speed, y = velocity.y/speed, z = velocity.z/speed,speed=speed}
|
||||
if speed >= 4.1 then
|
||||
speed = 4
|
||||
elseif speed >= 1.1 then
|
||||
speed = speed-0.1
|
||||
else
|
||||
speed = 1
|
||||
end
|
||||
vel.speed = speed
|
||||
if minetest.registered_nodes[cnode.name] and minetest.registered_nodes[cnode.name].tube and minetest.registered_nodes[cnode.name].tube.can_go then
|
||||
can_go = minetest.registered_nodes[cnode.name].tube.can_go(pos, cnode, vel, stack)
|
||||
else
|
||||
can_go = pipeworks.notvel(adjlist, vel)
|
||||
end
|
||||
local meta = nil
|
||||
for _,vect in ipairs(can_go) do
|
||||
local npos = addVect(pos,vect)
|
||||
local node = minetest.get_node(npos)
|
||||
local tube_receiver = minetest.get_item_group(node.name,"tubedevice_receiver")
|
||||
meta = minetest.get_meta(npos)
|
||||
local tubelike = meta:get_int("tubelike")
|
||||
if tube_receiver == 1 then
|
||||
if minetest.registered_nodes[node.name].tube and
|
||||
minetest.registered_nodes[node.name].tube.can_insert and
|
||||
minetest.registered_nodes[node.name].tube.can_insert(npos, node, stack, vect) then
|
||||
local i = #chests + 1
|
||||
chests[i] = {}
|
||||
chests[i].pos = npos
|
||||
chests[i].vect = vect
|
||||
end
|
||||
elseif tubelike == 1 then
|
||||
local i = #tubes + 1
|
||||
tubes[i] = {}
|
||||
tubes[i].pos = npos
|
||||
tubes[i].vect = vect
|
||||
end
|
||||
end
|
||||
if chests[1] == nil then--no chests found
|
||||
if tubes[1] == nil then
|
||||
return 0
|
||||
else
|
||||
n = (cmeta:get_int("tubedir")%(#tubes)) + 1
|
||||
if pipeworks.enable_cyclic_mode then
|
||||
cmeta:set_int("tubedir",n)
|
||||
end
|
||||
velocity.x = tubes[n].vect.x*vel.speed
|
||||
velocity.y = tubes[n].vect.y*vel.speed
|
||||
velocity.z = tubes[n].vect.z*vel.speed
|
||||
end
|
||||
else
|
||||
n = (cmeta:get_int("tubedir")%(#chests))+1
|
||||
if pipeworks.enable_cyclic_mode then
|
||||
cmeta:set_int("tubedir",n)
|
||||
end
|
||||
velocity.x = chests[n].vect.x*speed
|
||||
velocity.y = chests[n].vect.y*speed
|
||||
velocity.z = chests[n].vect.z*speed
|
||||
end
|
||||
return 1
|
||||
end
|
||||
|
||||
minetest.register_entity("pipeworks:tubed_item", {
|
||||
initial_properties = {
|
||||
hp_max = 1,
|
||||
physical = false,
|
||||
-- collisionbox = {0,0,0,0,0,0},
|
||||
collisionbox = {0.1,0.1,0.1,0.1,0.1,0.1},
|
||||
visual = "sprite",
|
||||
visual_size = {x=0.5, y=0.5},
|
||||
textures = {""},
|
||||
spritediv = {x=1, y=1},
|
||||
initial_sprite_basepos = {x=0, y=0},
|
||||
is_visible = false,
|
||||
start_pos={},
|
||||
route={}
|
||||
},
|
||||
|
||||
itemstring = '',
|
||||
physical_state = false,
|
||||
|
||||
set_item = function(self, itemstring)
|
||||
self.itemstring = itemstring
|
||||
local stack = ItemStack(itemstring)
|
||||
local itemtable = stack:to_table()
|
||||
local itemname = nil
|
||||
if itemtable then
|
||||
itemname = stack:to_table().name
|
||||
end
|
||||
local item_texture = nil
|
||||
local item_type = ""
|
||||
if minetest.registered_items[itemname] then
|
||||
item_texture = minetest.registered_items[itemname].inventory_image
|
||||
item_type = minetest.registered_items[itemname].type
|
||||
end
|
||||
prop = {
|
||||
is_visible = true,
|
||||
visual = "sprite",
|
||||
textures = {"unknown_item.png"}
|
||||
}
|
||||
if item_texture and item_texture ~= "" then
|
||||
prop.visual = "sprite"
|
||||
prop.textures = {item_texture}
|
||||
prop.visual_size = {x=0.3, y=0.3}
|
||||
else
|
||||
prop.visual = "wielditem"
|
||||
prop.textures = {itemname}
|
||||
prop.visual_size = {x=0.15, y=0.15}
|
||||
end
|
||||
self.object:set_properties(prop)
|
||||
end,
|
||||
|
||||
get_staticdata = function(self)
|
||||
if self.start_pos==nil then return end
|
||||
local velocity=self.object:getvelocity()
|
||||
self.object:setpos(self.start_pos)
|
||||
return minetest.serialize({
|
||||
itemstring=self.itemstring,
|
||||
velocity=velocity,
|
||||
start_pos=self.start_pos
|
||||
})
|
||||
end,
|
||||
|
||||
on_activate = function(self, staticdata)
|
||||
if staticdata=="" or staticdata==nil then return end
|
||||
local item = minetest.deserialize(staticdata)
|
||||
local stack = ItemStack(item.itemstring)
|
||||
local itemtable = stack:to_table()
|
||||
local itemname = nil
|
||||
if itemtable then
|
||||
itemname = stack:to_table().name
|
||||
end
|
||||
|
||||
if itemname then
|
||||
self.start_pos=item.start_pos
|
||||
self.object:setvelocity(item.velocity)
|
||||
self.object:setacceleration({x=0, y=0, z=0})
|
||||
self.object:setpos(item.start_pos)
|
||||
end
|
||||
self:set_item(item.itemstring)
|
||||
end,
|
||||
|
||||
on_step = function(self, dtime)
|
||||
if self.start_pos==nil then
|
||||
local pos = self.object:getpos()
|
||||
self.start_pos=roundpos(pos)
|
||||
end
|
||||
local pos = self.object:getpos()
|
||||
local node = minetest.get_node(pos)
|
||||
local meta = minetest.get_meta(pos)
|
||||
local tubelike = meta:get_int("tubelike")
|
||||
local stack = ItemStack(self.itemstring)
|
||||
local drop_pos = nil
|
||||
|
||||
local velocity=self.object:getvelocity()
|
||||
|
||||
if velocity == nil then return end
|
||||
|
||||
local velocitycopy = {x = velocity.x, y = velocity.y, z = velocity.z}
|
||||
|
||||
local moved = false
|
||||
local speed = math.abs(velocity.x+velocity.y+velocity.z)
|
||||
local vel = {x = velocity.x/speed, y = velocity.y/speed, z = velocity.z/speed, speed = speed}
|
||||
|
||||
if math.abs(vel.x) == 1 then
|
||||
local next_node = math.abs(pos.x-self.start_pos.x)
|
||||
if next_node >= 1 then
|
||||
self.start_pos.x = self.start_pos.x+vel.x
|
||||
moved = true
|
||||
end
|
||||
elseif math.abs(vel.y) == 1 then
|
||||
local next_node = math.abs(pos.y-self.start_pos.y)
|
||||
if next_node >= 1 then
|
||||
self.start_pos.y = self.start_pos.y+vel.y
|
||||
moved = true
|
||||
end
|
||||
elseif math.abs(vel.z) == 1 then
|
||||
local next_node = math.abs(pos.z-self.start_pos.z)
|
||||
if next_node >= 1 then
|
||||
self.start_pos.z = self.start_pos.z+vel.z
|
||||
moved = true
|
||||
end
|
||||
end
|
||||
|
||||
local sposcopy = {x = self.start_pos.x, y = self.start_pos.y, z = self.start_pos.z}
|
||||
|
||||
node = minetest.get_node(self.start_pos)
|
||||
if moved and minetest.get_item_group(node.name, "tubedevice_receiver") == 1 then
|
||||
local leftover = nil
|
||||
if minetest.registered_nodes[node.name].tube and minetest.registered_nodes[node.name].tube.insert_object then
|
||||
leftover = minetest.registered_nodes[node.name].tube.insert_object(self.start_pos, node, stack, vel)
|
||||
else
|
||||
leftover = stack
|
||||
end
|
||||
if leftover:is_empty() then
|
||||
self.object:remove()
|
||||
return
|
||||
end
|
||||
velocity.x = -velocity.x
|
||||
velocity.y = -velocity.y
|
||||
velocity.z = -velocity.z
|
||||
self.object:setvelocity(velocity)
|
||||
self:set_item(leftover:to_string())
|
||||
return
|
||||
end
|
||||
|
||||
if moved then
|
||||
if go_next (self.start_pos, velocity, stack) == 0 then
|
||||
drop_pos = minetest.find_node_near(vector.add(self.start_pos, velocity), 1, "air")
|
||||
if drop_pos then
|
||||
minetest.item_drop(stack, "", drop_pos)
|
||||
self.object:remove()
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
if velocity.x~=velocitycopy.x or velocity.y~=velocitycopy.y or velocity.z~=velocitycopy.z or
|
||||
self.start_pos.x~=sposcopy.x or self.start_pos.y~=sposcopy.y or self.start_pos.z~=sposcopy.z then
|
||||
self.object:setpos(self.start_pos)
|
||||
self.object:setvelocity(velocity)
|
||||
end
|
||||
end
|
||||
})
|
||||
|
||||
if minetest.get_modpath("mesecons_mvps") ~= nil then
|
||||
local function add_table(table,toadd)
|
||||
local i = 1
|
||||
while true do
|
||||
o = table[i]
|
||||
if o == toadd then return end
|
||||
if o == nil then break end
|
||||
i = i+1
|
||||
end
|
||||
table[i] = toadd
|
||||
end
|
||||
mesecon:register_mvps_unmov("pipeworks:tubed_item")
|
||||
mesecon:register_on_mvps_move(function(moved_nodes)
|
||||
local objects_to_move = {}
|
||||
for _, n in ipairs(moved_nodes) do
|
||||
local objects = minetest.get_objects_inside_radius(n.oldpos, 1)
|
||||
for _, obj in ipairs(objects) do
|
||||
local entity = obj:get_luaentity()
|
||||
if entity and entity.name == "pipeworks:tubed_item" then
|
||||
--objects_to_move[#objects_to_move+1] = obj
|
||||
add_table(objects_to_move, obj)
|
||||
end
|
||||
end
|
||||
end
|
||||
if #objects_to_move > 0 then
|
||||
local dir = vector.subtract(moved_nodes[1].pos, moved_nodes[1].oldpos)
|
||||
for _, obj in ipairs(objects_to_move) do
|
||||
local entity = obj:get_luaentity()
|
||||
obj:setpos(vector.add(obj:getpos(), dir))
|
||||
entity.start_pos = vector.add(entity.start_pos, dir)
|
||||
end
|
||||
end
|
||||
end)
|
||||
end
|
|
@ -1,202 +0,0 @@
|
|||
---------------------
|
||||
-- The various models
|
||||
|
||||
-- Pipe models
|
||||
|
||||
pipeworks.pipe_leftstub = {
|
||||
{ -32/64, -2/64, -6/64, 1/64, 2/64, 6/64 }, -- pipe segment against -X face
|
||||
{ -32/64, -4/64, -5/64, 1/64, 4/64, 5/64 },
|
||||
{ -32/64, -5/64, -4/64, 1/64, 5/64, 4/64 },
|
||||
{ -32/64, -6/64, -2/64, 1/64, 6/64, 2/64 },
|
||||
|
||||
{ -32/64, -3/64, -8/64, -30/64, 3/64, 8/64 }, -- (the flange for it)
|
||||
{ -32/64, -5/64, -7/64, -30/64, 5/64, 7/64 },
|
||||
{ -32/64, -6/64, -6/64, -30/64, 6/64, 6/64 },
|
||||
{ -32/64, -7/64, -5/64, -30/64, 7/64, 5/64 },
|
||||
{ -32/64, -8/64, -3/64, -30/64, 8/64, 3/64 }
|
||||
}
|
||||
|
||||
pipeworks.pipe_rightstub = {
|
||||
{ -1/64, -2/64, -6/64, 32/64, 2/64, 6/64 }, -- pipe segment against +X face
|
||||
{ -1/64, -4/64, -5/64, 32/64, 4/64, 5/64 },
|
||||
{ -1/64, -5/64, -4/64, 32/64, 5/64, 4/64 },
|
||||
{ -1/64, -6/64, -2/64, 32/64, 6/64, 2/64 },
|
||||
|
||||
{ 30/64, -3/64, -8/64, 32/64, 3/64, 8/64 }, -- (the flange for it)
|
||||
{ 30/64, -5/64, -7/64, 32/64, 5/64, 7/64 },
|
||||
{ 30/64, -6/64, -6/64, 32/64, 6/64, 6/64 },
|
||||
{ 30/64, -7/64, -5/64, 32/64, 7/64, 5/64 },
|
||||
{ 30/64, -8/64, -3/64, 32/64, 8/64, 3/64 }
|
||||
}
|
||||
|
||||
pipeworks.pipe_bottomstub = {
|
||||
{ -2/64, -32/64, -6/64, 2/64, 1/64, 6/64 }, -- pipe segment against -Y face
|
||||
{ -4/64, -32/64, -5/64, 4/64, 1/64, 5/64 },
|
||||
{ -5/64, -32/64, -4/64, 5/64, 1/64, 4/64 },
|
||||
{ -6/64, -32/64, -2/64, 6/64, 1/64, 2/64 },
|
||||
|
||||
{ -3/64, -32/64, -8/64, 3/64, -30/64, 8/64 }, -- (the flange for it)
|
||||
{ -5/64, -32/64, -7/64, 5/64, -30/64, 7/64 },
|
||||
{ -6/64, -32/64, -6/64, 6/64, -30/64, 6/64 },
|
||||
{ -7/64, -32/64, -5/64, 7/64, -30/64, 5/64 },
|
||||
{ -8/64, -32/64, -3/64, 8/64, -30/64, 3/64 }
|
||||
}
|
||||
|
||||
pipeworks.pipe_topstub = {
|
||||
{ -2/64, -1/64, -6/64, 2/64, 32/64, 6/64 }, -- pipe segment against +Y face
|
||||
{ -4/64, -1/64, -5/64, 4/64, 32/64, 5/64 },
|
||||
{ -5/64, -1/64, -4/64, 5/64, 32/64, 4/64 },
|
||||
{ -6/64, -1/64, -2/64, 6/64, 32/64, 2/64 },
|
||||
|
||||
{ -3/64, 30/64, -8/64, 3/64, 32/64, 8/64 }, -- (the flange for it)
|
||||
{ -5/64, 30/64, -7/64, 5/64, 32/64, 7/64 },
|
||||
{ -6/64, 30/64, -6/64, 6/64, 32/64, 6/64 },
|
||||
{ -7/64, 30/64, -5/64, 7/64, 32/64, 5/64 },
|
||||
{ -8/64, 30/64, -3/64, 8/64, 32/64, 3/64 }
|
||||
}
|
||||
|
||||
pipeworks.pipe_frontstub = {
|
||||
{ -6/64, -2/64, -32/64, 6/64, 2/64, 1/64 }, -- pipe segment against -Z face
|
||||
{ -5/64, -4/64, -32/64, 5/64, 4/64, 1/64 },
|
||||
{ -4/64, -5/64, -32/64, 4/64, 5/64, 1/64 },
|
||||
{ -2/64, -6/64, -32/64, 2/64, 6/64, 1/64 },
|
||||
|
||||
{ -8/64, -3/64, -32/64, 8/64, 3/64, -30/64 }, -- (the flange for it)
|
||||
{ -7/64, -5/64, -32/64, 7/64, 5/64, -30/64 },
|
||||
{ -6/64, -6/64, -32/64, 6/64, 6/64, -30/64 },
|
||||
{ -5/64, -7/64, -32/64, 5/64, 7/64, -30/64 },
|
||||
{ -3/64, -8/64, -32/64, 3/64, 8/64, -30/64 }
|
||||
}
|
||||
|
||||
pipeworks.pipe_backstub = {
|
||||
{ -6/64, -2/64, -1/64, 6/64, 2/64, 32/64 }, -- pipe segment against -Z face
|
||||
{ -5/64, -4/64, -1/64, 5/64, 4/64, 32/64 },
|
||||
{ -4/64, -5/64, -1/64, 4/64, 5/64, 32/64 },
|
||||
{ -2/64, -6/64, -1/64, 2/64, 6/64, 32/64 },
|
||||
|
||||
{ -8/64, -3/64, 30/64, 8/64, 3/64, 32/64 }, -- (the flange for it)
|
||||
{ -7/64, -5/64, 30/64, 7/64, 5/64, 32/64 },
|
||||
{ -6/64, -6/64, 30/64, 6/64, 6/64, 32/64 },
|
||||
{ -5/64, -7/64, 30/64, 5/64, 7/64, 32/64 },
|
||||
{ -3/64, -8/64, 30/64, 3/64, 8/64, 32/64 }
|
||||
}
|
||||
|
||||
pipeworks.pipe_boxes = {pipeworks.pipe_leftstub, pipeworks.pipe_rightstub, pipeworks.pipe_bottomstub, pipeworks.pipe_topstub, pipeworks.pipe_frontstub, pipeworks.pipe_backstub}
|
||||
|
||||
pipeworks.pipe_selectboxes = {
|
||||
{ -32/64, -8/64, -8/64, 8/64, 8/64, 8/64 },
|
||||
{ -8/64 , -8/64, -8/64, 32/64, 8/64, 8/64 },
|
||||
{ -8/64 , -32/64, -8/64, 8/64, 8/64, 8/64 },
|
||||
{ -8/64 , -8/64, -8/64, 8/64, 32/64, 8/64 },
|
||||
{ -8/64 , -8/64, -32/64, 8/64, 8/64, 8/64 },
|
||||
{ -8/64 , -8/64, -8/64, 8/64, 8/64, 32/64 }
|
||||
}
|
||||
|
||||
pipeworks.pipe_bendsphere = {
|
||||
{ -4/64, -4/64, -4/64, 4/64, 4/64, 4/64 },
|
||||
{ -5/64, -3/64, -3/64, 5/64, 3/64, 3/64 },
|
||||
{ -3/64, -5/64, -3/64, 3/64, 5/64, 3/64 },
|
||||
{ -3/64, -3/64, -5/64, 3/64, 3/64, 5/64 }
|
||||
}
|
||||
|
||||
-- Tube models
|
||||
|
||||
pipeworks.tube_leftstub = {
|
||||
{ -32/64, -9/64, -9/64, 9/64, 9/64, 9/64 }, -- tube segment against -X face
|
||||
}
|
||||
|
||||
pipeworks.tube_rightstub = {
|
||||
{ -9/64, -9/64, -9/64, 32/64, 9/64, 9/64 }, -- tube segment against +X face
|
||||
}
|
||||
|
||||
pipeworks.tube_bottomstub = {
|
||||
{ -9/64, -32/64, -9/64, 9/64, 9/64, 9/64 }, -- tube segment against -Y face
|
||||
}
|
||||
|
||||
pipeworks.tube_topstub = {
|
||||
{ -9/64, -9/64, -9/64, 9/64, 32/64, 9/64 }, -- tube segment against +Y face
|
||||
}
|
||||
|
||||
pipeworks.tube_frontstub = {
|
||||
{ -9/64, -9/64, -32/64, 9/64, 9/64, 9/64 }, -- tube segment against -Z face
|
||||
}
|
||||
|
||||
pipeworks.tube_backstub = {
|
||||
{ -9/64, -9/64, -9/64, 9/64, 9/64, 32/64 }, -- tube segment against -Z face
|
||||
}
|
||||
|
||||
pipeworks.tube_boxes = {pipeworks.tube_leftstub, pipeworks.tube_rightstub, pipeworks.tube_bottomstub, pipeworks.tube_topstub, pipeworks.tube_frontstub, pipeworks.tube_backstub}
|
||||
|
||||
pipeworks.tube_selectboxes = {
|
||||
{ -32/64, -10/64, -10/64, 10/64, 10/64, 10/64 },
|
||||
{ -10/64 , -10/64, -10/64, 32/64, 10/64, 10/64 },
|
||||
{ -10/64 , -32/64, -10/64, 10/64, 10/64, 10/64 },
|
||||
{ -10/64 , -10/64, -10/64, 10/64, 32/64, 10/64 },
|
||||
{ -10/64 , -10/64, -32/64, 10/64, 10/64, 10/64 },
|
||||
{ -10/64 , -10/64, -10/64, 10/64, 10/64, 32/64 }
|
||||
}
|
||||
|
||||
-- Device models
|
||||
|
||||
pipeworks.pipe_pumpbody = {
|
||||
{ -7/16, -6/16, -7/16, 7/16, 5/16, 7/16 },
|
||||
{ -8/16, -8/16, -8/16, 8/16, -6/16, 8/16 }
|
||||
}
|
||||
|
||||
pipeworks.pipe_valvebody = {
|
||||
{ -4/16, -4/16, -4/16, 4/16, 4/16, 4/16 }
|
||||
}
|
||||
|
||||
pipeworks.pipe_valvehandle_on = {
|
||||
{ -5/16, 4/16, -1/16, 0, 5/16, 1/16 }
|
||||
}
|
||||
|
||||
pipeworks.pipe_valvehandle_off = {
|
||||
{ -1/16, 4/16, -5/16, 1/16, 5/16, 0 }
|
||||
}
|
||||
|
||||
pipeworks.pipe_sensorbody = {
|
||||
{ -3/16, -2/16, -2/16, 3/16, 2/16, 2/16 }
|
||||
}
|
||||
|
||||
pipeworks.spigot_bottomstub = {
|
||||
{ -2/64, -16/64, -6/64, 2/64, 1/64, 6/64 }, -- pipe segment against -Y face
|
||||
{ -4/64, -16/64, -5/64, 4/64, 1/64, 5/64 },
|
||||
{ -5/64, -16/64, -4/64, 5/64, 1/64, 4/64 },
|
||||
{ -6/64, -16/64, -2/64, 6/64, 1/64, 2/64 },
|
||||
|
||||
{ -3/64, -16/64, -8/64, 3/64, -14/64, 8/64 }, -- (the flange for it)
|
||||
{ -5/64, -16/64, -7/64, 5/64, -14/64, 7/64 },
|
||||
{ -6/64, -16/64, -6/64, 6/64, -14/64, 6/64 },
|
||||
{ -7/64, -16/64, -5/64, 7/64, -14/64, 5/64 },
|
||||
{ -8/64, -16/64, -3/64, 8/64, -14/64, 3/64 }
|
||||
}
|
||||
|
||||
pipeworks.spigot_stream = {
|
||||
{ -3/64, (-41/64)-0.01, -5/64, 3/64, -16/64, 5/64 },
|
||||
{ -4/64, (-41/64)-0.01, -4/64, 4/64, -16/64, 4/64 },
|
||||
{ -5/64, (-41/64)-0.01, -3/64, 5/64, -16/64, 3/64 }
|
||||
}
|
||||
|
||||
pipeworks.entry_panel = {
|
||||
{ -8/16, -8/16, -1/16, 8/16, 8/16, 1/16 }
|
||||
}
|
||||
|
||||
pipeworks.fountainhead_model = {
|
||||
{ -2/64, -32/64, -6/64, 2/64, 21/64, 6/64 }, -- main segment
|
||||
{ -4/64, -32/64, -5/64, 4/64, 21/64, 5/64 },
|
||||
{ -5/64, -32/64, -4/64, 5/64, 21/64, 4/64 },
|
||||
{ -6/64, -32/64, -2/64, 6/64, 21/64, 2/64 },
|
||||
|
||||
{ -3/64, -32/64, -8/64, 3/64, -30/64, 8/64 }, -- bottom flange
|
||||
{ -5/64, -32/64, -7/64, 5/64, -30/64, 7/64 },
|
||||
{ -6/64, -32/64, -6/64, 6/64, -30/64, 6/64 },
|
||||
{ -7/64, -32/64, -5/64, 7/64, -30/64, 5/64 },
|
||||
{ -8/64, -32/64, -3/64, 8/64, -30/64, 3/64 },
|
||||
|
||||
{ -3/64, 20/64, -8/64, 3/64, 32/64, 8/64 }, -- top flange/outlet
|
||||
{ -5/64, 20/64, -7/64, 5/64, 32/64, 7/64 },
|
||||
{ -6/64, 20/64, -6/64, 6/64, 32/64, 6/64 },
|
||||
{ -7/64, 20/64, -5/64, 7/64, 32/64, 5/64 },
|
||||
{ -8/64, 20/64, -3/64, 8/64, 32/64, 3/64 }
|
||||
}
|
|
@ -1,392 +0,0 @@
|
|||
|
||||
--register 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") --old name
|
||||
minetest.register_alias("technic:node_breaker_on", "pipeworks:nodebreaker_on") --old name
|
||||
|
||||
minetest.register_craft({
|
||||
output = 'pipeworks:nodebreaker_off 1',
|
||||
recipe = {
|
||||
{'group:wood', 'default:pick_mese','group:wood'},
|
||||
{'default:stone', 'mesecons:piston','default:stone'},
|
||||
{'default:stone', 'mesecons:mesecon','default:stone'},
|
||||
}
|
||||
})
|
||||
|
||||
local function swap_node(pos, name)
|
||||
local node = minetest.get_node(pos)
|
||||
if node.name == name then
|
||||
return
|
||||
end
|
||||
node.name = name
|
||||
minetest.swap_node(pos, node)
|
||||
end
|
||||
|
||||
--define the functions from https://github.com/minetest/minetest/pull/834 while waiting for the devs to notice it
|
||||
local function dir_to_facedir(dir, is6d)
|
||||
--account for y if requested
|
||||
if is6d and math.abs(dir.y) > math.abs(dir.x) and math.abs(dir.y) > math.abs(dir.z) then
|
||||
|
||||
--from above
|
||||
if dir.y < 0 then
|
||||
if math.abs(dir.x) > math.abs(dir.z) then
|
||||
if dir.x < 0 then
|
||||
return 19
|
||||
else
|
||||
return 13
|
||||
end
|
||||
else
|
||||
if dir.z < 0 then
|
||||
return 10
|
||||
else
|
||||
return 4
|
||||
end
|
||||
end
|
||||
|
||||
--from below
|
||||
else
|
||||
if math.abs(dir.x) > math.abs(dir.z) then
|
||||
if dir.x < 0 then
|
||||
return 15
|
||||
else
|
||||
return 17
|
||||
end
|
||||
else
|
||||
if dir.z < 0 then
|
||||
return 6
|
||||
else
|
||||
return 8
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
--otherwise, place horizontally
|
||||
elseif math.abs(dir.x) > math.abs(dir.z) then
|
||||
if dir.x < 0 then
|
||||
return 3
|
||||
else
|
||||
return 1
|
||||
end
|
||||
else
|
||||
if dir.z < 0 then
|
||||
return 2
|
||||
else
|
||||
return 0
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
local function delay(x)
|
||||
return (function() return x end)
|
||||
end
|
||||
|
||||
local function break_node (pos, facedir)
|
||||
--locate the outgoing velocity, front, and back of the node via facedir_to_dir
|
||||
if type(facedir) ~= "number" or facedir < 0 or facedir > 23 then return end
|
||||
|
||||
local vel = minetest.facedir_to_dir(facedir)
|
||||
local front = {x=pos.x - vel.x, y=pos.y - vel.y, z=pos.z - vel.z}
|
||||
|
||||
local node = minetest.get_node(front)
|
||||
--if node.name == "air" or node.name == "ignore" then
|
||||
-- return nil
|
||||
--elseif minetest.registered_nodes[node.name] and minetest.registered_nodes[node.name].liquidtype ~= "none" then
|
||||
-- return nil
|
||||
--end
|
||||
local meta = minetest.get_meta(pos)
|
||||
local inv = meta:get_inventory()
|
||||
local pick_inv = "pick"
|
||||
local pick = inv:get_stack("pick", 1)
|
||||
if pick:is_empty() then
|
||||
pick = ItemStack("default:pick_mese")
|
||||
inv:set_stack("ghost_pick", 1, pick)
|
||||
pick_inv = "ghost_pick"
|
||||
end
|
||||
local pitch
|
||||
local yaw
|
||||
if vel.z < 0 then
|
||||
yaw = 0
|
||||
pitch = 0
|
||||
elseif vel.z > 0 then
|
||||
yaw = math.pi
|
||||
pitch = 0
|
||||
elseif vel.x < 0 then
|
||||
yaw = 3*math.pi/2
|
||||
pitch = 0
|
||||
elseif vel.x > 0 then
|
||||
yaw = math.pi/2
|
||||
pitch = 0
|
||||
elseif vel.y > 0 then
|
||||
yaw = 0
|
||||
pitch = -math.pi/2
|
||||
else
|
||||
yaw = 0
|
||||
pitch = math.pi/2
|
||||
end
|
||||
local digger = {
|
||||
get_inventory_formspec = delay(""),
|
||||
get_look_dir = delay({x = -vel.x, y = -vel.y, z = -vel.z}),
|
||||
get_look_pitch = delay(pitch),
|
||||
get_look_yaw = delay(yaw),
|
||||
get_player_control = delay({jump=false, right=false, left=false, LMB=false, RMB=false, sneak=false, aux1=false, down=false, up=false}),
|
||||
get_player_control_bits = delay(0),
|
||||
get_player_name = delay(meta:get_string("owner")),
|
||||
is_player = delay(true),
|
||||
set_inventory_formspec = delay(),
|
||||
getpos = delay({x = pos.x, y = pos.y - 1.5, z = pos.z}), -- Player height
|
||||
get_hp = delay(20),
|
||||
get_inventory = delay(inv),
|
||||
get_wielded_item = delay(pick),
|
||||
get_wield_index = delay(1),
|
||||
get_wield_list = delay(pick_inv),
|
||||
moveto = delay(),
|
||||
punch = delay(),
|
||||
remove = delay(),
|
||||
right_click = delay(),
|
||||
setpos = delay(),
|
||||
set_hp = delay(),
|
||||
set_properties = delay(),
|
||||
set_wielded_item = function(self, stack)
|
||||
if stack:get_name() == pick:get_name() then
|
||||
inv:set_stack(pick_inv, 1, stack)
|
||||
else
|
||||
inv:add_item("main", stack)
|
||||
inv:set_stack(pick_inv, 1, ItemStack(""))
|
||||
end
|
||||
end,
|
||||
set_animation = delay(),
|
||||
set_attach = delay(),
|
||||
set_detach = delay(),
|
||||
set_bone_position = delay(),
|
||||
}
|
||||
|
||||
if pick_inv == "pick" and minetest.registered_items[pick:get_name()] and minetest.registered_items[pick:get_name()].on_use then
|
||||
local pos_under, pos_above = {x = pos.x - vel.x, y = pos.y - vel.y, z = pos.z - vel.z}, {x = pos.x - 2*vel.x, y = pos.y - 2*vel.y, z = pos.z - 2*vel.z}
|
||||
local pointed_thing = {type="node", under=pos_under, above=pos_above}
|
||||
inv:set_stack(pick_inv, 1, minetest.registered_items[pick:get_name()].on_use(pick, digger, pointed_thing) or pick)
|
||||
else
|
||||
minetest.node_dig(front, node, digger)
|
||||
end
|
||||
|
||||
for i = 1, 100 do
|
||||
local dropped_item = inv:get_stack("main", i)
|
||||
if not dropped_item:is_empty() then
|
||||
local item1 = pipeworks.tube_item({x=pos.x, y=pos.y, z=pos.z}, dropped_item)
|
||||
item1:get_luaentity().start_pos = {x=pos.x, y=pos.y, z=pos.z}
|
||||
item1:setvelocity(vel)
|
||||
item1:setacceleration({x=0, y=0, z=0})
|
||||
inv:set_stack("main", i, ItemStack(""))
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
local node_breaker_on = function(pos, node)
|
||||
if node.name == "pipeworks:nodebreaker_off" then
|
||||
swap_node(pos, "pipeworks:nodebreaker_on")
|
||||
break_node(pos, node.param2)
|
||||
nodeupdate(pos)
|
||||
end
|
||||
end
|
||||
|
||||
local node_breaker_off = function(pos, node)
|
||||
if node.name == "pipeworks:nodebreaker_on" then
|
||||
swap_node(pos, "pipeworks:nodebreaker_off")
|
||||
nodeupdate(pos)
|
||||
end
|
||||
end
|
||||
|
||||
minetest.register_node("pipeworks:nodebreaker_off", {
|
||||
description = "Node Breaker",
|
||||
tile_images = {"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 = true,
|
||||
paramtype2 = "facedir",
|
||||
groups = {snappy=2,choppy=2,oddly_breakable_by_hand=2, mesecon = 2,tubedevice=1, tubedevice_receiver=1},
|
||||
mesecons= {effector={rules=pipeworks.rules_all,action_on=node_breaker_on, action_off=node_breaker_off}},
|
||||
sounds = default.node_sound_stone_defaults(),
|
||||
tube = {connect_sides = {left = 1, right = 1, back = 1, top = 1, bottom = 1},
|
||||
input_inventory = "pick",
|
||||
insert_object = function(pos, node, stack, direction)
|
||||
local vel = minetest.facedir_to_dir(node.param2)
|
||||
if math.abs(vel.x) == math.abs(direction.x) and math.abs(vel.y) == math.abs(direction.y) and math.abs(vel.z) == math.abs(direction.z) then
|
||||
return stack
|
||||
end
|
||||
local meta = minetest.get_meta(pos)
|
||||
local inv = meta:get_inventory()
|
||||
return inv:add_item("pick", stack)
|
||||
end,
|
||||
can_insert = function(pos, node, stack, direction)
|
||||
local vel = minetest.facedir_to_dir(node.param2)
|
||||
if math.abs(vel.x) == math.abs(direction.x) and math.abs(vel.y) == math.abs(direction.y) and math.abs(vel.z) == math.abs(direction.z) then
|
||||
return false
|
||||
end
|
||||
local meta = minetest.get_meta(pos)
|
||||
local inv = meta:get_inventory()
|
||||
return inv:room_for_item("pick", stack)
|
||||
end,
|
||||
can_remove = function(pos, node, stack, dir)
|
||||
return stack:get_count()
|
||||
end},
|
||||
on_construct = function(pos)
|
||||
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)
|
||||
--inv:set_stack("pick", 1, ItemStack("default:pick_mese"))
|
||||
meta:set_string("formspec",
|
||||
"invsize[8,6;]"..
|
||||
"label[0,0;Node breaker]"..
|
||||
"list[current_name;pick;3.5,0;1,1;]"..
|
||||
"list[current_player;main;0,2;8,4;]")
|
||||
end,
|
||||
after_place_node = function (pos, placer)
|
||||
pipeworks.scan_for_tube_objects(pos, placer)
|
||||
local placer_pos = placer:getpos()
|
||||
|
||||
--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 = dir_to_facedir(dir, true)
|
||||
minetest.set_node(pos, node)
|
||||
minetest.log("action", "real (6d) facedir: " .. node.param2)
|
||||
end
|
||||
|
||||
minetest.get_meta(pos):set_string("owner", placer:get_player_name())
|
||||
end,
|
||||
after_dig_node = function(pos, oldnode, oldmetadata, digger)
|
||||
local stack = oldmetadata.inventory.pick[1]
|
||||
if not stack:is_empty() then
|
||||
minetest.add_item(pos, stack)
|
||||
end
|
||||
pipeworks.scan_for_tube_objects(pos, oldnode, oldmetadata, digger)
|
||||
end,
|
||||
allow_metadata_inventory_move = function(pos, from_list, from_index, to_list, to_index, count, player)
|
||||
local meta = minetest.get_meta(pos)
|
||||
if player:get_player_name() ~= meta:get_string("owner") and meta:get_string("owner") ~= "" then
|
||||
return 0
|
||||
end
|
||||
return count
|
||||
end,
|
||||
allow_metadata_inventory_put = function(pos, listname, index, stack, player)
|
||||
local meta = minetest.get_meta(pos)
|
||||
if player:get_player_name() ~= meta:get_string("owner") and meta:get_string("owner") ~= "" then
|
||||
return 0
|
||||
end
|
||||
return stack:get_count()
|
||||
end,
|
||||
allow_metadata_inventory_take = function(pos, listname, index, stack, player)
|
||||
local meta = minetest.get_meta(pos)
|
||||
if player:get_player_name() ~= meta:get_string("owner") and meta:get_string("owner") ~= "" then
|
||||
return 0
|
||||
end
|
||||
return stack:get_count()
|
||||
end
|
||||
})
|
||||
|
||||
minetest.register_node("pipeworks:nodebreaker_on", {
|
||||
description = "Node Breaker",
|
||||
tile_images = {"pipeworks_nodebreaker_top_on.png","pipeworks_nodebreaker_bottom_on.png","pipeworks_nodebreaker_side2_on.png","pipeworks_nodebreaker_side1_on.png",
|
||||
"pipeworks_nodebreaker_back.png","pipeworks_nodebreaker_front_on.png"},
|
||||
mesecons= {effector={rules=pipeworks.rules_all,action_on=node_breaker_on, action_off=node_breaker_off}},
|
||||
is_ground_content = true,
|
||||
paramtype2 = "facedir",
|
||||
groups = {snappy=2,choppy=2,oddly_breakable_by_hand=2, mesecon = 2,tubedevice=1,not_in_creative_inventory=1, tubedevice_receiver=1},
|
||||
sounds = default.node_sound_stone_defaults(),
|
||||
drop = "pipeworks:nodebreaker_off",
|
||||
tube = {connect_sides = {left = 1, right = 1, back = 1, top = 1, bottom = 1},
|
||||
input_inventory = "pick",
|
||||
insert_object = function(pos, node, stack, direction)
|
||||
local vel = minetest.facedir_to_dir(node.param2)
|
||||
if math.abs(vel.x) == math.abs(direction.x) and math.abs(vel.y) == math.abs(direction.y) and math.abs(vel.z) == math.abs(direction.z) then
|
||||
return stack
|
||||
end
|
||||
local meta = minetest.get_meta(pos)
|
||||
local inv = meta:get_inventory()
|
||||
return inv:add_item("pick", stack)
|
||||
end,
|
||||
can_insert = function(pos, node, stack, direction)
|
||||
local vel = minetest.facedir_to_dir(node.param2)
|
||||
if math.abs(vel.x) == math.abs(direction.x) and math.abs(vel.y) == math.abs(direction.y) and math.abs(vel.z) == math.abs(direction.z) then
|
||||
return false
|
||||
end
|
||||
local meta = minetest.get_meta(pos)
|
||||
local inv = meta:get_inventory()
|
||||
return inv:room_for_item("pick", stack)
|
||||
end,
|
||||
can_remove = function(pos, node, stack, dir)
|
||||
return stack:get_count()
|
||||
end},
|
||||
on_construct = function(pos)
|
||||
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)
|
||||
meta:set_string("formspec",
|
||||
"invsize[8,6;]"..
|
||||
"label[0,0;Node breaker]"..
|
||||
"list[current_name;pick;3.5,0;1,1;]"..
|
||||
"list[current_player;main;0,2;8,4;]")
|
||||
--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:getpos()
|
||||
|
||||
--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 = dir_to_facedir(dir, true)
|
||||
minetest.set_node(pos, node)
|
||||
minetest.log("action", "real (6d) facedir: " .. node.param2)
|
||||
end
|
||||
|
||||
minetest.get_meta(pos):set_string("owner", placer:get_player_name())
|
||||
end,
|
||||
after_dig_node = function(pos, oldnode, oldmetadata, digger)
|
||||
local stack = oldmetadata.inventory.pick[1]
|
||||
if not stack:is_empty() then
|
||||
minetest.add_item(pos, stack)
|
||||
end
|
||||
pipeworks.scan_for_tube_objects(pos, oldnode, oldmetadata, digger)
|
||||
end,
|
||||
allow_metadata_inventory_move = function(pos, from_list, from_index, to_list, to_index, count, player)
|
||||
local meta = minetest.get_meta(pos)
|
||||
if player:get_player_name() ~= meta:get_string("owner") and meta:get_string("owner") ~= "" then
|
||||
return 0
|
||||
end
|
||||
return count
|
||||
end,
|
||||
allow_metadata_inventory_put = function(pos, listname, index, stack, player)
|
||||
local meta = minetest.get_meta(pos)
|
||||
if player:get_player_name() ~= meta:get_string("owner") and meta:get_string("owner") ~= "" then
|
||||
return 0
|
||||
end
|
||||
return stack:get_count()
|
||||
end,
|
||||
allow_metadata_inventory_take = function(pos, listname, index, stack, player)
|
||||
local meta = minetest.get_meta(pos)
|
||||
if player:get_player_name() ~= meta:get_string("owner") and meta:get_string("owner") ~= "" then
|
||||
return 0
|
||||
end
|
||||
return stack:get_count()
|
||||
end
|
||||
})
|