1
0
mirror of https://github.com/sys4-fr/server-nalc.git synced 2024-11-14 06:20:32 +01:00

Updated mesecons, pipeworks and homedecor

- Homedecor now using an inventory texture for lamps
- Reoganized pipeworks' code
- Added secure fix in pipeworks
- Added meshnodes, sounds and fixes in mesecons
- Removed "mesecons_compatibility"
This commit is contained in:
LeMagnesium 2015-02-05 19:07:29 +01:00
parent 3038c66e21
commit d57a4701f2
100 changed files with 2577 additions and 1460 deletions

View File

@ -5,12 +5,7 @@
-- This file defines some items in order to not have to depend on other mods.
-- Boilerplate to support localized strings if intllib mod is installed.
local S
if minetest.get_modpath("intllib") then
S = intllib.Getter()
else
S = function(s) return s end
end
local S = rawget(_G, "intllib") and intllib.Getter() or function(s) return s end
if (not minetest.get_modpath("homedecor")) then

View File

@ -51,13 +51,22 @@ end
--wrapper around minetest.register_node that sets sane defaults and interprets some specialized settings
function homedecor.register(name, def)
def.paramtype = def.paramtype or "light"
def.paramtype2 = def.paramtype2 or "facedir"
def.drawtype = def.drawtype
or (def.mesh and "mesh")
or (def.node_box and "nodebox")
def.paramtype = def.paramtype or "light"
-- avoid facedir for some drawtypes as they might be used internally for something else
-- even if undocumented
if not (def.drawtype == "glasslike_framed"
or def.drawtype == "raillike"
or def.drawtype == "plantlike"
or def.drawtype == "firelike") then
def.paramtype2 = def.paramtype2 or "facedir"
end
local infotext = def.infotext
--def.infotext = nil -- currently used to set locked refrigerator infotexts

View File

@ -16,15 +16,9 @@ homedecor.debug = 0
homedecor.detail_level = 16
homedecor.modpath = minetest.get_modpath("homedecor")
homedecor.intllib_modpath = minetest.get_modpath("intllib")
-- Boilerplate to support localized strings if intllib mod is installed.
local S
if minetest.get_modpath("intllib") then
S = intllib.Getter()
else
S = function(s) return s end
end
local S = rawget(_G, "intllib") and intllib.Getter() or function(s) return s end
homedecor.gettext = S
-- debug

View File

@ -338,6 +338,7 @@ local function reg_lamp(suffix, nxt, tilesuffix, light, color)
description = S("Table Lamp "..colordesc),
mesh = "homedecor_table_lamp.obj",
tiles = { "homedecor_table_standing_lamp"..lampcolor.."_"..suffix..".png" },
inventory_image = "homedecor_table_lamp"..lampcolor.."_inv.png",
walkable = false,
light_source = light,
selection_box = tlamp_cbox,

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.5 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.5 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.0 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.9 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.6 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.8 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 7.0 KiB

After

Width:  |  Height:  |  Size: 8.1 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 7.7 KiB

After

Width:  |  Height:  |  Size: 8.8 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 6.6 KiB

After

Width:  |  Height:  |  Size: 7.5 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 7.2 KiB

After

Width:  |  Height:  |  Size: 8.5 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 7.7 KiB

After

Width:  |  Height:  |  Size: 8.8 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 6.9 KiB

After

Width:  |  Height:  |  Size: 8.0 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 7.6 KiB

After

Width:  |  Height:  |  Size: 8.7 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 6.5 KiB

After

Width:  |  Height:  |  Size: 7.4 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 7.2 KiB

After

Width:  |  Height:  |  Size: 8.4 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 7.6 KiB

After

Width:  |  Height:  |  Size: 8.7 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 6.8 KiB

After

Width:  |  Height:  |  Size: 7.9 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 7.6 KiB

After

Width:  |  Height:  |  Size: 8.6 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 6.3 KiB

After

Width:  |  Height:  |  Size: 7.3 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 7.2 KiB

After

Width:  |  Height:  |  Size: 8.4 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 7.6 KiB

After

Width:  |  Height:  |  Size: 8.7 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 6.7 KiB

After

Width:  |  Height:  |  Size: 7.8 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 7.5 KiB

After

Width:  |  Height:  |  Size: 8.5 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 6.3 KiB

After

Width:  |  Height:  |  Size: 7.2 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 7.0 KiB

After

Width:  |  Height:  |  Size: 8.2 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 7.5 KiB

After

Width:  |  Height:  |  Size: 8.5 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 6.9 KiB

After

Width:  |  Height:  |  Size: 8.0 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 7.6 KiB

After

Width:  |  Height:  |  Size: 8.7 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 6.5 KiB

After

Width:  |  Height:  |  Size: 7.4 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 7.2 KiB

After

Width:  |  Height:  |  Size: 8.4 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 7.7 KiB

After

Width:  |  Height:  |  Size: 8.7 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 6.9 KiB

After

Width:  |  Height:  |  Size: 8.0 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 7.6 KiB

After

Width:  |  Height:  |  Size: 8.7 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 6.5 KiB

After

Width:  |  Height:  |  Size: 7.4 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 7.2 KiB

After

Width:  |  Height:  |  Size: 8.4 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 7.6 KiB

After

Width:  |  Height:  |  Size: 8.7 KiB

View File

@ -38,11 +38,14 @@ minetest.register_entity("itemframes:item",{
return ""
end,
})
local facedir = {}
facedir[0] = {x=0,y=0,z=1}
facedir[1] = {x=1,y=0,z=0}
facedir[2] = {x=0,y=0,z=-1}
facedir[3] = {x=-1,y=0,z=0}
local remove_item = function(pos, node)
local objs = nil
if node.name == "itemframes:frame" then
@ -58,6 +61,7 @@ local remove_item = function(pos, node)
end
end
end
local update_item = function(pos, node)
remove_item(pos, node)
local meta = minetest.get_meta(pos)
@ -130,9 +134,11 @@ minetest.register_node("itemframes:frame",{
end
end,
can_dig = function(pos,player)
local meta = minetest.get_meta(pos)
return player:get_player_name() == meta:get_string("owner")
end,
after_destruct = remove_item,
})
minetest.register_craft({
@ -181,9 +187,11 @@ function itemframes.register_pedestal(subname, recipeitem, groups, images, descr
end
end,
can_dig = function(pos,player)
local meta = minetest.get_meta(pos)
return player:get_player_name() == meta:get_string("owner")
end,
after_destruct = remove_item,
})
minetest.register_craft({

View File

@ -3,10 +3,16 @@
-- PilzAdam's original text-on-signs mod and rewritten by Vanessa Ezekowitz
-- and Diego Martinez
-- textpos = {
-- { delta = {entity position for 0° yaw}, exact yaw expression }
-- { delta = {entity position for 180° yaw}, exact yaw expression }
-- { delta = {entity position for 270° yaw}, exact yaw expression }
-- { delta = {entity position for 90° yaw}, exact yaw expression }
-- }
signs_lib = {}
signs_lib.modpath = minetest.get_modpath("signs_lib")
signs_lib.intllib_modpath = minetest.get_modpath("intllib")
signs_lib.wall_sign_model = {
nodebox = {
@ -30,10 +36,10 @@ signs_lib.yard_sign_model = {
}
},
textpos = {
{delta = {x = 0, y = 0.07, z = -0.063}, yaw = 0},
{delta = {x = -0.063, y = 0.07, z = 0 }, yaw = math.pi / -2},
{delta = {x = 0, y = 0.07, z = 0.063}, yaw = math.pi},
{delta = {x = 0.063, y = 0.07, z = 0 }, yaw = math.pi / 2},
{delta = {x = 0, y = 0.07, z = -0.068}, yaw = 0},
{delta = {x = -0.068, y = 0.07, z = 0 }, yaw = math.pi / -2},
{delta = {x = 0, y = 0.07, z = 0.068}, yaw = math.pi},
{delta = {x = 0.068, y = 0.07, z = 0 }, yaw = math.pi / 2},
}
}
@ -70,12 +76,7 @@ signs_lib.sign_post_model = {
}
-- Boilerplate to support localized strings if intllib mod is installed.
local S
if minetest.get_modpath("intllib") then
S = intllib.Getter()
else
S = function(s) return s end
end
local S = rawget(_G, "intllib") and intllib.Getter() or function(s) return s end
signs_lib.gettext = S
-- the list of standard sign nodes

View File

@ -28,13 +28,11 @@ mesecon.on_placenode = function (pos, node)
-- Effectors: Send changesignal and activate or deactivate
if mesecon.is_effector(node.name) then
local powered_rules = {}
local unpowered_rules = {}
-- for each input rule, check if powered
for _, r in ipairs(mesecon.effector_get_rules(node)) do
local powered = mesecon.is_powered(pos, r)
if powered then table.insert(powered_rules, r)
else table.insert(unpowered_rules, r) end
if powered then table.insert(powered_rules, r) end
local state = powered and mesecon.state.on or mesecon.state.off
mesecon.changesignal(pos, node, r, state, 1)
@ -44,10 +42,6 @@ mesecon.on_placenode = function (pos, node)
for _, r in ipairs(powered_rules) do
mesecon.activate(pos, node, r, 1)
end
else
for _, r in ipairs(unpowered_rules) do
mesecon.deactivate(pos, node, r, 1)
end
end
end
end

View File

@ -1,191 +0,0 @@
doors = {}
-- Registers a door - REDEFINITION ONLY | DOORS MOD MUST HAVE BEEN LOADED BEFORE
-- name: The name of the door
-- def: a table with the folowing fields:
-- description
-- inventory_image
-- groups
-- tiles_bottom: the tiles of the bottom part of the door {front, side}
-- tiles_top: the tiles of the bottom part of the door {front, side}
-- If the following fields are not defined the default values are used
-- node_box_bottom
-- node_box_top
-- selection_box_bottom
-- selection_box_top
-- only_placer_can_open: if true only the player who placed the door can
-- open it
local function is_right(pos)
local r1 = minetest.get_node({x=pos.x-1, y=pos.y, z=pos.z})
local r2 = minetest.get_node({x=pos.x, y=pos.y, z=pos.z-1})
if string.find(r1.name, "door_") or string.find(r2.name, "door_") then
if string.find(r1.name, "_1") or string.find(r2.name, "_1") then
return true
else
return false
end
end
end
function doors:register_door(name, def)
def.groups.not_in_creative_inventory = 1
local box = {{-0.5, -0.5, -0.5, 0.5, 0.5, -0.5+1.5/16}}
if not def.node_box_bottom then
def.node_box_bottom = box
end
if not def.node_box_top then
def.node_box_top = box
end
if not def.selection_box_bottom then
def.selection_box_bottom= box
end
if not def.selection_box_top then
def.selection_box_top = box
end
local tt = def.tiles_top
local tb = def.tiles_bottom
local function after_dig_node(pos, name)
if minetest.get_node(pos).name == name then
minetest.remove_node(pos)
end
end
local function on_rightclick(pos, dir, check_name, replace, replace_dir, params)
pos.y = pos.y+dir
if not minetest.get_node(pos).name == check_name then
return
end
local p2 = minetest.get_node(pos).param2
p2 = params[p2+1]
local meta = minetest.get_meta(pos):to_table()
minetest.set_node(pos, {name=replace_dir, param2=p2})
minetest.get_meta(pos):from_table(meta)
pos.y = pos.y-dir
meta = minetest.get_meta(pos):to_table()
minetest.set_node(pos, {name=replace, param2=p2})
minetest.get_meta(pos):from_table(meta)
local snd_1 = "_close"
local snd_2 = "_open"
if params[1] == 3 then
snd_1 = "_open"
snd_2 = "_close"
end
if is_right(pos) then
minetest.sound_play("door"..snd_1, {pos = pos, gain = 0.3, max_hear_distance = 10})
else
minetest.sound_play("door"..snd_2, {pos = pos, gain = 0.3, max_hear_distance = 10})
end
end
local function on_mesecons_signal_open (pos, node)
on_rightclick(pos, 1, name.."_t_1", name.."_b_2", name.."_t_2", {1,2,3,0})
end
local function on_mesecons_signal_close (pos, node)
on_rightclick(pos, 1, name.."_t_2", name.."_b_1", name.."_t_1", {3,0,1,2})
end
local function check_player_priv(pos, player)
if not def.only_placer_can_open then
return true
end
local meta = minetest.get_meta(pos)
local pn = player:get_player_name()
return meta:get_string("doors_owner") == pn
end
minetest.register_node(":"..name.."_b_1", {
tiles = {tb[2], tb[2], tb[2], tb[2], tb[1], tb[1].."^[transformfx"},
paramtype = "light",
paramtype2 = "facedir",
drop = name,
drawtype = "nodebox",
node_box = {
type = "fixed",
fixed = def.node_box_bottom
},
selection_box = {
type = "fixed",
fixed = def.selection_box_bottom
},
groups = def.groups,
after_dig_node = function(pos, oldnode, oldmetadata, digger)
pos.y = pos.y+1
after_dig_node(pos, name.."_t_1")
end,
on_rightclick = function(pos, node, puncher)
if check_player_priv(pos, puncher) then
on_rightclick(pos, 1, name.."_t_1", name.."_b_2", name.."_t_2", {1,2,3,0})
end
end,
mesecons = {effector = {
action_on = on_mesecons_signal_open
}},
can_dig = check_player_priv,
})
minetest.register_node(":"..name.."_b_2", {
tiles = {tb[2], tb[2], tb[2], tb[2], tb[1].."^[transformfx", tb[1]},
paramtype = "light",
paramtype2 = "facedir",
drop = name,
drawtype = "nodebox",
node_box = {
type = "fixed",
fixed = def.node_box_bottom
},
selection_box = {
type = "fixed",
fixed = def.selection_box_bottom
},
groups = def.groups,
after_dig_node = function(pos, oldnode, oldmetadata, digger)
pos.y = pos.y+1
after_dig_node(pos, name.."_t_2")
end,
on_rightclick = function(pos, node, puncher)
if check_player_priv(pos, puncher) then
on_rightclick(pos, 1, name.."_t_2", name.."_b_1", name.."_t_1", {3,0,1,2})
end
end,
mesecons = {effector = {
action_off = on_mesecons_signal_close
}},
can_dig = check_player_priv,
})
end
doors:register_door("doors:door_wood", {
description = "Wooden Door",
inventory_image = "door_wood.png",
groups = {snappy=1,choppy=2,oddly_breakable_by_hand=2,flammable=2,door=1},
tiles_bottom = {"door_wood_b.png", "door_brown.png"},
tiles_top = {"door_wood_a.png", "door_brown.png"},
sounds = default.node_sound_wood_defaults(),
})
doors:register_door("doors:door_steel", {
description = "Steel Door",
inventory_image = "door_steel.png",
groups = {snappy=1,bendy=2,cracky=1,melty=2,level=2,door=1},
tiles_bottom = {"door_steel_b.png", "door_grey.png"},
tiles_top = {"door_steel_a.png", "door_grey.png"},
only_placer_can_open = true,
sounds = default.node_sound_stone_defaults(),
})

View File

@ -0,0 +1,80 @@
-- Modified, from minetest_game/mods/doors/init.lua
local function on_rightclick(pos, dir, check_name, replace, replace_dir, params)
pos.y = pos.y + dir
if not minetest.get_node(pos).name == check_name then
return
end
local p2 = minetest.get_node(pos).param2
p2 = params[p2 + 1]
minetest.swap_node(pos, {name = replace_dir, param2 = p2})
pos.y = pos.y - dir
minetest.swap_node(pos, {name = replace, param2 = p2})
if (minetest.get_meta(pos):get_int("right") ~= 0) == (params[1] ~= 3) then
minetest.sound_play("door_close", {pos = pos, gain = 0.3, max_hear_distance = 10})
else
minetest.sound_play("door_open", {pos = pos, gain = 0.3, max_hear_distance = 10})
end
end
local function meseconify_door(name)
local function toggle_state1 (pos, node)
on_rightclick(pos, 1, name.."_t_1", name.."_b_2", name.."_t_2", {1,2,3,0})
end
local function toggle_state2 (pos, node)
on_rightclick(pos, 1, name.."_t_2", name.."_b_1", name.."_t_1", {3,0,1,2})
end
minetest.override_item(name.."_b_1", {
mesecons = {effector = {
action_on = toggle_state1,
action_off = toggle_state1,
rules = mesecon.rules.pplate
}},
})
minetest.override_item(name.."_b_2", {
mesecons = {effector = {
action_on = toggle_state2,
action_off = toggle_state2,
rules = mesecon.rules.pplate
}},
})
end
meseconify_door("doors:door_wood")
meseconify_door("doors:door_steel")
meseconify_door("doors:door_glass")
meseconify_door("doors:door_obsidian_glass")
-- Trapdoor
local function trapdoor_switch(pos, node)
local state = minetest.get_meta(pos):get_int("state")
if state == 1 then
minetest.sound_play("doors_door_close", {pos = pos, gain = 0.3, max_hear_distance = 10})
minetest.set_node(pos, {name="doors:trapdoor", param2 = node.param2})
else
minetest.sound_play("doors_door_open", {pos = pos, gain = 0.3, max_hear_distance = 10})
minetest.set_node(pos, {name="doors:trapdoor_open", param2 = node.param2})
end
minetest.get_meta(pos):set_int("state", state == 1 and 0 or 1)
end
minetest.override_item("doors:trapdoor", {
mesecons = {effector = {
action_on = trapdoor_switch,
action_off = trapdoor_switch
}},
})
minetest.override_item("doors:trapdoor_open", {
mesecons = {effector = {
action_on = trapdoor_switch,
action_off = trapdoor_switch
}},
})

View File

@ -4,24 +4,17 @@
-- (does not work with other liquids)
minetest.register_node("mesecons_hydroturbine:hydro_turbine_off", {
drawtype = "nodebox",
drawtype = "mesh",
mesh = "jeija_hydro_turbine.obj",
tiles = {"jeija_hydro_turbine_off.png"},
inventory_image = "jeija_hydro_turbine_inv.png",
wield_scale = {x=0.75, y=0.75, z=0.75},
groups = {dig_immediate=2},
description="Water Turbine",
paramtype = "light",
selection_box = {
type = "fixed",
fixed = {{-0.5, -0.5, -0.5, 0.5, 0.5, 0.5},
{-0.15, 0.5, -0.15, 0.15, 1.45, 0.15},
{-0.45, 1.15, -0.1, 0.45, 1.45, 0.1},
{-0.1, 1.15, -0.45, 0.1, 1.45, 0.45}},
},
node_box = {
type = "fixed",
fixed = {{-0.5, -0.5, -0.5, 0.5, 0.5, 0.5},
{-0.15, 0.5, -0.15, 0.15, 1.45, 0.15},
{-0.45, 1.15, -0.1, 0.45, 1.45, 0.1},
{-0.1, 1.15, -0.45, 0.1, 1.45, 0.45}},
fixed = { -0.5, -0.5, -0.5, 0.5, 1.5, 0.5 },
},
sounds = default.node_sound_stone_defaults(),
mesecons = {receptor = {
@ -30,25 +23,18 @@ minetest.register_node("mesecons_hydroturbine:hydro_turbine_off", {
})
minetest.register_node("mesecons_hydroturbine:hydro_turbine_on", {
drawtype = "nodebox",
drawtype = "mesh",
mesh = "jeija_hydro_turbine.obj",
wield_scale = {x=0.75, y=0.75, z=0.75},
tiles = {"jeija_hydro_turbine_on.png"},
inventory_image = "jeija_hydro_turbine_inv.png",
drop = "mesecons_hydroturbine:hydro_turbine_off 1",
groups = {dig_immediate=2,not_in_creative_inventory=1},
description="Water Turbine",
paramtype = "light",
selection_box = {
type = "fixed",
fixed = {{-0.5, -0.5, -0.5, 0.5, 0.5, 0.5},
{-0.15, 0.5, -0.15, 0.15, 1.45, 0.15},
{-0.5, 1.15, -0.1, 0.5, 1.45, 0.1},
{-0.1, 1.15, -0.5, 0.1, 1.45, 0.5}},
},
node_box = {
type = "fixed",
fixed = {{-0.5, -0.5, -0.5, 0.5, 0.5, 0.5},
{-0.15, 0.5, -0.15, 0.15, 1.45, 0.15},
{-0.5, 1.15, -0.1, 0.5, 1.45, 0.1},
{-0.1, 1.15, -0.5, 0.1, 1.45, 0.5}},
fixed = { -0.5, -0.5, -0.5, 0.5, 1.5, 0.5 },
},
sounds = default.node_sound_stone_defaults(),
mesecons = {receptor = {

View File

@ -0,0 +1,416 @@
# Blender v2.69 (sub 0) OBJ File: 'mesecons-water-turbine.blend'
# www.blender.org
o Cylinder.002_Cylinder.003
v 0.000000 0.500000 -0.150000
v 0.000000 0.562500 -0.150000
v 0.106066 0.500000 -0.106066
v 0.106066 0.562500 -0.106066
v 0.150000 0.500000 0.000000
v 0.150000 0.562500 0.000000
v 0.106066 0.500000 0.106066
v 0.106066 0.562500 0.106066
v -0.000000 0.500000 0.150000
v -0.000000 0.562500 0.150000
v -0.106066 0.500000 0.106066
v -0.106066 0.562500 0.106066
v -0.150000 0.500000 -0.000000
v -0.150000 0.562500 -0.000000
v -0.106066 0.500000 -0.106066
v -0.106066 0.562500 -0.106066
v 0.097545 0.625000 -0.490393
v -0.097545 0.625000 -0.490393
v -0.277785 0.625000 -0.415735
v -0.415735 0.625000 -0.277785
v -0.490393 0.625000 -0.097545
v -0.490393 0.625000 0.097545
v -0.415735 0.625000 0.277785
v -0.277785 0.625000 0.415735
v -0.097545 0.625000 0.490393
v 0.097545 0.625000 0.490393
v 0.277785 0.625000 0.415735
v 0.415735 0.625000 0.277785
v 0.490393 0.625000 0.097545
v 0.490393 0.625000 -0.097545
v 0.415735 0.625000 -0.277785
v 0.277785 0.625000 -0.415735
v 0.097545 0.656250 -0.490393
v -0.097545 0.656250 -0.490393
v -0.277785 0.656250 -0.415735
v -0.415735 0.656250 -0.277785
v -0.490393 0.656250 -0.097545
v -0.490393 0.656250 0.097545
v -0.415735 0.656250 0.277785
v -0.277785 0.656250 0.415735
v -0.097545 0.656250 0.490393
v 0.097545 0.656250 0.490393
v 0.277785 0.656250 0.415735
v 0.415735 0.656250 0.277785
v 0.490393 0.656250 0.097545
v 0.490393 0.656250 -0.097545
v 0.415735 0.656250 -0.277785
v 0.277785 0.656250 -0.415735
v 0.116233 0.634645 -0.436100
v 0.116233 1.482640 -0.436100
v 0.299524 0.634645 -0.186124
v 0.299524 1.482640 -0.186124
v 0.343405 0.634645 0.080186
v 0.343405 1.482640 0.080186
v 0.186124 0.634645 0.299524
v 0.186124 1.482640 0.299524
v -0.080186 0.634645 0.343405
v -0.080186 1.482640 0.343405
v -0.299524 0.634645 0.186124
v -0.299524 1.482640 0.186124
v -0.343405 0.634645 -0.080186
v -0.343405 1.482640 -0.080186
v -0.186124 0.634645 -0.299524
v -0.186124 1.482640 -0.299524
v 0.080186 0.634645 -0.343405
v 0.080186 1.482640 -0.343405
v 0.390559 1.482640 -0.226180
v 0.390559 0.634645 -0.226180
v 0.436100 1.482640 0.116233
v 0.436100 0.634645 0.116233
v 0.226180 1.482640 0.390559
v 0.226180 0.634645 0.390559
v -0.116233 1.482640 0.436100
v -0.116233 0.634645 0.436100
v -0.390559 1.482640 0.226180
v -0.390559 0.634645 0.226180
v -0.436100 1.482640 -0.116233
v -0.436100 0.634645 -0.116233
v -0.226180 1.482640 -0.390559
v -0.226180 0.634645 -0.390559
v 0.108975 0.634645 -0.430778
v 0.292266 0.634645 -0.180802
v 0.292266 1.482640 -0.180802
v 0.108975 1.482640 -0.430778
v 0.381664 0.634645 -0.227549
v 0.334509 0.634645 0.078817
v 0.334509 1.482640 0.078817
v 0.381664 1.482640 -0.227549
v 0.430778 0.634645 0.108975
v 0.180802 0.634645 0.292266
v 0.180802 1.482640 0.292266
v 0.430778 1.482640 0.108975
v 0.227549 0.634645 0.381664
v -0.078817 0.634645 0.334509
v -0.078817 1.482640 0.334509
v 0.227549 1.482640 0.381664
v -0.108975 0.634645 0.430778
v -0.292266 0.634645 0.180802
v -0.292266 1.482640 0.180802
v -0.108975 1.482640 0.430778
v -0.381664 0.634645 0.227549
v -0.334509 0.634645 -0.078817
v -0.334509 1.482640 -0.078817
v -0.381664 1.482640 0.227549
v -0.227549 0.634645 -0.381663
v 0.078817 0.634645 -0.334509
v 0.078817 1.482640 -0.334509
v -0.227549 1.482640 -0.381663
v -0.430779 0.634645 -0.108975
v -0.180802 0.634645 -0.292266
v -0.180802 1.482640 -0.292266
v -0.430779 1.482640 -0.108975
v 0.097545 1.500000 -0.490393
v -0.097545 1.500000 -0.490393
v -0.277785 1.500000 -0.415735
v -0.415735 1.500000 -0.277785
v -0.490393 1.500000 -0.097545
v -0.490393 1.500000 0.097545
v -0.415735 1.500000 0.277785
v -0.277785 1.500000 0.415735
v -0.097545 1.500000 0.490393
v 0.097545 1.500000 0.490393
v 0.277785 1.500000 0.415735
v 0.415735 1.500000 0.277785
v 0.490393 1.500000 0.097545
v 0.490393 1.500000 -0.097545
v 0.415735 1.500000 -0.277785
v 0.277785 1.500000 -0.415735
v 0.097545 1.468750 -0.490393
v -0.097545 1.468750 -0.490393
v -0.277785 1.468750 -0.415735
v -0.415735 1.468750 -0.277785
v -0.490393 1.468750 -0.097545
v -0.490393 1.468750 0.097545
v -0.415735 1.468750 0.277785
v -0.277785 1.468750 0.415735
v -0.097545 1.468750 0.490393
v 0.097545 1.468750 0.490393
v 0.277785 1.468750 0.415735
v 0.415735 1.468750 0.277785
v 0.490393 1.468750 0.097545
v 0.490393 1.468750 -0.097545
v 0.415735 1.468750 -0.277785
v 0.277785 1.468750 -0.415735
v 0.025624 0.559630 -0.061863
v 0.025624 1.481372 -0.061863
v 0.061863 0.559630 -0.025624
v 0.061863 1.481372 -0.025624
v 0.061863 0.559630 0.025624
v 0.061863 1.481372 0.025624
v 0.025624 0.559630 0.061863
v 0.025624 1.481372 0.061863
v -0.025624 0.559630 0.061863
v -0.025624 1.481372 0.061863
v -0.061863 0.559630 0.025624
v -0.061863 1.481372 0.025624
v -0.061863 0.559630 -0.025624
v -0.061863 1.481372 -0.025624
v -0.025624 0.559630 -0.061863
v -0.025624 1.481372 -0.061863
v 0.500000 -0.500000 -0.500000
v 0.500000 -0.500000 0.500000
v -0.500000 -0.500000 0.500000
v -0.500000 -0.500000 -0.500000
v 0.500000 0.500000 -0.500000
v 0.500000 0.500000 0.500000
v -0.500000 0.500000 0.500000
v -0.500000 0.500000 -0.500000
vt 0.416667 0.625000
vt 0.416667 0.645833
vt 0.395833 0.645833
vt 0.395833 0.625000
vt 0.375000 0.645833
vt 0.375000 0.625000
vt 0.291667 0.625000
vt 0.291667 0.645833
vt 0.312500 0.645833
vt 0.312500 0.625000
vt 0.333333 0.645833
vt 0.333333 0.625000
vt 0.354167 0.645833
vt 0.354167 0.625000
vt 0.708333 0.645833
vt 0.729167 0.625000
vt 0.750000 0.625000
vt 0.770833 0.645833
vt 0.770833 0.666667
vt 0.750000 0.687500
vt 0.729167 0.687500
vt 0.708333 0.666667
vt 0.437500 0.625000
vt 0.437500 0.645833
vt 0.458333 0.625000
vt 0.458333 0.645833
vt 0.656250 0.953125
vt 0.593750 0.980469
vt 0.531250 0.980469
vt 0.468750 0.953125
vt 0.421875 0.906250
vt 0.394531 0.843750
vt 0.394531 0.781250
vt 0.421875 0.718750
vt 0.468750 0.671875
vt 0.531250 0.644531
vt 0.593750 0.644531
vt 0.656250 0.671875
vt 0.703125 0.718750
vt 0.730469 0.781250
vt 0.730469 0.843750
vt 0.703125 0.906250
vt 0.019531 0.843750
vt 0.019531 0.781250
vt 0.046875 0.718750
vt 0.093750 0.671875
vt 0.156250 0.644531
vt 0.218750 0.644531
vt 0.281250 0.671875
vt 0.328125 0.718750
vt 0.355469 0.781250
vt 0.355469 0.843750
vt 0.328125 0.906250
vt 0.281250 0.953125
vt 0.218750 0.980469
vt 0.156250 0.980469
vt 0.093750 0.953125
vt 0.046875 0.906250
vt 0.187500 0.041667
vt 0.104167 0.041667
vt 0.104167 0.020833
vt 0.187500 0.020833
vt 0.270833 0.041667
vt 0.270833 0.020833
vt 0.354167 0.041667
vt 0.354167 0.020833
vt 0.437500 0.041667
vt 0.437500 0.020833
vt 0.520833 0.041667
vt 0.520833 0.020833
vt 0.354167 0.104167
vt 0.270833 0.104167
vt 0.270833 0.083333
vt 0.354167 0.083333
vt 0.604167 0.041667
vt 0.604167 0.020833
vt 0.687500 0.041667
vt 0.687500 0.020833
vt 0.437500 0.104167
vt 0.437500 0.083333
vt 0.104167 0.104167
vt 0.020833 0.104167
vt 0.020833 0.083333
vt 0.104167 0.083333
vt 0.520833 0.104167
vt 0.520833 0.083333
vt 0.187500 0.104167
vt 0.187500 0.083333
vt 0.604167 0.104167
vt 0.604167 0.083333
vt 0.687500 0.104167
vt 0.687500 0.083333
vt 0.020833 0.041667
vt 0.020833 0.020833
vt 0.979167 0.020833
vt 0.979167 0.270833
vt 0.895833 0.270833
vt 0.895833 0.020833
vt 0.875000 0.020833
vt 0.875000 0.270833
vt 0.791667 0.270833
vt 0.791667 0.020833
vt 0.687500 0.208333
vt 0.687500 0.229167
vt 0.604167 0.229167
vt 0.604167 0.208333
vt 0.104167 0.145833
vt 0.104167 0.166667
vt 0.020833 0.166667
vt 0.020833 0.145833
vt 0.187500 0.145833
vt 0.187500 0.166667
vt 0.270833 0.145833
vt 0.270833 0.166667
vt 0.354167 0.145833
vt 0.354167 0.166667
vt 0.187500 0.208333
vt 0.187500 0.229167
vt 0.104167 0.229167
vt 0.104167 0.208333
vt 0.437500 0.145833
vt 0.437500 0.166667
vt 0.520833 0.145833
vt 0.520833 0.166667
vt 0.270833 0.208333
vt 0.270833 0.229167
vt 0.604167 0.145833
vt 0.604167 0.166667
vt 0.354167 0.208333
vt 0.354167 0.229167
vt 0.687500 0.145833
vt 0.687500 0.166667
vt 0.437500 0.208333
vt 0.437500 0.229167
vt 0.020833 0.229167
vt 0.020833 0.208333
vt 0.520833 0.208333
vt 0.520833 0.229167
vt 0.854167 0.645833
vt 0.854167 0.979167
vt 0.812500 0.979167
vt 0.812500 0.645833
vt 0.979167 0.312500
vt 0.979167 0.645833
vt 0.937500 0.645833
vt 0.937500 0.312500
vt 0.895833 0.645833
vt 0.895833 0.312500
vt 0.854167 0.312500
vt 0.812500 0.312500
vt 0.979167 0.979167
vt 0.937500 0.979167
vt 0.895833 0.979167
vt 0.020833 0.604167
vt 0.020833 0.270833
vt 0.354167 0.270833
vt 0.354167 0.604167
vt 0.729167 0.270833
vt 0.729167 0.604167
vt 0.395833 0.604167
vt 0.395833 0.270833
s off
f 1/1 2/2 4/3 3/4
f 3/4 4/3 6/5 5/6
f 5/7 6/8 8/9 7/10
f 7/10 8/9 10/11 9/12
f 9/12 10/11 12/13 11/14
f 11/14 12/13 14/5 13/6
f 4/15 2/16 16/17 14/18 12/19 10/20 8/21 6/22
f 15/23 16/24 2/2 1/1
f 13/25 14/26 16/24 15/23
f 130/27 129/28 144/29 143/30 142/31 141/32 140/33 139/34 138/35 137/36 136/37 135/38 134/39 133/40 132/41 131/42
f 18/43 17/44 32/45 31/46 30/47 29/48 28/49 27/50 26/51 25/52 24/53 23/54 22/55 21/56 20/57 19/58
f 27/59 28/60 44/61 43/62
f 26/63 27/59 43/62 42/64
f 25/65 26/63 42/64 41/66
f 24/67 25/65 41/66 40/68
f 23/69 24/67 40/68 39/70
f 17/71 18/72 34/73 33/74
f 22/75 23/69 39/70 38/76
f 21/77 22/75 38/76 37/78
f 32/79 17/71 33/74 48/80
f 20/81 21/82 37/83 36/84
f 31/85 32/79 48/80 47/86
f 19/87 20/81 36/84 35/88
f 30/89 31/85 47/86 46/90
f 18/72 19/87 35/88 34/73
f 29/91 30/89 46/90 45/92
f 28/60 29/93 45/94 44/61
f 49/95 50/96 52/97 51/98
f 68/98 67/95 54/96 53/97
f 70/95 69/96 56/97 55/98
f 72/96 71/97 58/98 57/95
f 74/95 73/96 60/97 59/98
f 76/95 75/96 62/97 61/98
f 80/96 79/97 66/98 65/95
f 78/95 77/96 64/97 63/98
f 81/99 82/100 83/101 84/102
f 85/100 86/101 87/102 88/99
f 89/101 90/102 91/99 92/100
f 93/102 94/99 95/100 96/101
f 97/102 98/99 99/100 100/101
f 101/99 102/100 103/101 104/102
f 105/102 106/99 107/100 108/101
f 109/101 110/102 111/99 112/100
f 75/100 76/99 101/98 104/97
f 71/100 72/99 93/98 96/97
f 67/98 68/97 85/100 88/99
f 79/98 80/97 105/100 108/99
f 77/100 78/99 109/98 112/97
f 73/100 74/99 97/98 100/97
f 69/98 70/97 89/100 92/99
f 50/98 49/97 81/100 84/99
f 33/51 34/52 35/53 36/54 37/55 38/56 39/57 40/58 41/43 42/44 43/45 44/46 45/47 46/48 47/49 48/50
f 123/103 139/104 140/105 124/106
f 122/107 138/108 139/109 123/110
f 121/111 137/112 138/108 122/107
f 120/113 136/114 137/112 121/111
f 119/115 135/116 136/114 120/113
f 113/117 129/118 130/119 114/120
f 118/121 134/122 135/116 119/115
f 117/123 133/124 134/122 118/121
f 128/125 144/126 129/118 113/117
f 116/127 132/128 133/124 117/123
f 127/129 143/130 144/126 128/125
f 115/131 131/132 132/128 116/127
f 126/133 142/134 143/130 127/129
f 114/120 130/119 131/135 115/136
f 125/137 141/138 142/134 126/133
f 124/106 140/105 141/138 125/137
f 145/139 146/140 148/141 147/142
f 147/143 148/144 150/145 149/146
f 149/146 150/145 152/147 151/148
f 151/148 152/147 154/139 153/149
f 153/149 154/139 156/142 155/150
f 155/144 156/151 158/152 157/145
f 159/147 160/153 146/140 145/139
f 157/145 158/152 160/153 159/147
f 161/154 162/155 163/156 164/157
f 165/155 168/156 167/157 166/154
f 161/158 165/159 166/160 162/161
f 162/158 166/159 167/160 163/161
f 163/158 167/159 168/160 164/161
f 165/160 161/161 164/158 168/159
f 113/40 114/41 115/42 116/27 117/28 118/29 119/30 120/31 121/32 122/33 123/34 124/35 125/36 126/37 127/38 128/39

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.8 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 835 B

After

Width:  |  Height:  |  Size: 2.9 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 817 B

After

Width:  |  Height:  |  Size: 2.9 KiB

View File

@ -1 +1,2 @@
mesecons
dye

View File

@ -52,9 +52,9 @@ function mesecon.lightstone_add(name, base_item, texture_off, texture_on)
end
mesecon.lightstone_add("red", "default:clay_brick", "jeija_lightstone_red_off.png", "jeija_lightstone_red_on.png")
mesecon.lightstone_add("green", "default:cactus", "jeija_lightstone_green_off.png", "jeija_lightstone_green_on.png")
mesecon.lightstone_add("blue", "mesecons_materials:fiber", "jeija_lightstone_blue_off.png", "jeija_lightstone_blue_on.png")
mesecon.lightstone_add("gray", "default:cobble", "jeija_lightstone_gray_off.png", "jeija_lightstone_gray_on.png")
mesecon.lightstone_add("darkgray", "default:gravel", "jeija_lightstone_darkgray_off.png", "jeija_lightstone_darkgray_on.png")
mesecon.lightstone_add("yellow", "default:mese_crystal_fragment", "jeija_lightstone_yellow_off.png", "jeija_lightstone_yellow_on.png")
mesecon.lightstone_add("red", "dye:red", "jeija_lightstone_red_off.png", "jeija_lightstone_red_on.png")
mesecon.lightstone_add("green", "dye:green", "jeija_lightstone_green_off.png", "jeija_lightstone_green_on.png")
mesecon.lightstone_add("blue", "dye:blue", "jeija_lightstone_blue_off.png", "jeija_lightstone_blue_on.png")
mesecon.lightstone_add("gray", "dye:grey", "jeija_lightstone_gray_off.png", "jeija_lightstone_gray_on.png")
mesecon.lightstone_add("darkgray", "dye:dark_grey", "jeija_lightstone_darkgray_off.png", "jeija_lightstone_darkgray_on.png")
mesecon.lightstone_add("yellow", "dye:yellow", "jeija_lightstone_yellow_off.png", "jeija_lightstone_yellow_on.png")

View File

@ -232,4 +232,6 @@ function mesecon.mvps_move_objects(pos, dir, nodestack)
end
mesecon.register_mvps_stopper("default:chest_locked")
mesecon.register_mvps_stopper("default:chest")
mesecon.register_mvps_stopper("default:bookshelf")
mesecon.register_mvps_stopper("default:furnace")

View File

@ -61,9 +61,15 @@ mesecon.noteblock_play = function (pos, param2)
if block_below_name == "default:glass" then
soundname="mesecons_noteblock_hihat"
end
if block_below_name == "default:steelblock" then
soundname=soundname.."2" -- Go up an octave.
end
if block_below_name == "default:stone" then
soundname="mesecons_noteblock_kick"
end
if block_below_name == "default:lava_source" then
soundname="fire_large"
end
if block_below_name == "default:chest" then
soundname="mesecons_noteblock_snare"
end
@ -73,6 +79,9 @@ mesecon.noteblock_play = function (pos, param2)
if block_below_name == "default:wood" then
soundname="mesecons_noteblock_litecrash"
end
if block_below_name == "default:coalblock" then
soundname="tnt_explode"
end
minetest.sound_play(soundname,
{pos = pos, gain = 1.0, max_hear_distance = 32,})
end

View File

@ -3,9 +3,9 @@
-- Powers the block 2 nodes behind (using a receiver)
mesecon.register_node("mesecons_walllever:wall_lever", {
description="Lever",
drawtype = "nodebox",
inventory_image = "jeija_wall_lever_off.png",
wield_image = "jeija_wall_lever_off.png",
drawtype = "mesh",
inventory_image = "jeija_wall_lever_inv.png",
wield_image = "jeija_wall_lever_inv.png",
paramtype = "light",
paramtype2 = "facedir",
sunlight_propagates = true,
@ -24,40 +24,16 @@ mesecon.register_node("mesecons_walllever:wall_lever", {
minetest.sound_play("mesecons_lever", {pos=pos})
end
},{
tiles = { "jeija_wall_lever_tb.png", "jeija_wall_lever_bottom.png",
"jeija_wall_lever_sides.png", "jeija_wall_lever_sides.png",
"jeija_wall_lever_back.png", "jeija_wall_lever_off.png",
},
node_box = {
type = "fixed",
fixed = {{ -6/16, -6/16, 6/16, 6/16, 6/16, 8/16 }, -- the base "slab"
{ -5/16, -3/16, 5/16, 5/16, 3/16, 6/16 }, -- the lighted ring area
{ -4/16, -2/16, 4/16, 4/16, 2/16, 5/16 }, -- the raised bit
{ -2/16, -1/16, 3/16, 2/16, 1/16, 4/16 }, -- the lever "hinge"
{ -1/16, -8/16, 4/16, 1/16, 0, 6/16 }} -- the lever itself.
},
tiles = { "jeija_wall_lever_off.png" },
mesh="jeija_wall_lever_off.obj",
mesecons = {receptor = {
rules = mesecon.rules.buttonlike_get,
state = mesecon.state.off
}},
groups = {dig_immediate = 2, mesecon_needs_receiver = 1}
},{
tiles = {
"jeija_wall_lever_top.png",
"jeija_wall_lever_tb.png",
"jeija_wall_lever_sides.png",
"jeija_wall_lever_sides.png",
"jeija_wall_lever_back.png",
"jeija_wall_lever_on.png",
},
node_box = {
type = "fixed",
fixed = {{ -6/16, -6/16, 6/16, 6/16, 6/16, 8/16 }, -- the base "slab"
{ -5/16, -3/16, 5/16, 5/16, 3/16, 6/16 }, -- the lighted ring area
{ -4/16, -2/16, 4/16, 4/16, 2/16, 5/16 }, -- the raised bit
{ -2/16, -1/16, 3/16, 2/16, 1/16, 4/16 }, -- the lever "hinge"
{ -1/16, 0, 4/16, 1/16, 8/16, 6/16 }} -- the lever itself.
},
tiles = { "jeija_wall_lever_on.png" },
mesh="jeija_wall_lever_on.obj",
mesecons = {receptor = {
rules = mesecon.rules.buttonlike_get,
state = mesecon.state.on

View File

@ -0,0 +1,263 @@
# Blender v2.73 (sub 0) OBJ File: 'mesecons-wall-lever-off.blend'
# www.blender.org
o nodebox-5
v 0.289062 0.156250 0.312500
v -0.375000 0.375000 0.375000
v -0.375000 -0.375000 0.375000
v 0.332500 0.207500 0.375000
v 0.332500 -0.207500 0.375000
v 0.375000 0.375000 0.375000
v 0.375000 -0.375000 0.375000
v 0.289062 -0.156250 0.312500
v -0.062500 -0.036146 0.200392
v -0.062500 -0.068498 0.321133
v -0.062500 -0.394498 0.233782
v -0.062500 -0.362146 0.113041
v -0.332500 0.207500 0.375000
v 0.062500 -0.036146 0.200392
v 0.062500 -0.068498 0.321133
v -0.332500 -0.207500 0.375000
v 0.332500 0.207500 0.375000
v 0.062500 -0.394498 0.233782
v 0.062500 -0.362146 0.113041
v 0.332500 -0.207500 0.375000
v 0.375000 -0.375000 0.375000
v 0.375000 -0.375000 0.500000
v 0.375000 0.375000 0.500000
v 0.375000 0.375000 0.375000
v -0.375000 -0.375000 0.375000
v -0.375000 -0.375000 0.500000
v -0.375000 0.375000 0.500000
v -0.375000 0.375000 0.375000
v -0.289062 0.156250 0.312500
v -0.332500 0.207500 0.375000
v -0.332500 -0.207500 0.375000
v -0.289062 -0.156250 0.312500
v -0.250000 0.125000 0.312500
v -0.250000 -0.125000 0.312500
v 0.250000 0.125000 0.312500
v 0.250000 -0.125000 0.312500
v -0.250000 -0.000000 0.250000
v -0.000000 -0.125000 0.250000
v 0.250000 -0.000000 0.250000
v 0.000000 0.125000 0.250000
v -0.250000 0.125000 0.250000
v -0.250000 0.125000 0.312500
v -0.250000 -0.125000 0.312500
v -0.250000 -0.125000 0.250000
v 0.250000 0.125000 0.250000
v 0.250000 0.125000 0.312500
v 0.250000 -0.125000 0.312500
v 0.250000 -0.125000 0.250000
v 0.250000 -0.125000 0.250000
v 0.250000 0.125000 0.250000
v -0.250000 -0.125000 0.250000
v -0.250000 0.125000 0.250000
v 0.125000 -0.062500 0.187500
v 0.125000 0.062500 0.187500
v -0.125000 -0.062500 0.187500
v -0.125000 0.062500 0.187500
v 0.065000 -0.032500 0.176992
v 0.065000 0.032500 0.176992
v -0.065000 -0.032500 0.176992
v -0.065000 0.032500 0.176992
v 0.000000 0.125000 0.250000
v 0.250000 -0.000000 0.250000
v -0.000000 -0.125000 0.250000
v -0.250000 -0.000000 0.250000
v 0.000000 0.062500 0.187500
v -0.187500 -0.093750 0.208750
v 0.125000 -0.000000 0.187500
v 0.000000 -0.062500 0.187500
v -0.125000 -0.000000 0.187500
v 0.187500 0.093750 0.208750
v 0.187500 -0.093750 0.208750
v -0.187500 0.093750 0.208750
v 0.000000 0.093750 0.208750
v 0.000000 -0.093750 0.208750
v 0.187500 -0.000000 0.208750
v -0.187500 -0.000000 0.208750
vt 0.416667 0.416667
vt 0.083333 0.416667
vt 0.055556 0.472222
vt 0.444444 0.472222
vt 0.083333 0.083333
vt 0.055556 0.027778
vt 0.444444 0.027778
vt 0.416667 0.083333
vt 0.472222 0.055556
vt 0.472222 0.444444
vt 0.027778 0.055556
vt 0.027778 0.444444
vt 0.250000 0.833333
vt 0.250000 0.638889
vt 0.305556 0.638889
vt 0.305556 0.833333
vt 0.388889 0.777778
vt 0.333333 0.777778
vt 0.333333 0.722222
vt 0.388889 0.722222
vt 0.944444 0.527778
vt 0.944444 0.916667
vt 1.000000 0.916667
vt 1.000000 0.527778
vt 0.500000 0.527778
vt 0.555556 0.527778
vt 0.555556 0.916667
vt 0.500000 0.916667
vt 0.138889 0.833333
vt 0.194444 0.833333
vt 0.194444 0.638889
vt 0.138889 0.638889
vt 0.944444 0.472222
vt 0.555556 0.472222
vt 0.555556 0.972222
vt 0.944444 0.972222
vt 0.888802 0.166753
vt 0.555642 0.166753
vt 0.527778 0.138889
vt 0.916667 0.138889
vt 0.888802 0.388802
vt 0.916667 0.416667
vt 0.527778 0.416667
vt 0.555642 0.388802
vt 0.361111 0.361111
vt 0.250000 0.361111
vt 0.138889 0.361111
vt 0.138889 0.416667
vt 0.361111 0.416667
vt 0.361111 0.083333
vt 0.361111 0.138889
vt 0.138889 0.138889
vt 0.138889 0.083333
vt 0.250000 0.083333
vt 0.416667 0.361111
vt 0.416667 0.138889
vt 0.416667 0.250000
vt 0.138889 0.250000
vt 0.083333 0.138889
vt 0.083333 0.361111
vt 0.083333 0.638889
vt 0.083333 0.833333
vt 0.444444 0.611111
vt 0.055556 0.611111
vt 0.027778 0.527778
vt 0.472222 0.527778
vt 0.444444 0.888889
vt 0.472222 0.972222
vt 0.055556 0.888889
vt 0.027778 0.972222
vt 0.722222 0.361111
vt 0.583333 0.361111
vt 0.722222 0.388802
vt 0.833333 0.333333
vt 0.777778 0.305556
vt 0.777778 0.250000
vt 0.833333 0.222222
vt 0.833333 0.277778
vt 0.722222 0.194444
vt 0.722222 0.166753
vt 0.861111 0.194444
vt 0.583333 0.277778
vt 0.583333 0.194444
vt 0.555642 0.277778
vt 0.861111 0.277778
vt 0.888802 0.277778
vt 0.861111 0.361111
vt 0.666667 0.250000
vt 0.666667 0.305556
vt 0.611111 0.222222
vt 0.722222 0.222222
vt 0.611111 0.333333
vt 0.611111 0.277778
vt 0.722222 0.333333
vn 0.000000 0.773300 -0.634100
vn 0.000000 -0.773300 -0.634100
vn -0.821200 0.000000 -0.570700
vn 0.821200 0.000000 -0.570700
vn 0.000000 -0.258800 0.965900
vn 0.000000 -0.965900 -0.258800
vn 1.000000 0.000000 0.000000
vn -1.000000 0.000000 0.000000
vn 0.000000 0.258800 -0.965900
vn 0.000000 -0.000000 1.000000
vn 0.000000 -1.000000 0.000000
vn 0.000000 1.000000 0.000000
vn 0.000000 0.000000 -1.000000
vn 0.000000 0.688800 -0.724900
vn -0.269900 0.421500 -0.865700
vn -0.395600 0.336800 -0.854500
vn 0.000000 0.797100 -0.603900
vn -0.142400 0.274900 -0.950900
vn -0.056900 0.142700 -0.988100
vn -0.056900 -0.142700 -0.988100
vn -0.142400 -0.274900 -0.950900
vn -0.247900 0.000000 -0.968700
vn 0.000000 -0.688800 -0.724900
vn 0.000000 -0.797100 -0.603900
vn -0.395600 -0.336800 -0.854500
vn -0.269900 -0.421500 -0.865700
vn 0.440000 0.000000 -0.898000
vn 0.269900 0.421500 -0.865700
vn 0.395600 0.336800 -0.854500
vn 0.550800 0.000000 -0.834600
vn -0.440000 0.000000 -0.898000
vn -0.550800 0.000000 -0.834600
vn 0.056900 -0.142700 -0.988100
vn 0.056900 0.142700 -0.988100
vn 0.142400 -0.274900 -0.950900
vn 0.000000 -0.450200 -0.892900
vn 0.142400 0.274900 -0.950900
vn 0.247900 0.000000 -0.968700
vn 0.000000 0.450200 -0.892900
vn 0.269900 -0.421500 -0.865700
vn 0.395600 -0.336800 -0.854500
s off
f 1/1/1 29/2/1 30/3/1 4/4/1
f 8/5/2 5/6/2 31/7/2 32/8/2
f 32/8/3 31/9/3 30/10/3 29/1/3
f 8/2/4 1/5/4 4/11/4 5/12/4
f 18/13/5 15/14/5 10/15/5 11/16/5
f 19/17/6 18/18/6 11/19/6 12/20/6
f 21/21/7 24/22/7 23/23/7 22/24/7
f 25/25/8 26/26/8 27/27/8 28/28/8
f 19/29/9 12/30/9 9/31/9 14/32/9
f 22/26/10 23/21/10 27/22/10 26/27/10
f 21/33/11 22/21/11 26/26/11 25/34/11
f 24/22/12 28/27/12 27/35/12 23/36/12
f 34/37/13 36/38/13 8/39/13 32/40/13
f 33/41/13 34/37/13 32/40/13 29/42/13
f 33/41/13 29/42/13 1/43/13 35/44/13
f 35/44/13 1/43/13 8/39/13 36/38/13
f 45/45/12 40/46/12 41/47/12 42/48/12 46/49/12
f 48/50/11 47/51/11 43/52/11 44/53/11 38/54/11
f 44/55/8 43/45/8 42/51/8 41/56/8 37/57/8
f 48/47/7 39/58/7 45/52/7 46/59/7 47/60/7
f 12/13/8 11/30/8 10/31/8 9/14/8
f 19/29/7 14/32/7 15/61/7 18/62/7
f 16/63/13 20/64/13 7/65/13 3/66/13
f 13/67/13 16/63/13 3/66/13 2/68/13
f 17/69/13 6/70/13 7/65/13 20/64/13
f 13/67/13 2/68/13 6/70/13 17/69/13
s 1
f 73/71/14 72/72/15 52/44/16 61/73/17
f 56/74/18 60/75/19 59/76/20 55/77/21 69/78/22
f 74/79/23 63/80/24 51/37/25 66/81/26
f 75/82/27 70/83/28 50/38/29 62/84/30
f 76/85/31 64/86/32 52/41/16 72/87/15
f 57/88/33 59/76/20 60/75/19 58/89/34
f 55/77/21 59/76/20 57/88/33 53/90/35 68/91/36
f 53/90/35 57/88/33 58/89/34 54/92/37 67/93/38
f 54/92/37 58/89/34 60/75/19 56/74/18 65/94/39
f 65/94/39 56/92/18 72/72/15 73/71/14
f 54/74/37 65/94/39 73/71/14 70/87/28
f 70/87/28 73/71/14 61/73/17 50/41/29
f 68/91/36 74/79/23 66/81/26 55/77/21
f 53/90/35 71/83/40 74/79/23 68/91/36
f 71/83/40 49/38/41 63/80/24 74/79/23
f 67/93/38 54/90/37 70/83/28 75/82/27
f 53/92/35 67/93/38 75/82/27 71/72/40
f 71/72/40 75/82/27 62/84/30 49/44/41
f 69/78/22 76/85/31 72/87/15 56/74/18
f 55/77/21 66/81/26 76/85/31 69/78/22
f 66/81/26 51/37/25 64/86/32 76/85/31

View File

@ -0,0 +1,263 @@
# Blender v2.73 (sub 0) OBJ File: 'mesecons-wall-lever.blend'
# www.blender.org
o nodebox-5
v 0.289062 0.156250 0.312500
v -0.375000 0.375000 0.375000
v -0.375000 -0.375000 0.375000
v 0.332500 0.207500 0.375000
v 0.332500 -0.207500 0.375000
v 0.375000 0.375000 0.375000
v 0.375000 -0.375000 0.375000
v 0.289062 -0.156250 0.312500
v -0.062500 0.075354 0.315617
v -0.062500 0.043002 0.194876
v -0.062500 0.369002 0.107525
v -0.062500 0.401354 0.228266
v -0.332500 0.207500 0.375000
v 0.062500 0.075354 0.315617
v 0.062500 0.043002 0.194876
v -0.332500 -0.207500 0.375000
v 0.332500 0.207500 0.375000
v 0.062500 0.369002 0.107525
v 0.062500 0.401354 0.228266
v 0.332500 -0.207500 0.375000
v 0.375000 -0.375000 0.375000
v 0.375000 -0.375000 0.500000
v 0.375000 0.375000 0.500000
v 0.375000 0.375000 0.375000
v -0.375000 -0.375000 0.375000
v -0.375000 -0.375000 0.500000
v -0.375000 0.375000 0.500000
v -0.375000 0.375000 0.375000
v -0.289062 0.156250 0.312500
v -0.332500 0.207500 0.375000
v -0.332500 -0.207500 0.375000
v -0.289062 -0.156250 0.312500
v -0.250000 0.125000 0.312500
v -0.250000 -0.125000 0.312500
v 0.250000 0.125000 0.312500
v 0.250000 -0.125000 0.312500
v -0.250000 -0.000000 0.250000
v -0.000000 -0.125000 0.250000
v 0.250000 -0.000000 0.250000
v 0.000000 0.125000 0.250000
v -0.250000 0.125000 0.250000
v -0.250000 0.125000 0.312500
v -0.250000 -0.125000 0.312500
v -0.250000 -0.125000 0.250000
v 0.250000 0.125000 0.250000
v 0.250000 0.125000 0.312500
v 0.250000 -0.125000 0.312500
v 0.250000 -0.125000 0.250000
v 0.250000 -0.125000 0.250000
v 0.250000 0.125000 0.250000
v -0.250000 -0.125000 0.250000
v -0.250000 0.125000 0.250000
v 0.125000 -0.062500 0.187500
v 0.125000 0.062500 0.187500
v -0.125000 -0.062500 0.187500
v -0.125000 0.062500 0.187500
v 0.065000 -0.032500 0.176992
v 0.065000 0.032500 0.176992
v -0.065000 -0.032500 0.176992
v -0.065000 0.032500 0.176992
v 0.000000 0.125000 0.250000
v 0.250000 -0.000000 0.250000
v -0.000000 -0.125000 0.250000
v -0.250000 -0.000000 0.250000
v 0.000000 0.062500 0.187500
v -0.187500 -0.093750 0.208750
v 0.125000 -0.000000 0.187500
v 0.000000 -0.062500 0.187500
v -0.125000 -0.000000 0.187500
v 0.187500 0.093750 0.208750
v 0.187500 -0.093750 0.208750
v -0.187500 0.093750 0.208750
v 0.000000 0.093750 0.208750
v 0.000000 -0.093750 0.208750
v 0.187500 -0.000000 0.208750
v -0.187500 -0.000000 0.208750
vt 0.416667 0.416667
vt 0.083333 0.416667
vt 0.055556 0.472222
vt 0.444444 0.472222
vt 0.083333 0.083333
vt 0.055556 0.027778
vt 0.444444 0.027778
vt 0.416667 0.083333
vt 0.472222 0.055556
vt 0.472222 0.444444
vt 0.027778 0.055556
vt 0.027778 0.444444
vt 0.250000 0.833333
vt 0.250000 0.638889
vt 0.305556 0.638889
vt 0.305556 0.833333
vt 0.388889 0.777778
vt 0.333333 0.777778
vt 0.333333 0.722222
vt 0.388889 0.722222
vt 0.944444 0.527778
vt 0.944444 0.916667
vt 1.000000 0.916667
vt 1.000000 0.527778
vt 0.500000 0.527778
vt 0.555556 0.527778
vt 0.555556 0.916667
vt 0.500000 0.916667
vt 0.138889 0.833333
vt 0.194444 0.833333
vt 0.194444 0.638889
vt 0.138889 0.638889
vt 0.944444 0.472222
vt 0.555556 0.472222
vt 0.555556 0.972222
vt 0.944444 0.972222
vt 0.888802 0.166753
vt 0.555642 0.166753
vt 0.527778 0.138889
vt 0.916667 0.138889
vt 0.888802 0.388802
vt 0.916667 0.416667
vt 0.527778 0.416667
vt 0.555642 0.388802
vt 0.361111 0.361111
vt 0.250000 0.361111
vt 0.138889 0.361111
vt 0.138889 0.416667
vt 0.361111 0.416667
vt 0.361111 0.083333
vt 0.361111 0.138889
vt 0.138889 0.138889
vt 0.138889 0.083333
vt 0.250000 0.083333
vt 0.416667 0.361111
vt 0.416667 0.138889
vt 0.416667 0.250000
vt 0.138889 0.250000
vt 0.083333 0.138889
vt 0.083333 0.361111
vt 0.083333 0.638889
vt 0.083333 0.833333
vt 0.444444 0.611111
vt 0.055556 0.611111
vt 0.027778 0.527778
vt 0.472222 0.527778
vt 0.444444 0.888889
vt 0.472222 0.972222
vt 0.055556 0.888889
vt 0.027778 0.972222
vt 0.722222 0.361111
vt 0.583333 0.361111
vt 0.722222 0.388802
vt 0.833333 0.333333
vt 0.777778 0.305556
vt 0.777778 0.250000
vt 0.833333 0.222222
vt 0.833333 0.277778
vt 0.722222 0.194444
vt 0.722222 0.166753
vt 0.861111 0.194444
vt 0.583333 0.277778
vt 0.583333 0.194444
vt 0.555642 0.277778
vt 0.861111 0.277778
vt 0.888802 0.277778
vt 0.861111 0.361111
vt 0.666667 0.250000
vt 0.666667 0.305556
vt 0.611111 0.222222
vt 0.722222 0.222222
vt 0.611111 0.333333
vt 0.611111 0.277778
vt 0.722222 0.333333
vn 0.000000 0.773300 -0.634100
vn 0.000000 -0.773300 -0.634100
vn -0.821200 0.000000 -0.570700
vn 0.821200 0.000000 -0.570700
vn 0.000000 -0.258800 -0.965900
vn 0.000000 0.965900 -0.258800
vn 1.000000 0.000000 0.000000
vn -1.000000 0.000000 0.000000
vn 0.000000 0.258800 0.965900
vn 0.000000 -0.000000 1.000000
vn 0.000000 -1.000000 0.000000
vn 0.000000 1.000000 0.000000
vn 0.000000 0.000000 -1.000000
vn 0.000000 0.688800 -0.724900
vn -0.269900 0.421500 -0.865700
vn -0.395600 0.336800 -0.854500
vn 0.000000 0.797100 -0.603900
vn -0.142400 0.274900 -0.950900
vn -0.056900 0.142700 -0.988100
vn -0.056900 -0.142700 -0.988100
vn -0.142400 -0.274900 -0.950900
vn -0.247900 0.000000 -0.968700
vn 0.000000 -0.688800 -0.724900
vn 0.000000 -0.797100 -0.603900
vn -0.395600 -0.336800 -0.854500
vn -0.269900 -0.421500 -0.865700
vn 0.440000 0.000000 -0.898000
vn 0.269900 0.421500 -0.865700
vn 0.395600 0.336800 -0.854500
vn 0.550800 0.000000 -0.834600
vn -0.440000 0.000000 -0.898000
vn -0.550800 0.000000 -0.834600
vn 0.056900 -0.142700 -0.988100
vn 0.056900 0.142700 -0.988100
vn 0.142400 -0.274900 -0.950900
vn 0.000000 -0.450200 -0.892900
vn 0.142400 0.274900 -0.950900
vn 0.247900 0.000000 -0.968700
vn 0.000000 0.450200 -0.892900
vn 0.269900 -0.421500 -0.865700
vn 0.395600 -0.336800 -0.854500
s off
f 1/1/1 29/2/1 30/3/1 4/4/1
f 8/5/2 5/6/2 31/7/2 32/8/2
f 32/8/3 31/9/3 30/10/3 29/1/3
f 8/2/4 1/5/4 4/11/4 5/12/4
f 18/13/5 15/14/5 10/15/5 11/16/5
f 19/17/6 18/18/6 11/19/6 12/20/6
f 21/21/7 24/22/7 23/23/7 22/24/7
f 25/25/8 26/26/8 27/27/8 28/28/8
f 19/29/9 12/30/9 9/31/9 14/32/9
f 22/26/10 23/21/10 27/22/10 26/27/10
f 21/33/11 22/21/11 26/26/11 25/34/11
f 24/22/12 28/27/12 27/35/12 23/36/12
f 34/37/13 36/38/13 8/39/13 32/40/13
f 33/41/13 34/37/13 32/40/13 29/42/13
f 33/41/13 29/42/13 1/43/13 35/44/13
f 35/44/13 1/43/13 8/39/13 36/38/13
f 45/45/12 40/46/12 41/47/12 42/48/12 46/49/12
f 48/50/11 47/51/11 43/52/11 44/53/11 38/54/11
f 44/55/8 43/45/8 42/51/8 41/56/8 37/57/8
f 48/47/7 39/58/7 45/52/7 46/59/7 47/60/7
f 12/13/8 11/30/8 10/31/8 9/14/8
f 19/29/7 14/32/7 15/61/7 18/62/7
f 16/63/13 20/64/13 7/65/13 3/66/13
f 13/67/13 16/63/13 3/66/13 2/68/13
f 17/69/13 6/70/13 7/65/13 20/64/13
f 13/67/13 2/68/13 6/70/13 17/69/13
s 1
f 73/71/14 72/72/15 52/44/16 61/73/17
f 56/74/18 60/75/19 59/76/20 55/77/21 69/78/22
f 74/79/23 63/80/24 51/37/25 66/81/26
f 75/82/27 70/83/28 50/38/29 62/84/30
f 76/85/31 64/86/32 52/41/16 72/87/15
f 57/88/33 59/76/20 60/75/19 58/89/34
f 55/77/21 59/76/20 57/88/33 53/90/35 68/91/36
f 53/90/35 57/88/33 58/89/34 54/92/37 67/93/38
f 54/92/37 58/89/34 60/75/19 56/74/18 65/94/39
f 65/94/39 56/92/18 72/72/15 73/71/14
f 54/74/37 65/94/39 73/71/14 70/87/28
f 70/87/28 73/71/14 61/73/17 50/41/29
f 68/91/36 74/79/23 66/81/26 55/77/21
f 53/90/35 71/83/40 74/79/23 68/91/36
f 71/83/40 49/38/41 63/80/24 74/79/23
f 67/93/38 54/90/37 70/83/28 75/82/27
f 53/92/35 67/93/38 75/82/27 71/72/40
f 71/72/40 75/82/27 62/84/30 49/44/41
f 69/78/22 76/85/31 72/87/15 56/74/18
f 55/77/21 66/81/26 76/85/31 69/78/22
f 66/81/26 51/37/25 64/86/32 76/85/31

Binary file not shown.

Before

Width:  |  Height:  |  Size: 614 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 582 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 500 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 500 B

After

Width:  |  Height:  |  Size: 1.5 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 517 B

After

Width:  |  Height:  |  Size: 1.5 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 612 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 575 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 587 B

View File

@ -1,93 +1,240 @@
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()
local craft_time = 1
local function count_index(invlist)
local index = {}
for _, stack in pairs(invlist) do
if not stack:is_empty() then
local stack_name = stack:get_name()
index[stack_name] = (index[stack_name] or 0) + stack:get_count()
end
end
return l
return index
end
local function autocraft(inventory, pos)
if not inventory then return end
local recipe = inventory:get_list("recipe")
if not recipe then return end
local recipe_last
local result
local new
local function get_item_info(stack)
local name = stack:get_name()
local def = minetest.registered_items[name]
local description = def and def.description or "Unknown item"
return description, name
end
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
local function get_craft(pos, inventory, hash)
local hash = hash or minetest.hash_node_position(pos)
local craft = autocrafterCache[hash]
if not craft then
local recipe = inventory:get_list("recipe")
local output, decremented_input = minetest.get_craft_result({method = "normal", width = 3, items = recipe})
craft = {recipe = recipe, consumption=count_index(recipe), output = output, decremented_input = decremented_input}
autocrafterCache[hash] = craft
end
return craft
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
local function autocraft(inventory, craft)
if not craft then return false end
local output_item = craft.output.item
-- check if we have enough room in dst
if not inventory:room_for_item("dst", output_item) then return false end
local consumption = craft.consumption
local inv_index = count_index(inventory:get_list("src"))
-- check if we have enough material available
for itemname, number in pairs(consumption) do
if (not inv_index[itemname]) or inv_index[itemname] < number then return false 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
-- consume material
for itemname, number in pairs(consumption) 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)
-- craft the result into the dst inventory and add any "replacements" as well
inventory:add_item("dst", output_item)
for i = 1, 9 do
inventory:add_item("dst", new.items[i])
inventory:add_item("dst", craft.decremented_input.items[i])
end
return true
end
-- returns false to stop the timer, true to continue running
-- is started only from start_autocrafter(pos) after sanity checks and cached recipe
local function run_autocrafter(pos, elapsed)
local meta = minetest.get_meta(pos)
local inventory = meta:get_inventory()
local craft = get_craft(pos, inventory)
local output_item = craft.output.item
-- only use crafts that have an actual result
if output_item:is_empty() then
meta:set_string("infotext", "unconfigured Autocrafter: unknown recipe")
return false
end
for step = 1, math.floor(elapsed/craft_time) do
local continue = autocraft(inventory, craft)
if not continue then return false end
end
return true
end
local function start_crafter(pos)
local meta = minetest.get_meta(pos)
if meta:get_int("enabled") == 1 then
local timer = minetest.get_node_timer(pos)
if not timer:is_started() then
timer:start(craft_time)
end
end
end
local function update_autocrafter(pos)
local function after_inventory_change(pos)
start_crafter(pos)
end
-- note, that this function assumes allready being updated to virtual items
-- and doesn't handle recipes with stacksizes > 1
local function after_recipe_change(pos, inventory)
local meta = minetest.get_meta(pos)
if meta:get_string("virtual_items") == "" then
meta:set_string("virtual_items", "1")
local inv = meta:get_inventory()
for _, stack in ipairs(inv:get_list("recipe")) do
minetest.item_drop(stack, "", pos)
-- if we emptied the grid, there's no point in keeping it running or cached
if inventory:is_empty("recipe") then
minetest.get_node_timer(pos):stop()
autocrafterCache[minetest.hash_node_position(pos)] = nil
meta:set_string("infotext", "unconfigured Autocrafter")
return
end
local recipe_changed = false
local recipe = inventory:get_list("recipe")
local hash = minetest.hash_node_position(pos)
local craft = autocrafterCache[hash]
if craft then
-- check if it changed
local cached_recipe = craft.recipe
for i = 1, 9 do
if recipe[i]:get_name() ~= cached_recipe[i]:get_name() then
autocrafterCache[hash] = nil -- invalidate recipe
craft = nil
break
end
end
end
craft = craft or get_craft(pos, inventory, hash)
local output_item = craft.output.item
local description, name = get_item_info(output_item)
meta:set_string("infotext", string.format("'%s' Autocrafter (%s)", description, name))
inventory:set_stack("output", 1, output_item)
after_inventory_change(pos)
end
-- clean out unknown items and groups, which would be handled like unknown items in the crafting grid
-- if minetest supports query by group one day, this might replace them
-- with a canonical version instead
local function normalize(item_list)
for i = 1, #item_list do
local name = item_list[i]
if not minetest.registered_items[name] then
item_list[i] = ""
end
end
return item_list
end
local function on_output_change(pos, inventory, stack)
if not stack then
inventory:set_list("output", {})
inventory:set_list("recipe", {})
else
local input = minetest.get_craft_recipe(stack:get_name())
if not input.items or input.type ~= "normal" then return end
local items, width = normalize(input.items), input.width
local item_idx, width_idx = 1, 1
for i = 1, 9 do
if width_idx <= width then
inventory:set_stack("recipe", i, items[item_idx])
item_idx = item_idx + 1
else
inventory:set_stack("recipe", i, ItemStack(""))
end
width_idx = (width_idx < 3) and (width_idx + 1) or 1
end
-- we'll set the output slot in after_recipe_change to the actual result of the new recipe
end
after_recipe_change(pos, inventory)
end
-- returns false if we shouldn't bother attempting to start the timer again after this
local function update_meta(meta, enabled)
local state = enabled and "on" or "off"
meta:set_int("enabled", enabled and 1 or 0)
meta:set_string("formspec",
"size[8,11]"..
"list[context;recipe;0,0;3,3;]"..
"image[3,1;1,1;gui_hb_bg.png^[colorize:#141318:255]"..
"list[context;output;3,1;1,1;]"..
"image_button[3,2;1,1;pipeworks_button_" .. state .. ".png;" .. state .. ";;;false;pipeworks_button_interm.png]" ..
"list[context;src;0,3.5;8,3;]"..
"list[context;dst;4,0;4,3;]"..
default.gui_bg..
default.gui_bg_img..
default.gui_slots..
default.get_hotbar_bg(0,7) ..
"list[current_player;main;0,7;8,4;]")
-- toggling the button doesn't quite call for running a recipe change check
-- so instead we run a minimal version for infotext setting only
-- this might be more written code, but actually executes less
local output = meta:get_inventory():get_stack("output", 1)
if output:is_empty() then -- doesn't matter if paused or not
meta:set_string("infotext", "unconfigured Autocrafter")
return false
end
local description, name = get_item_info(output)
local infotext = enabled and string.format("'%s' Autocrafter (%s)", description, name)
or string.format("paused '%s' Autocrafter", description)
meta:set_string("infotext", infotext)
return enabled
end
-- 1st version of the autocrafter had actual items in the crafting grid
-- the 2nd replaced these with virtual items, dropped the content on update and set "virtual_items" to string "1"
-- the third added an output inventory, changed the formspec and added a button for enabling/disabling
-- so we work out way backwards on this history and update each single case to the newest version
local function upgrade_autocrafter(pos, meta)
local meta = meta or minetest.get_meta(pos)
local inv = meta:get_inventory()
if inv:get_size("output") == 0 then -- we are version 2 or 1
inv:set_size("output", 1)
-- migrate the old autocrafters into an "enabled" state
update_meta(meta, true)
if meta:get_string("virtual_items") == "1" then -- we are version 2
-- we allready dropped stuff, so lets remove the metadatasetting (we are not being called again for this node)
meta:set_string("virtual_items", "")
else -- we are version 1
local recipe = inv:get_list("recipe")
if not recipe then return end
for idx, stack in ipairs(recipe) do
if not stack:is_empty() then
minetest.item_drop(stack, "", pos)
stack:set_count(1)
stack:set_wear(0)
inv:set_stack("recipe", idx, stack)
end
end
end
-- update the recipe, cache, and start the crafter
autocrafterCache[minetest.hash_node_position(pos)] = nil
after_recipe_change(pos, inv)
end
end
minetest.register_node("pipeworks:autocrafter", {
@ -98,7 +245,9 @@ minetest.register_node("pipeworks:autocrafter", {
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)
local added = inv:add_item("src", stack)
after_inventory_change(pos)
return added
end,
can_insert = function(pos, node, stack, direction)
local meta = minetest.get_meta(pos)
@ -109,78 +258,104 @@ minetest.register_node("pipeworks:autocrafter", {
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")
meta:set_string("virtual_items", "1")
local inv = meta:get_inventory()
inv:set_size("src", 3*8)
inv:set_size("recipe", 3*3)
inv:set_size("dst", 4*3)
inv:set_size("output", 1)
update_meta(meta, false)
end,
on_receive_fields = function(pos, formname, fields, sender)
local meta = minetest.get_meta(pos)
if fields.on then
update_meta(meta, false)
minetest.get_node_timer(pos):stop()
elseif fields.off then
if update_meta(meta, true) then
start_crafter(pos)
end
end
end,
on_punch = update_autocrafter,
can_dig = function(pos, player)
update_autocrafter(pos)
upgrade_autocrafter(pos)
local meta = minetest.get_meta(pos)
local inv = meta:get_inventory()
return (inv:is_empty("src") and inv:is_empty("dst"))
end,
after_place_node = function(pos)
pipeworks.scan_for_tube_objects(pos)
end,
after_place_node = pipeworks.scan_for_tube_objects,
after_dig_node = function(pos)
pipeworks.scan_for_tube_objects(pos)
end,
on_destruct = function(pos)
autocrafterCache[minetest.hash_node_position(pos)] = nil
end,
allow_metadata_inventory_put = function(pos, listname, index, stack, player)
update_autocrafter(pos)
upgrade_autocrafter(pos)
local inv = minetest.get_meta(pos):get_inventory()
if listname == "recipe" then
local stack_copy = ItemStack(stack)
stack_copy:set_count(1)
inv:set_stack(listname, index, stack_copy)
stack:set_count(1)
inv:set_stack(listname, index, stack)
after_recipe_change(pos, inv)
return 0
elseif listname == "output" then
on_output_change(pos, inv, stack)
return 0
else
return stack:get_count()
end
after_inventory_change(pos)
return stack:get_count()
end,
allow_metadata_inventory_take = function(pos, listname, index, stack, player)
update_autocrafter(pos)
upgrade_autocrafter(pos)
local inv = minetest.get_meta(pos):get_inventory()
if listname == "recipe" then
inv:set_stack(listname, index, ItemStack(""))
after_recipe_change(pos, inv)
return 0
elseif listname == "output" then
on_output_change(pos, inv, nil)
return 0
else
return stack:get_count()
end
after_inventory_change(pos)
return stack:get_count()
end,
allow_metadata_inventory_move = function(pos, from_list, from_index, to_list, to_index, count, player)
update_autocrafter(pos)
upgrade_autocrafter(pos)
local inv = minetest.get_meta(pos):get_inventory()
local stack = inv:get_stack(from_list, from_index)
stack:set_count(count)
if from_list == "recipe" then
inv:set_stack(from_list, from_index, ItemStack(""))
if to_list == "output" then
on_output_change(pos, inv, stack)
return 0
elseif to_list == "recipe" then
local stack_copy = ItemStack(stack)
stack_copy:set_count(1)
inv:set_stack(to_list, to_index, stack_copy)
return 0
else
return stack:get_count()
elseif from_list == "output" then
on_output_change(pos, inv, nil)
if to_list ~= "recipe" then
return 0
end -- else fall through to recipe list handling
end
if from_list == "recipe" or to_list == "recipe" then
if from_list == "recipe" then
inv:set_stack(from_list, from_index, ItemStack(""))
end
if to_list == "recipe" then
stack:set_count(1)
inv:set_stack(to_list, to_index, stack)
end
after_recipe_change(pos, inv)
return 0
end
after_inventory_change(pos)
return count
end,
on_timer = run_autocrafter
})
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
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" }
},
})

View File

@ -9,7 +9,7 @@ local function autoroute_pipes(pos)
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,
minetest.swap_node(pos, {name = "pipeworks:pipe_"..tube_table[nsurround]..state,
param2 = tube_table_facedirs[nsurround]})
end

View File

@ -129,15 +129,17 @@ function fs_helpers.cycling_button(meta, base, meta_name, values)
local val = values[current_value + 1]
local text
local texture_name = nil
local addopts = nil
--when we get a table, we know the caller wants an image_button
if type(val) == "table" then
text = val["text"]
texture_name = val["texture"]
addopts = val["addopts"]
else
text = val
end
local field = "fs_helpers_cycling:"..new_value..":"..meta_name
return base..";"..(texture_name and texture_name..";" or "")..field..";"..minetest.formspec_escape(text).."]"
return base..";"..(texture_name and texture_name..";" or "")..field..";"..minetest.formspec_escape(text)..(addopts and ";"..addopts or "").."]"
end
---------

View File

@ -148,174 +148,4 @@ if minetest.get_modpath("homedecor") == nil then
})
end
minetest.register_craft( {
output = "pipeworks:one_way_tube 2",
recipe = {
{ "homedecor:plastic_sheeting", "homedecor:plastic_sheeting", "homedecor:plastic_sheeting" },
{ "group: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" },
{ "group: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" },
{ "group: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" }
},
})

View File

@ -0,0 +1,79 @@
local straight = function(pos, node, velocity, stack) return {velocity} end
minetest.register_node("pipeworks:steel_block_embedded_tube", {
description = "Airtight steelblock embedded tube",
tiles = {
"default_steel_block.png", "default_steel_block.png",
"default_steel_block.png", "default_steel_block.png",
"default_steel_block.png^pipeworks_tube_connection_metallic.png",
"default_steel_block.png^pipeworks_tube_connection_metallic.png",
},
paramtype = "light",
paramtype2 = "facedir",
groups = {cracky=1, oddly_breakable_by_hand = 1, tubedevice = 1},
legacy_facedir_simple = true,
sounds = default.node_sound_stone_defaults(),
tube = {
connect_sides = {front = 1, back = 1,},
priority = 50,
can_go = straight,
can_insert = function(pos, node, stack, direction)
local dir = minetest.facedir_to_dir(node.param2)
return vector.equals(dir, direction) or vector.equals(vector.multiply(dir, -1), direction)
end,
},
})
minetest.register_craft( {
output = "pipeworks:steel_block_embedded_tube 1",
recipe = {
{ "default:steel_ingot", "default:steel_ingot", "default:steel_ingot" },
{ "default:steel_ingot", "pipeworks:tube_1", "default:steel_ingot" },
{ "default:steel_ingot", "default:steel_ingot", "default:steel_ingot" }
},
})
local pane_box = {
type = "fixed",
fixed = {
{ -9/64, -9/64, -8/16, 9/64, 9/64, 8/16 }, -- tube
{ -8/16, -8/16, -1/16, 8/16, 8/16, 1/16 } -- pane
}
}
minetest.register_node("pipeworks:steel_pane_embedded_tube", {
drawtype = "nodebox",
description = "Airtight panel embedded tube ",
tiles = {
"pipeworks_pane_embedded_tube_sides.png^[transformR90",
"pipeworks_pane_embedded_tube_sides.png^[transformR90",
"pipeworks_pane_embedded_tube_sides.png",
"pipeworks_pane_embedded_tube_sides.png",
"pipeworks_pane_embedded_tube_ends.png", "pipeworks_pane_embedded_tube_ends.png",
},
node_box = pane_box,
selection_box = pane_box,
collision_box = pane_box,
paramtype = "light",
paramtype2 = "facedir",
groups = {cracky=1, oddly_breakable_by_hand = 1, tubedevice = 1},
legacy_facedir_simple = true,
sounds = default.node_sound_stone_defaults(),
tube = {
connect_sides = {front = 1, back = 1,},
priority = 50,
can_go = straight,
can_insert = function(pos, node, stack, direction)
local dir = minetest.facedir_to_dir(node.param2)
return vector.equals(dir, direction) or vector.equals(vector.multiply(dir, -1), direction)
end,
},
})
minetest.register_craft( {
output = "pipeworks:steel_pane_embedded_tube 1",
recipe = {
{ "", "default:steel_ingot", "" },
{ "", "pipeworks:tube_1", "" },
{ "", "default:steel_ingot", "" }
},
})

View File

@ -16,4 +16,5 @@ pipeworks.enable_crossing_tube = true
pipeworks.enable_sand_tube = true
pipeworks.enable_mese_sand_tube = true
pipeworks.enable_one_way_tube = true
pipeworks.enable_priority_tube = true
pipeworks.enable_cyclic_mode = true

View File

@ -0,0 +1,223 @@
local function delay(x)
return (function() return x end)
end
local function set_filter_infotext(data, meta)
local infotext = data.wise_desc.." Filter-Injector"
if meta:get_int("slotseq_mode") == 2 then
infotext = infotext .. " (slot #"..meta:get_int("slotseq_index").." next)"
end
meta:set_string("infotext", infotext)
end
local function set_filter_formspec(data, meta)
local itemname = data.wise_desc.." Filter-Injector"
local formspec = "size[8,8.5]"..
"item_image[0,0;1,1;pipeworks:"..data.name.."]"..
"label[1,0;"..minetest.formspec_escape(itemname).."]"..
"label[0,1;Prefer item types:]"..
"list[context;main;0,1.5;8,2;]"..
fs_helpers.cycling_button(meta, "button[0,3.5;4,1", "slotseq_mode",
{"Sequence slots by Priority",
"Sequence slots Randomly",
"Sequence slots by Rotation"})..
"list[current_player;main;0,4.5;8,4;]"
meta:set_string("formspec", formspec)
end
-- todo SOON: this function has *way too many* parameters
local function grabAndFire(data,slotseq_mode,filtmeta,frominv,frominvname,frompos,fromnode,filterfor,fromtube,fromdef,dir,fakePlayer,all)
local sposes = {}
for spos,stack in ipairs(frominv:get_list(frominvname)) do
local matches
if filterfor == "" then
matches = stack:get_name() ~= ""
else
matches = stack:get_name() == filterfor.name
end
if matches then table.insert(sposes, spos) end
end
if #sposes == 0 then return false end
if slotseq_mode == 1 then
for i = #sposes, 2, -1 do
local j = math.random(i)
local t = sposes[j]
sposes[j] = sposes[i]
sposes[i] = t
end
elseif slotseq_mode == 2 then
local headpos = filtmeta:get_int("slotseq_index")
table.sort(sposes, function (a, b)
if a >= headpos then
if b < headpos then return true end
else
if b >= headpos then return false end
end
return a < b
end)
end
for _, spos in ipairs(sposes) do
local stack = frominv:get_stack(frominvname, spos)
local doRemove = stack:get_count()
if fromtube.can_remove then
doRemove = fromtube.can_remove(frompos, fromnode, stack, dir)
elseif fromdef.allow_metadata_inventory_take then
doRemove = fromdef.allow_metadata_inventory_take(frompos, frominvname,spos, stack, fakePlayer)
end
-- stupid lack of continue statements grumble
if doRemove > 0 then
if slotseq_mode == 2 then
local nextpos = spos + 1
if nextpos > frominv:get_size(frominvname) then
nextpos = 1
end
filtmeta:set_int("slotseq_index", nextpos)
set_filter_infotext(data, filtmeta)
end
local item
local count
if all then
count = math.min(stack:get_count(), doRemove)
if filterfor.count and filterfor.count > 1 then
count = math.min(filterfor.count, count)
end
else
count = 1
end
if fromtube.remove_items then
-- it could be the entire stack...
item = fromtube.remove_items(frompos, fromnode, stack, dir, count)
else
item = stack:take_item(count)
frominv:set_stack(frominvname, spos, stack)
if fromdef.on_metadata_inventory_take then
fromdef.on_metadata_inventory_take(frompos, frominvname, spos, item, fakePlayer)
end
end
local pos = vector.add(frompos, vector.multiply(dir, 1.4))
local start_pos = vector.add(frompos, dir)
local item1 = pipeworks.tube_inject_item(pos, start_pos, dir, item)
return true-- only fire one item, please
end
end
return false
end
local function punch_filter(data, filtpos, filtnode)
local filtmeta = minetest.get_meta(filtpos)
local filtinv = filtmeta:get_inventory()
local owner = filtmeta:get_string("owner")
local fakePlayer = {
get_player_name = delay(owner),
} -- TODO: use a mechanism as the wielder one
local dir = minetest.facedir_to_right_dir(filtnode.param2)
local frompos = vector.subtract(filtpos, dir)
local fromnode = minetest.get_node(frompos)
if not fromnode then return end
local fromdef = minetest.registered_nodes[fromnode.name]
if not fromdef then return end
local fromtube = fromdef.tube
if not (fromtube and fromtube.input_inventory) then return end
local filters = {}
for _, filterstack in ipairs(filtinv:get_list("main")) do
local filtername = filterstack:get_name()
local filtercount = filterstack:get_count()
if filtername ~= "" then table.insert(filters, {name = filtername, count = filtercount}) end
end
if #filters == 0 then table.insert(filters, "") end
local slotseq_mode = filtmeta:get_int("slotseq_mode")
local frommeta = minetest.get_meta(frompos)
local frominv = frommeta:get_inventory()
if fromtube.before_filter then fromtube.before_filter(frompos) end
for _, frominvname in ipairs(type(fromtube.input_inventory) == "table" and fromtube.input_inventory or {fromtube.input_inventory}) do
local done = false
for _, filterfor in ipairs(filters) do
if grabAndFire(data, slotseq_mode, filtmeta, frominv, frominvname, frompos, fromnode, filterfor, fromtube, fromdef, dir, fakePlayer, data.stackwise) then
done = true
break
end
end
if done then break end
end
if fromtube.after_filter then fromtube.after_filter(frompos) end
end
for _, data in ipairs({
{
name = "filter",
wise_desc = "Itemwise",
stackwise = false,
},
{
name = "mese_filter",
wise_desc = "Stackwise",
stackwise = true,
},
}) do
minetest.register_node("pipeworks:"..data.name, {
description = data.wise_desc.." Filter-Injector",
tiles = {
"pipeworks_"..data.name.."_top.png",
"pipeworks_"..data.name.."_top.png",
"pipeworks_"..data.name.."_output.png",
"pipeworks_"..data.name.."_input.png",
"pipeworks_"..data.name.."_side.png",
"pipeworks_"..data.name.."_top.png",
},
paramtype2 = "facedir",
groups = {snappy = 2, choppy = 2, oddly_breakable_by_hand = 2, mesecon = 2},
legacy_facedir_simple = true,
sounds = default.node_sound_wood_defaults(),
on_construct = function(pos)
local meta = minetest.get_meta(pos)
set_filter_formspec(data, meta)
set_filter_infotext(data, meta)
local inv = meta:get_inventory()
inv:set_size("main", 8*2)
end,
after_place_node = function (pos, placer)
minetest.get_meta(pos):set_string("owner", placer:get_player_name())
end,
on_receive_fields = function(pos, formname, fields, sender)
fs_helpers.on_receive_fields(pos, fields)
local meta = minetest.get_meta(pos)
meta:set_int("slotseq_index", 1)
set_filter_formspec(data, meta)
set_filter_infotext(data, meta)
end,
can_dig = function(pos, player)
local meta = minetest.get_meta(pos)
local inv = meta:get_inventory()
return inv:is_empty("main")
end,
mesecons = {
effector = {
action_on = function(pos, node)
punch_filter(data, pos, node)
end,
},
},
tube = {connect_sides = {right = 1}},
on_punch = function (pos, node, puncher)
punch_filter(data, pos, node)
end,
})
end
minetest.register_craft( {
output = "pipeworks:filter 2",
recipe = {
{ "default:steel_ingot", "default:steel_ingot", "homedecor:plastic_sheeting" },
{ "group: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" },
{ "group:stick", "default:mese", "homedecor:plastic_sheeting" },
{ "default:steel_ingot", "default:steel_ingot", "homedecor:plastic_sheeting" }
},
})

View File

@ -115,7 +115,13 @@ dofile(pipeworks.modpath.."/luaentity.lua")
dofile(pipeworks.modpath.."/item_transport.lua")
dofile(pipeworks.modpath.."/flowing_logic.lua")
dofile(pipeworks.modpath.."/crafts.lua")
dofile(pipeworks.modpath.."/tubes.lua")
dofile(pipeworks.modpath.."/tube_registration.lua")
dofile(pipeworks.modpath.."/routing_tubes.lua")
dofile(pipeworks.modpath.."/sorting_tubes.lua")
dofile(pipeworks.modpath.."/vacuum_tubes.lua")
dofile(pipeworks.modpath.."/signal_tubes.lua")
dofile(pipeworks.modpath.."/decorative_tubes.lua")
dofile(pipeworks.modpath.."/filter-injector.lua")
dofile(pipeworks.modpath.."/trashcan.lua")
dofile(pipeworks.modpath.."/wielder.lua")

View File

@ -1,7 +1,3 @@
local function delay(x)
return (function() return x end)
end
function pipeworks.tube_item(pos, item)
error("obsolete pipeworks.tube_item() called; change caller to use pipeworks.tube_inject_item() instead")
end
@ -23,204 +19,6 @@ end
-- both optional w/ sensible defaults and fallback to normal allow_* function
-- XXX: possibly change insert_object to insert_item
local function set_filter_infotext(data, meta)
local infotext = data.wise_desc.." Filter-Injector"
if meta:get_int("slotseq_mode") == 2 then
infotext = infotext .. " (slot #"..meta:get_int("slotseq_index").." next)"
end
meta:set_string("infotext", infotext)
end
local function set_filter_formspec(data, meta)
local itemname = data.wise_desc.." Filter-Injector"
local formspec = "size[8,8.5]"..
"item_image[0,0;1,1;pipeworks:"..data.name.."]"..
"label[1,0;"..minetest.formspec_escape(itemname).."]"..
"label[0,1;Prefer item types:]"..
"list[current_name;main;0,1.5;8,2;]"..
fs_helpers.cycling_button(meta, "button[0,3.5;4,1", "slotseq_mode",
{"Sequence slots by Priority",
"Sequence slots Randomly",
"Sequence slots by Rotation"})..
"list[current_player;main;0,4.5;8,4;]"
meta:set_string("formspec", formspec)
end
-- todo SOON: this function has *way too many* parameters
local function grabAndFire(data,slotseq_mode,filtmeta,frominv,frominvname,frompos,fromnode,filtername,fromtube,fromdef,dir,fakePlayer,all)
local sposes = {}
for spos,stack in ipairs(frominv:get_list(frominvname)) do
local matches
if filtername == "" then
matches = stack:get_name() ~= ""
else
matches = stack:get_name() == filtername
end
if matches then table.insert(sposes, spos) end
end
if #sposes == 0 then return false end
if slotseq_mode == 1 then
for i = #sposes, 2, -1 do
local j = math.random(i)
local t = sposes[j]
sposes[j] = sposes[i]
sposes[i] = t
end
elseif slotseq_mode == 2 then
local headpos = filtmeta:get_int("slotseq_index")
table.sort(sposes, function (a, b)
if a >= headpos then
if b < headpos then return true end
else
if b >= headpos then return false end
end
return a < b
end)
end
for _, spos in ipairs(sposes) do
local stack = frominv:get_stack(frominvname, spos)
local doRemove = stack:get_count()
if fromtube.can_remove then
doRemove = fromtube.can_remove(frompos, fromnode, stack, dir)
elseif fromdef.allow_metadata_inventory_take then
doRemove = fromdef.allow_metadata_inventory_take(frompos, frominvname,spos, stack, fakePlayer)
end
-- stupid lack of continue statements grumble
if doRemove > 0 then
if slotseq_mode == 2 then
local nextpos = spos + 1
if nextpos > frominv:get_size(frominvname) then
nextpos = 1
end
filtmeta:set_int("slotseq_index", nextpos)
set_filter_infotext(data, filtmeta)
end
local item
local count
if all then
count = math.min(stack:get_count(), doRemove)
else
count = 1
end
if fromtube.remove_items then
-- it could be the entire stack...
item = fromtube.remove_items(frompos, fromnode, stack, dir, count)
else
item = stack:take_item(count)
frominv:set_stack(frominvname, spos, stack)
if fromdef.on_metadata_inventory_take then
fromdef.on_metadata_inventory_take(frompos, frominvname, spos, item, fakePlayer)
end
end
local pos = vector.add(frompos, vector.multiply(dir, 1.4))
local start_pos = vector.add(frompos, dir)
local item1 = pipeworks.tube_inject_item(pos, start_pos, dir, item)
return true-- only fire one item, please
end
end
return false
end
local function punch_filter(data, filtpos, filtnode)
local filtmeta = minetest.get_meta(filtpos)
local filtinv = filtmeta:get_inventory()
local owner = filtmeta:get_string("owner")
local fakePlayer = {
get_player_name = delay(owner),
} -- TODO: use a mechanism as the wielder one
local dir = minetest.facedir_to_right_dir(filtnode.param2)
local frompos = vector.subtract(filtpos, dir)
local fromnode = minetest.get_node(frompos)
if not fromnode then return end
local fromdef = minetest.registered_nodes[fromnode.name]
if not fromdef then return end
local fromtube = fromdef.tube
if not (fromtube and fromtube.input_inventory) then return end
local filters = {}
for _, filterstack in ipairs(filtinv:get_list("main")) do
local filtername = filterstack:get_name()
if filtername ~= "" then table.insert(filters, filtername) end
end
if #filters == 0 then table.insert(filters, "") end
local slotseq_mode = filtmeta:get_int("slotseq_mode")
local frommeta = minetest.get_meta(frompos)
local frominv = frommeta:get_inventory()
if fromtube.before_filter then fromtube.before_filter(frompos) end
for _, frominvname in ipairs(type(fromtube.input_inventory) == "table" and fromtube.input_inventory or {fromtube.input_inventory}) do
local done = false
for _, filtername in ipairs(filters) do
if grabAndFire(data, slotseq_mode, filtmeta, frominv, frominvname, frompos, fromnode, filtername, fromtube, fromdef, dir, fakePlayer, data.stackwise) then
done = true
break
end
end
if done then break end
end
if fromtube.after_filter then fromtube.after_filter(frompos) end
end
for _, data in ipairs({
{
name = "filter",
wise_desc = "Itemwise",
stackwise = false,
},
{
name = "mese_filter",
wise_desc = "Stackwise",
stackwise = true,
},
}) do
minetest.register_node("pipeworks:"..data.name, {
description = data.wise_desc.." Filter-Injector",
tiles = {
"pipeworks_"..data.name.."_top.png",
"pipeworks_"..data.name.."_top.png",
"pipeworks_"..data.name.."_output.png",
"pipeworks_"..data.name.."_input.png",
"pipeworks_"..data.name.."_side.png",
"pipeworks_"..data.name.."_top.png",
},
paramtype2 = "facedir",
groups = {snappy = 2, choppy = 2, oddly_breakable_by_hand = 2, mesecon = 2},
legacy_facedir_simple = true,
sounds = default.node_sound_wood_defaults(),
on_construct = function(pos)
local meta = minetest.get_meta(pos)
set_filter_formspec(data, meta)
set_filter_infotext(data, meta)
local inv = meta:get_inventory()
inv:set_size("main", 8*2)
end,
after_place_node = function (pos, placer)
minetest.get_meta(pos):set_string("owner", placer:get_player_name())
end,
on_receive_fields = function(pos, formname, fields, sender)
fs_helpers.on_receive_fields(pos, fields)
local meta = minetest.get_meta(pos)
meta:set_int("slotseq_index", 1)
set_filter_formspec(data, meta)
set_filter_infotext(data, meta)
end,
can_dig = function(pos, player)
local meta = minetest.get_meta(pos)
local inv = meta:get_inventory()
return inv:is_empty("main")
end,
mesecons = {
effector = {
action_on = function(pos, node)
punch_filter(data, pos, node)
end,
},
},
tube = {connect_sides = {right = 1}},
on_punch = function (pos, node, puncher)
punch_filter(data, pos, node)
end,
})
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)

View File

@ -26,7 +26,6 @@ if not minetest.get_modpath("auto_tree_tap") and
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 },
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={back=1}},
on_construct = function(pos)

View File

@ -0,0 +1,117 @@
-- the default tube and default textures
pipeworks.register_tube("pipeworks:tube", "Pneumatic tube segment")
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" }
},
})
-- the high priority tube is a low-cpu replacement for sorting tubes in situations
-- where players would use them for simple routing (turning off paths)
-- without doing actual sorting, like at outputs of tubedevices that might both accept and eject items
if pipeworks.enable_priority_tube then
local color = "#ff3030:128"
pipeworks.register_tube("pipeworks:priority_tube", {
description = "High Priority Tube Segment",
inventory_image = "pipeworks_tube_inv.png^[colorize:" .. color,
plain = { "pipeworks_tube_plain.png^[colorize:" .. color },
noctr = { "pipeworks_tube_noctr.png^[colorize:" .. color },
ends = { "pipeworks_tube_end.png^[colorize:" .. color },
short = "pipeworks_tube_short.png^[colorize:" .. color,
node_def = {
tube = { priority = 150 } -- higher than tubedevices (100)
},
})
minetest.register_craft( {
output = "pipeworks:priority_tube_1 6",
recipe = {
{ "homedecor:plastic_sheeting", "homedecor:plastic_sheeting", "homedecor:plastic_sheeting" },
{ "default:gold_ingot", "", "default:gold_ingot" },
{ "homedecor:plastic_sheeting", "homedecor:plastic_sheeting", "homedecor:plastic_sheeting" }
},
})
end
if pipeworks.enable_accelerator_tube then
pipeworks.register_tube("pipeworks:accelerator_tube", {
description = "Accelerating Pneumatic Tube Segment",
inventory_image = "pipeworks_accelerator_tube_inv.png",
plain = { "pipeworks_accelerator_tube_plain.png" },
noctr = { "pipeworks_accelerator_tube_noctr.png" },
ends = { "pipeworks_accelerator_tube_end.png" },
short = "pipeworks_accelerator_tube_short.png",
node_def = {
tube = {can_go = function(pos, node, velocity, stack)
velocity.speed = velocity.speed+1
return pipeworks.notvel(pipeworks.meseadjlist, velocity)
end}
},
})
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" }
},
})
end
if pipeworks.enable_crossing_tube then
pipeworks.register_tube("pipeworks:crossing_tube", {
description = "Crossing Pneumatic Tube Segment",
inventory_image = "pipeworks_crossing_tube_inv.png",
plain = { "pipeworks_crossing_tube_plain.png" },
noctr = { "pipeworks_crossing_tube_noctr.png" },
ends = { "pipeworks_crossing_tube_end.png" },
short = "pipeworks_crossing_tube_short.png",
node_def = {
tube = {can_go = function(pos, node, velocity, stack) return {velocity} end }
},
})
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", "" }
},
})
end
if pipeworks.enable_one_way_tube then
minetest.register_node("pipeworks:one_way_tube", {
description = "One way tube",
tiles = {"pipeworks_one_way_tube_top.png", "pipeworks_one_way_tube_top.png", "pipeworks_one_way_tube_output.png",
"pipeworks_one_way_tube_input.png", "pipeworks_one_way_tube_side.png", "pipeworks_one_way_tube_top.png"},
paramtype2 = "facedir",
drawtype = "nodebox",
paramtype = "light",
node_box = {type = "fixed",
fixed = {{-1/2, -9/64, -9/64, 1/2, 9/64, 9/64}}},
groups = {snappy = 2, choppy = 2, oddly_breakable_by_hand = 2, tubedevice = 1},
sounds = default.node_sound_wood_defaults(),
tube = {
connect_sides = {left = 1, right = 1},
can_go = function(pos, node, velocity, stack)
return {velocity}
end,
can_insert = function(pos, node, stack, direction)
local dir = minetest.facedir_to_right_dir(node.param2)
return vector.equals(dir, direction)
end,
priority = 75 -- Higher than normal tubes, but lower than receivers
},
})
minetest.register_craft({
output = "pipeworks:one_way_tube 2",
recipe = {
{ "homedecor:plastic_sheeting", "homedecor:plastic_sheeting", "homedecor:plastic_sheeting" },
{ "group:stick", "default:mese_crystal", "homedecor:plastic_sheeting" },
{ "homedecor:plastic_sheeting", "homedecor:plastic_sheeting", "homedecor:plastic_sheeting" }
},
})
end

View File

@ -0,0 +1,111 @@
if pipeworks.enable_detector_tube then
local detector_tube_step = 2 * tonumber(minetest.setting_get("dedicated_server_step"))
pipeworks.register_tube("pipeworks:detector_tube_on", {
description = "Detecting Pneumatic Tube Segment on (you hacker you)",
inventory_image = "pipeworks_detector_tube_inv.png",
plain = { "pipeworks_detector_tube_plain.png" },
node_def = {
tube = {can_go = function(pos, node, velocity, stack)
local meta = minetest.get_meta(pos)
local name = minetest.get_node(pos).name
local nitems = meta:get_int("nitems")+1
meta:set_int("nitems", nitems)
local saved_pos = vector.new(pos)
minetest.after(detector_tube_step, minetest.registered_nodes[name].item_exit, saved_pos)
return pipeworks.notvel(pipeworks.meseadjlist,velocity)
end},
groups = {mesecon = 2, not_in_creative_inventory = 1},
drop = "pipeworks:detector_tube_off_1",
mesecons = {receptor = {state = "on", rules = pipeworks.mesecons_rules}},
item_exit = function(pos)
local meta = minetest.get_meta(pos)
local nitems = meta:get_int("nitems")-1
local node = minetest.get_node(pos)
local name = node.name
local fdir = node.param2
if nitems == 0 then
minetest.set_node(pos, {name = string.gsub(name, "on", "off"), param2 = fdir})
mesecon.receptor_off(pos, pipeworks.mesecons_rules)
else
meta:set_int("nitems", nitems)
end
end,
on_construct = function(pos)
local meta = minetest.get_meta(pos)
meta:set_int("nitems", 1)
local name = minetest.get_node(pos).name
local saved_pos = vector.new(pos)
minetest.after(detector_tube_step, minetest.registered_nodes[name].item_exit, saved_pos)
end,
},
})
pipeworks.register_tube("pipeworks:detector_tube_off", {
description = "Detecting Pneumatic Tube Segment",
inventory_image = "pipeworks_detector_tube_inv.png",
plain = { "pipeworks_detector_tube_plain.png" },
node_def = {
tube = {can_go = function(pos, node, velocity, stack)
local node = minetest.get_node(pos)
local name = node.name
local fdir = node.param2
minetest.set_node(pos,{name = string.gsub(name, "off", "on"), param2 = fdir})
mesecon.receptor_on(pos, pipeworks.mesecons_rules)
return pipeworks.notvel(pipeworks.meseadjlist, velocity)
end},
groups = {mesecon = 2},
mesecons = {receptor = {state = "off", rules = pipeworks.mesecons_rules }},
},
})
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" }
},
})
end
if pipeworks.enable_conductor_tube then
pipeworks.register_tube("pipeworks:conductor_tube_off", {
description = "Conducting Pneumatic Tube Segment",
inventory_image = "pipeworks_conductor_tube_inv.png",
short = "pipeworks_conductor_tube_short.png",
plain = { "pipeworks_conductor_tube_plain.png" },
noctr = { "pipeworks_conductor_tube_noctr.png" },
ends = { "pipeworks_conductor_tube_end.png" },
node_def = {
groups = {mesecon = 2},
mesecons = {conductor = {state = "off",
rules = pipeworks.mesecons_rules,
onstate = "pipeworks:conductor_tube_on_#id"}}
},
})
pipeworks.register_tube("pipeworks:conductor_tube_on", {
description = "Conducting Pneumatic Tube Segment on (you hacker you)",
inventory_image = "pipeworks_conductor_tube_inv.png",
short = "pipeworks_conductor_tube_short.png",
plain_textures = { "pipeworks_conductor_tube_on_plain.png" },
noctr = { "pipeworks_conductor_tube_on_noctr.png" },
ends = { "pipeworks_conductor_tube_on_end.png" },
node_def = {
groups = {mesecon = 2, not_in_creative_inventory = 1},
drop = "pipeworks:conductor_tube_off_1",
mesecons = {conductor = {state = "on",
rules = pipeworks.mesecons_rules,
offstate = "pipeworks:conductor_tube_off_#id"}}
},
})
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" }
},
})
end

View File

@ -0,0 +1,144 @@
if pipeworks.enable_mese_tube then
local function update_formspec(pos)
local meta = minetest.get_meta(pos)
local old_formspec = meta:get_string("formspec")
if string.find(old_formspec, "button1") then -- Old version
local inv = meta:get_inventory()
for i = 1, 6 do
for _, stack in ipairs(inv:get_list("line"..i)) do
minetest.item_drop(stack, "", pos)
end
end
end
local buttons_formspec = ""
for i = 0, 5 do
buttons_formspec = buttons_formspec .. fs_helpers.cycling_button(meta,
"image_button[7,"..(i)..";1,1", "l"..(i+1).."s",
{{text="",texture="pipeworks_button_off.png", addopts="false;false;pipeworks_button_interm.png"}, {text="",texture="pipeworks_button_on.png", addopts="false;false;pipeworks_button_interm.png"}})
end
meta:set_string("formspec",
"size[8,11]"..
"list[context;line1;1,0;6,1;]"..
"list[context;line2;1,1;6,1;]"..
"list[context;line3;1,2;6,1;]"..
"list[context;line4;1,3;6,1;]"..
"list[context;line5;1,4;6,1;]"..
"list[context;line6;1,5;6,1;]"..
"image[0,0;1,1;pipeworks_white.png]"..
"image[0,1;1,1;pipeworks_black.png]"..
"image[0,2;1,1;pipeworks_green.png]"..
"image[0,3;1,1;pipeworks_yellow.png]"..
"image[0,4;1,1;pipeworks_blue.png]"..
"image[0,5;1,1;pipeworks_red.png]"..
buttons_formspec..
"list[current_player;main;0,7;8,4;]")
end
pipeworks.register_tube("pipeworks:mese_tube", {
description = "Sorting Pneumatic Tube Segment",
inventory_image = "pipeworks_mese_tube_inv.png",
noctr = {"pipeworks_mese_tube_noctr_1.png", "pipeworks_mese_tube_noctr_2.png", "pipeworks_mese_tube_noctr_3.png",
"pipeworks_mese_tube_noctr_4.png", "pipeworks_mese_tube_noctr_5.png", "pipeworks_mese_tube_noctr_6.png"},
plain = {"pipeworks_mese_tube_plain_1.png", "pipeworks_mese_tube_plain_2.png", "pipeworks_mese_tube_plain_3.png",
"pipeworks_mese_tube_plain_4.png", "pipeworks_mese_tube_plain_5.png", "pipeworks_mese_tube_plain_6.png"},
ends = { "pipeworks_mese_tube_end.png" },
short = "pipeworks_mese_tube_short.png",
no_facedir = true, -- Must use old tubes, since the textures are rotated with 6d ones
node_def = {
tube = {can_go = function(pos, node, velocity, stack)
local tbl, tbln = {}, 0
local found, foundn = {}, 0
local meta = minetest.get_meta(pos)
local inv = meta:get_inventory()
local name = stack:get_name()
for i, vect in ipairs(pipeworks.meseadjlist) do
local npos = vector.add(pos, vect)
local node = minetest.get_node(npos)
local reg_node = minetest.registered_nodes[node.name]
if meta:get_int("l"..i.."s") == 1 and reg_node then
local tube_def = reg_node.tube
if not tube_def or not tube_def.can_insert or
tube_def.can_insert(npos, node, stack, vect) then
local invname = "line"..i
local is_empty = true
for _, st in ipairs(inv:get_list(invname)) do
if not st:is_empty() then
is_empty = false
if st:get_name() == name then
foundn = foundn + 1
found[foundn] = vect
end
end
end
if is_empty then
tbln = tbln + 1
tbl[tbln] = vect
end
end
end
end
return (foundn > 0) and found or tbl
end},
on_construct = function(pos)
local meta = minetest.get_meta(pos)
local inv = meta:get_inventory()
for i = 1, 6 do
meta:set_int("l"..tostring(i).."s", 1)
inv:set_size("line"..tostring(i), 6*1)
end
update_formspec(pos)
meta:set_string("infotext", "Sorting pneumatic tube")
end,
on_punch = update_formspec,
on_receive_fields = function(pos, formname, fields, sender)
fs_helpers.on_receive_fields(pos, fields)
update_formspec(pos)
end,
can_dig = function(pos, player)
update_formspec(pos) -- so non-virtual items would be dropped for old tubes
return true
end,
allow_metadata_inventory_put = function(pos, listname, index, stack, player)
update_formspec(pos) -- For old tubes
local inv = minetest.get_meta(pos):get_inventory()
local stack_copy = ItemStack(stack)
stack_copy:set_count(1)
inv:set_stack(listname, index, stack_copy)
return 0
end,
allow_metadata_inventory_take = function(pos, listname, index, stack, player)
update_formspec(pos) -- For old tubes
local inv = minetest.get_meta(pos):get_inventory()
inv:set_stack(listname, index, ItemStack(""))
return 0
end,
allow_metadata_inventory_move = function(pos, from_list, from_index, to_list, to_index, count, player)
update_formspec(pos) -- For old tubes
local inv = minetest.get_meta(pos):get_inventory()
inv:set_stack(from_list, from_index, ItemStack(""))
return 0
end,
},
})
minetest.register_craft( {
output = "pipeworks:mese_tube_000000 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"
},
})
end

View File

@ -105,112 +105,128 @@ local function get_receivers(pos, channel)
return receivers
end
local teleport_noctr_textures={"pipeworks_teleport_tube_noctr.png","pipeworks_teleport_tube_noctr.png","pipeworks_teleport_tube_noctr.png",
"pipeworks_teleport_tube_noctr.png","pipeworks_teleport_tube_noctr.png","pipeworks_teleport_tube_noctr.png"}
local teleport_plain_textures={"pipeworks_teleport_tube_plain.png","pipeworks_teleport_tube_plain.png","pipeworks_teleport_tube_plain.png",
"pipeworks_teleport_tube_plain.png","pipeworks_teleport_tube_plain.png","pipeworks_teleport_tube_plain.png"}
local teleport_end_textures={"pipeworks_teleport_tube_end.png","pipeworks_teleport_tube_end.png","pipeworks_teleport_tube_end.png",
"pipeworks_teleport_tube_end.png","pipeworks_teleport_tube_end.png","pipeworks_teleport_tube_end.png"}
local teleport_short_texture="pipeworks_teleport_tube_short.png"
local teleport_inv_texture="pipeworks_teleport_tube_inv.png"
local function set_teleport_tube_formspec(meta, can_receive)
local cr = (can_receive ~= 0)
meta:set_string("formspec","size[10.5,1;]"..
"field[0,0.5;7,1;channel;Channel:;${channel}]"..
"button[8,0;2.5,1;"..(cr and "cr0" or "cr1")..";"..
(cr and "Send and Receive" or "Send only").."]")
local function update_meta(meta, can_receive)
meta:set_int("can_receive", can_receive and 1 or 0)
local cr_state = can_receive and "on" or "off"
meta:set_string("formspec","size[8.6,2.2]"..
"field[0.6,0.6;7,1;channel;Channel:;${channel}]"..
"label[7.3,0;Receive]"..
"image_button[7.3,0.3;1,1;pipeworks_button_" .. cr_state .. ".png;cr" .. (can_receive and 0 or 1) .. ";;;false;pipeworks_button_interm.png]"..
"image[0.3,1.3;1,1;pipeworks_teleport_tube_inv.png]"..
"label[1.6,1.2;channels are public by default]" ..
"label[1.6,1.5;use <player>:<channel> for fully private channels]" ..
"label[1.6,1.8;use <player>\\;<channel> for private receivers]" ..
default.gui_bg..
default.gui_bg_img)
end
pipeworks.register_tube("pipeworks:teleport_tube","Teleporting Pneumatic Tube Segment",teleport_plain_textures,
teleport_noctr_textures,teleport_end_textures,teleport_short_texture,teleport_inv_texture, {
is_teleport_tube = true,
tube = {
can_go = function(pos,node,velocity,stack)
velocity.x = 0
velocity.y = 0
velocity.z = 0
pipeworks.register_tube("pipeworks:teleport_tube", {
description = "Teleporting Pneumatic Tube Segment",
inventory_image = "pipeworks_teleport_tube_inv.png",
noctr = { "pipeworks_teleport_tube_noctr.png" },
plain = { "pipeworks_teleport_tube_plain.png" },
ends = { "pipeworks_teleport_tube_end.png" },
short = "pipeworks_teleport_tube_short.png",
node_def = {
is_teleport_tube = true,
tube = {
can_go = function(pos,node,velocity,stack)
velocity.x = 0
velocity.y = 0
velocity.z = 0
local channel = minetest.get_meta(pos):get_string("channel")
if channel == "" then return {} end
local channel = minetest.get_meta(pos):get_string("channel")
if channel == "" then return {} end
local target = get_receivers(pos, channel)
if target[1] == nil then return {} end
local target = get_receivers(pos, channel)
if target[1] == nil then return {} end
local d = math.random(1,#target)
pos.x = target[d].x
pos.y = target[d].y
pos.z = target[d].z
return pipeworks.meseadjlist
end
},
on_construct = function(pos)
local meta = minetest.get_meta(pos)
meta:set_int("can_receive", 1)
set_teleport_tube_formspec(meta, 1)
end,
on_receive_fields = function(pos,formname,fields,sender)
if not fields.channel then
return -- ignore escaping or clientside manipulation of the form
end
local d = math.random(1,#target)
pos.x = target[d].x
pos.y = target[d].y
pos.z = target[d].z
return pipeworks.meseadjlist
end
},
on_construct = function(pos)
local meta = minetest.get_meta(pos)
update_meta(meta, true)
meta:set_string("infotext", "unconfigured Teleportation Tube")
end,
on_receive_fields = function(pos,formname,fields,sender)
if not fields.channel then
return -- ignore escaping or clientside manipulation of the form
end
local new_channel = tostring(fields.channel):trim()
local meta = minetest.get_meta(pos)
local can_receive = meta:get_int("can_receive")
local meta = minetest.get_meta(pos)
local can_receive = meta:get_int("can_receive")
-- check for private channels each time before actually changing anything
-- to not even allow switching between can_receive states of private channels
if fields.channel ~= "" then
local sender_name = sender:get_player_name()
local name, mode = fields.channel:match("^([^:;]+)([:;])")
if name and mode and name ~= sender_name then
--channels starting with '[name]:' can only be used by the named player
if mode == ":" then
minetest.chat_send_player(sender_name, "Sorry, channel '"..fields.channel.."' is reserved for exclusive use by "..name)
return
-- check for private channels each time before actually changing anything
-- to not even allow switching between can_receive states of private channels
if new_channel ~= "" then
local sender_name = sender:get_player_name()
local name, mode = new_channel:match("^([^:;]+)([:;])")
if name and mode and name ~= sender_name then
--channels starting with '[name]:' can only be used by the named player
if mode == ":" then
minetest.chat_send_player(sender_name, "Sorry, channel '"..new_channel.."' is reserved for exclusive use by "..name)
return
--channels starting with '[name];' can be used by other players, but cannot be received from
elseif mode == ";" and (fields.cr1 or (can_receive ~= 0 and not fields.cr0)) then
minetest.chat_send_player(sender_name, "Sorry, receiving from channel '"..fields.channel.."' is reserved for "..name)
return
--channels starting with '[name];' can be used by other players, but cannot be received from
elseif mode == ";" and (fields.cr1 or (can_receive ~= 0 and not fields.cr0)) then
minetest.chat_send_player(sender_name, "Sorry, receiving from channel '"..new_channel.."' is reserved for "..name)
return
end
end
end
end
local dirty = false
local dirty = false
-- test if a can_receive button was pressed
if fields.cr0 and can_receive ~= 0 then
can_receive = 0
meta:set_int("can_receive", can_receive)
dirty = true
elseif fields.cr1 and can_receive ~= 1 then
can_receive = 1
meta:set_int("can_receive", can_receive)
dirty = true
end
-- was the channel changed?
local channel = meta:get_string("channel")
if fields.channel ~= channel then
channel = fields.channel
meta:set_string("channel", channel)
dirty = true
end
-- save if we changed something, handle the empty channel while we're at it
if dirty then
if channel ~= "" then
set_tube(pos, channel, can_receive)
else
-- remove empty channel tubes, to not have to search through them
remove_tube(pos)
-- was the channel changed?
local channel = meta:get_string("channel")
if new_channel ~= channel then
channel = new_channel
meta:set_string("channel", channel)
dirty = true
end
set_teleport_tube_formspec(meta, can_receive)
-- test if a can_receive button was pressed
if fields.cr0 and can_receive ~= 0 then
can_receive = 0
update_meta(meta, false)
dirty = true
elseif fields.cr1 and can_receive ~= 1 then
can_receive = 1
update_meta(meta, true)
dirty = true
end
-- save if we changed something, handle the empty channel while we're at it
if dirty then
if channel ~= "" then
set_tube(pos, channel, can_receive)
local cr_description = (can_receive == 1) and "sending and receiving" or "sending"
meta:set_string("infotext", string.format("Teleportation Tube %s on '%s'", cr_description, channel))
else
-- remove empty channel tubes, to not have to search through them
remove_tube(pos)
meta:set_string("infotext", "unconfigured Teleportation Tube")
end
end
end,
on_destruct = function(pos)
remove_tube(pos)
end
end,
on_destruct = function(pos)
remove_tube(pos)
end
},
})
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" }
},
})
if minetest.get_modpath("mesecons_mvps") ~= nil then

Binary file not shown.

After

Width:  |  Height:  |  Size: 5.6 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.3 KiB

View File

@ -23,7 +23,11 @@ minetest.register_node("pipeworks:trashcan", {
"size[8,7]"..
"item_image[0,0;1,1;pipeworks:trashcan]"..
"label[1,0;Trash Can]"..
"list[current_name;trash;3.5,1;1,1;]"..
"list[context;trash;3.5,1;1,1;]"..
default.gui_bg..
default.gui_bg_img..
default.gui_slots..
default.get_hotbar_bg(0,3) ..
"list[current_player;main;0,3;8,4;]")
meta:set_string("infotext", "Trash Can")
meta:get_inventory():set_size("trash", 1)

View File

@ -0,0 +1,255 @@
-- This file supplies the various kinds of pneumatic tubes
local tubenodes = {}
pipeworks.tubenodes = tubenodes
minetest.register_alias("pipeworks:tube", "pipeworks:tube_000000")
-- now, a function to define the tubes
local REGISTER_COMPATIBILITY = true
local vti = {4, 3, 2, 1, 6, 5}
local default_noctrs = { "pipeworks_tube_noctr.png" }
local default_plain = { "pipeworks_tube_plain.png" }
local default_ends = { "pipeworks_tube_end.png" }
local texture_mt = {
__index = function(table, key)
local size, idx = #table, tonumber(key)
if size > 0 then -- avoid endless loops with empty tables
while idx > size do idx = idx - size end
return table[idx]
end
end
}
local register_one_tube = function(name, tname, dropname, desc, plain, noctrs, ends, short, inv, special, connects, style)
noctrs = noctrs or default_noctrs
setmetatable(noctrs, texture_mt)
plain = plain or default_plain
setmetatable(plain, texture_mt)
ends = ends or default_ends
setmetatable(ends, texture_mt)
short = short or "pipeworks_tube_short.png"
inv = inv or "pipeworks_tube_inv.png"
local outboxes = {}
local outsel = {}
local outimgs = {}
for i = 1, 6 do
outimgs[vti[i]] = plain[i]
end
for _, v in ipairs(connects) do
table.extend(outboxes, pipeworks.tube_boxes[v])
table.insert(outsel, pipeworks.tube_selectboxes[v])
outimgs[vti[v]] = noctrs[v]
end
if #connects == 1 then
local v = connects[1]
v = v-1 + 2*(v%2) -- Opposite side
outimgs[vti[v]] = ends[v]
end
local tgroups = {snappy = 3, tube = 1, tubedevice = 1, not_in_creative_inventory = 1}
local tubedesc = string.format("%s %s... You hacker, you.", desc, dump(connects))
local iimg = plain[1]
local wscale = {x = 1, y = 1, z = 1}
if #connects == 0 then
tgroups = {snappy = 3, tube = 1, tubedevice = 1}
tubedesc = desc
iimg=inv
outimgs = {
short, short,
ends[3],ends[4],
short, short
}
outboxes = { -24/64, -9/64, -9/64, 24/64, 9/64, 9/64 }
outsel = { -24/64, -10/64, -10/64, 24/64, 10/64, 10/64 }
wscale = {x = 1, y = 1, z = 0.01}
end
local rname = string.format("%s_%s", name, tname)
table.insert(tubenodes, rname)
local nodedef = {
description = tubedesc,
drawtype = "nodebox",
tiles = outimgs,
sunlight_propagates = true,
inventory_image = iimg,
wield_image = iimg,
wield_scale = wscale,
paramtype = "light",
selection_box = {
type = "fixed",
fixed = outsel
},
node_box = {
type = "fixed",
fixed = outboxes
},
groups = tgroups,
sounds = default.node_sound_wood_defaults(),
walkable = true,
stack_max = 99,
basename = name,
style = style,
drop = string.format("%s_%s", name, dropname),
tubelike = 1,
tube = {
connect_sides = {front = 1, back = 1, left = 1, right = 1, top = 1, bottom = 1},
priority = 50
},
--[[after_place_node = function(pos)
pipeworks.scan_for_tube_objects(pos)
if minetest.registered_nodes[rname].after_place_node_ then
minetest.registered_nodes[rname].after_place_node_(pos)
end
end,
after_dig_node = function(pos)
pipeworks.scan_for_tube_objects(pos)
if minetest.registered_nodes[rname].after_dig_node_ then
minetest.registered_nodes[rname].after_dig_node_(pos)
end
end]]
}
if style == "6d" then
nodedef.paramtype2 = "facedir"
end
if special == nil then special = {} end
for key, value in pairs(special) do
--if key == "after_dig_node" or key == "after_place_node" then
-- nodedef[key.."_"] = value
if key == "groups" then
for group, val in pairs(value) do
nodedef.groups[group] = val
end
elseif key == "tube" then
for key, val in pairs(value) do
nodedef.tube[key] = val
end
else
nodedef[key] = table.recursive_replace(value, "#id", tname)
end
end
minetest.register_node(rname, nodedef)
end
local register_all_tubes = function(name, desc, plain, noctrs, ends, short, inv, special, old_registration)
if old_registration then
for xm = 0, 1 do
for xp = 0, 1 do
for ym = 0, 1 do
for yp = 0, 1 do
for zm = 0, 1 do
for zp = 0, 1 do
local connects = {}
if xm == 1 then
connects[#connects+1] = 1
end
if xp == 1 then
connects[#connects+1] = 2
end
if ym == 1 then
connects[#connects+1] = 3
end
if yp == 1 then
connects[#connects+1] = 4
end
if zm == 1 then
connects[#connects+1] = 5
end
if zp == 1 then
connects[#connects+1] = 6
end
local tname = xm..xp..ym..yp..zm..zp
register_one_tube(name, tname, "000000", desc, plain, noctrs, ends, short, inv, special, connects, "old")
end
end
end
end
end
end
else
-- 6d tubes: uses only 10 nodes instead of 64, but the textures must be rotated
local cconnects = {{}, {1}, {1, 2}, {1, 3}, {1, 3, 5}, {1, 2, 3}, {1, 2, 3, 5}, {1, 2, 3, 4}, {1, 2, 3, 4, 5}, {1, 2, 3, 4, 5, 6}}
for index, connects in ipairs(cconnects) do
register_one_tube(name, tostring(index), "1", desc, plain, noctrs, ends, short, inv, special, connects, "6d")
end
if REGISTER_COMPATIBILITY then
local cname = name.."_compatibility"
minetest.register_node(cname, {
drawtype = "airlike",
style = "6d",
basename = name,
inventory_image = inv,
wield_image = inv,
paramtype = "light",
sunlight_propagates = true,
description = "Pneumatic tube segment (legacy)",
--[[after_place_node = function(pos)
pipeworks.scan_for_tube_objects(pos)
if minetest.registered_nodes[name.."_1"].after_place_node_ then
minetest.registered_nodes[name.."_1"].after_place_node_(pos)
end
end,]]
groups = {not_in_creative_inventory = 1, tube_to_update = 1, tube = 1},
tube = {connect_sides = {front = 1, back = 1, left = 1, right = 1, top = 1, bottom = 1}},
drop = name.."_1",
})
table.insert(tubenodes, cname)
for xm = 0, 1 do
for xp = 0, 1 do
for ym = 0, 1 do
for yp = 0, 1 do
for zm = 0, 1 do
for zp = 0, 1 do
local tname = xm..xp..ym..yp..zm..zp
minetest.register_alias(name.."_"..tname, cname)
end
end
end
end
end
end
end
end
end
pipeworks.register_tube = function(name, def, ...)
if type(def) == "table" then
register_all_tubes(name, def.description,
def.plain, def.noctr, def.ends, def.short,
def.inventory_image, def.node_def, def.no_facedir)
else
-- we assert to be the old function with the second parameter being the description
-- function(name, desc, plain, noctrs, ends, short, inv, special, old_registration)
assert(type(def) == "string", "invalid arguments to pipeworks.register_tube")
register_all_tubes(name, def, ...)
end
end
if REGISTER_COMPATIBILITY then
minetest.register_abm({
nodenames = {"group:tube_to_update"},
interval = 1,
chance = 1,
action = function(pos, node, active_object_count, active_object_count_wider)
local minp = vector.subtract(pos, 1)
local maxp = vector.add(pos, 1)
if table.getn(minetest.find_nodes_in_area(minp, maxp, "ignore")) == 0 then
pipeworks.scan_for_tube_objects(pos)
end
end
})
end

View File

@ -1,592 +0,0 @@
-- This file supplies the various kinds of pneumatic tubes
pipeworks.tubenodes = {}
minetest.register_alias("pipeworks:tube", "pipeworks:tube_000000")
-- now, a function to define the tubes
local REGISTER_COMPATIBILITY = true
local vti = {4, 3, 2, 1, 6, 5}
local register_one_tube = function(name, tname, dropname, desc, plain, noctrs, ends, short, inv, special, connects, style)
local outboxes = {}
local outsel = {}
local outimgs = {}
for i = 1, 6 do
outimgs[vti[i]] = plain[i]
end
for _, v in ipairs(connects) do
table.extend(outboxes, pipeworks.tube_boxes[v])
table.insert(outsel, pipeworks.tube_selectboxes[v])
outimgs[vti[v]] = noctrs[v]
end
if #connects == 1 then
local v = connects[1]
v = v-1 + 2*(v%2) -- Opposite side
outimgs[vti[v]] = ends[v]
end
local tgroups = {snappy = 3, tube = 1, tubedevice = 1, not_in_creative_inventory = 1}
local tubedesc = desc.." "..dump(connects).."... You hacker, you."
local iimg = plain[1]
local wscale = {x = 1, y = 1, z = 1}
if #connects == 0 then
tgroups = {snappy = 3, tube = 1, tubedevice = 1}
tubedesc = desc
iimg=inv
outimgs = {
short, short,
ends[3],ends[4],
short, short
}
outboxes = { -24/64, -9/64, -9/64, 24/64, 9/64, 9/64 }
outsel = { -24/64, -10/64, -10/64, 24/64, 10/64, 10/64 }
wscale = {x = 1, y = 1, z = 0.01}
end
local rname = name.."_"..tname
table.insert(pipeworks.tubenodes, rname)
local nodedef = {
description = tubedesc,
drawtype = "nodebox",
tiles = outimgs,
sunlight_propagates = true,
inventory_image = iimg,
wield_image = iimg,
wield_scale = wscale,
paramtype = "light",
selection_box = {
type = "fixed",
fixed = outsel
},
node_box = {
type = "fixed",
fixed = outboxes
},
groups = tgroups,
sounds = default.node_sound_wood_defaults(),
walkable = true,
stack_max = 99,
basename = name,
style = style,
drop = name.."_"..dropname,
tubelike = 1,
tube = {
connect_sides = {front = 1, back = 1, left = 1, right = 1, top = 1, bottom = 1},
priority = 50
},
--[[after_place_node = function(pos)
pipeworks.scan_for_tube_objects(pos)
if minetest.registered_nodes[rname].after_place_node_ then
minetest.registered_nodes[rname].after_place_node_(pos)
end
end,
after_dig_node = function(pos)
pipeworks.scan_for_tube_objects(pos)
if minetest.registered_nodes[rname].after_dig_node_ then
minetest.registered_nodes[rname].after_dig_node_(pos)
end
end]]
}
if style == "6d" then
nodedef.paramtype2 = "facedir"
end
if special == nil then special = {} end
for key, value in pairs(special) do
--if key == "after_dig_node" or key == "after_place_node" then
-- nodedef[key.."_"] = value
if key == "groups" then
for group, val in pairs(value) do
nodedef.groups[group] = val
end
elseif key == "tube" then
for key, val in pairs(value) do
nodedef.tube[key] = val
end
else
nodedef[key] = table.recursive_replace(value, "#id", tname)
end
end
minetest.register_node(rname, nodedef)
end
pipeworks.register_tube = function(name, desc, plain, noctrs, ends, short, inv, special, old_registration)
if old_registration then
for xm = 0, 1 do
for xp = 0, 1 do
for ym = 0, 1 do
for yp = 0, 1 do
for zm = 0, 1 do
for zp = 0, 1 do
local connects = {}
if xm == 1 then
connects[#connects+1] = 1
end
if xp == 1 then
connects[#connects+1] = 2
end
if ym == 1 then
connects[#connects+1] = 3
end
if yp == 1 then
connects[#connects+1] = 4
end
if zm == 1 then
connects[#connects+1] = 5
end
if zp == 1 then
connects[#connects+1] = 6
end
local tname = xm..xp..ym..yp..zm..zp
register_one_tube(name, tname, "000000", desc, plain, noctrs, ends, short, inv, special, connects, "old")
end
end
end
end
end
end
else
-- 6d tubes: uses only 10 nodes instead of 64, but the textures must be rotated
local cconnects = {{}, {1}, {1, 2}, {1, 3}, {1, 3, 5}, {1, 2, 3}, {1, 2, 3, 5}, {1, 2, 3, 4}, {1, 2, 3, 4, 5}, {1, 2, 3, 4, 5, 6}}
for index, connects in ipairs(cconnects) do
register_one_tube(name, tostring(index), "1", desc, plain, noctrs, ends, short, inv, special, connects, "6d")
end
if REGISTER_COMPATIBILITY then
local cname = name.."_compatibility"
minetest.register_node(cname, {
drawtype = "airlike",
style = "6d",
basename = name,
inventory_image = inv,
wield_image = inv,
paramtype = "light",
sunlight_propagates = true,
description = "Pneumatic tube segment (legacy)",
--[[after_place_node = function(pos)
pipeworks.scan_for_tube_objects(pos)
if minetest.registered_nodes[name.."_1"].after_place_node_ then
minetest.registered_nodes[name.."_1"].after_place_node_(pos)
end
end,]]
groups = {not_in_creative_inventory = 1, tube_to_update = 1, tube = 1},
tube = {connect_sides = {front = 1, back = 1, left = 1, right = 1, top = 1, bottom = 1}},
drop = name.."_1",
})
table.insert(pipeworks.tubenodes, cname)
for xm = 0, 1 do
for xp = 0, 1 do
for ym = 0, 1 do
for yp = 0, 1 do
for zm = 0, 1 do
for zp = 0, 1 do
local tname = xm..xp..ym..yp..zm..zp
minetest.register_alias(name.."_"..tname, cname)
end
end
end
end
end
end
end
end
end
if REGISTER_COMPATIBILITY then
minetest.register_abm({
nodenames = {"group:tube_to_update"},
interval = 1,
chance = 1,
action = function(pos, node, active_object_count, active_object_count_wider)
local minp = vector.subtract(pos, 1)
local maxp = vector.add(pos, 1)
if table.getn(minetest.find_nodes_in_area(minp, maxp, "ignore")) == 0 then
pipeworks.scan_for_tube_objects(pos)
end
end
})
end
-- now let's actually call that function to get the real work done!
local noctr_textures = {"pipeworks_tube_noctr.png", "pipeworks_tube_noctr.png", "pipeworks_tube_noctr.png",
"pipeworks_tube_noctr.png", "pipeworks_tube_noctr.png", "pipeworks_tube_noctr.png"}
local plain_textures = {"pipeworks_tube_plain.png", "pipeworks_tube_plain.png", "pipeworks_tube_plain.png",
"pipeworks_tube_plain.png", "pipeworks_tube_plain.png", "pipeworks_tube_plain.png"}
local end_textures = {"pipeworks_tube_end.png", "pipeworks_tube_end.png", "pipeworks_tube_end.png",
"pipeworks_tube_end.png", "pipeworks_tube_end.png", "pipeworks_tube_end.png"}
local short_texture = "pipeworks_tube_short.png"
local inv_texture = "pipeworks_tube_inv.png"
pipeworks.register_tube("pipeworks:tube", "Pneumatic tube segment", plain_textures, noctr_textures, end_textures, short_texture, inv_texture)
if pipeworks.enable_mese_tube then
local mese_noctr_textures = {"pipeworks_mese_tube_noctr_1.png", "pipeworks_mese_tube_noctr_2.png", "pipeworks_mese_tube_noctr_3.png",
"pipeworks_mese_tube_noctr_4.png", "pipeworks_mese_tube_noctr_5.png", "pipeworks_mese_tube_noctr_6.png"}
local mese_plain_textures = {"pipeworks_mese_tube_plain_1.png", "pipeworks_mese_tube_plain_2.png", "pipeworks_mese_tube_plain_3.png",
"pipeworks_mese_tube_plain_4.png", "pipeworks_mese_tube_plain_5.png", "pipeworks_mese_tube_plain_6.png"}
local mese_end_textures = {"pipeworks_mese_tube_end.png", "pipeworks_mese_tube_end.png", "pipeworks_mese_tube_end.png",
"pipeworks_mese_tube_end.png", "pipeworks_mese_tube_end.png", "pipeworks_mese_tube_end.png"}
local mese_short_texture = "pipeworks_mese_tube_short.png"
local mese_inv_texture = "pipeworks_mese_tube_inv.png"
local function update_formspec(pos)
local meta = minetest.get_meta(pos)
local old_formspec = meta:get_string("formspec")
if string.find(old_formspec, "button1") then -- Old version
local inv = meta:get_inventory()
for i = 1, 6 do
for _, stack in ipairs(inv:get_list("line"..i)) do
minetest.item_drop(stack, "", pos)
end
end
end
local buttons_formspec = ""
for i = 0, 5 do
buttons_formspec = buttons_formspec .. fs_helpers.cycling_button(meta,
"image_button[7,"..(i)..";1,1", "l"..(i+1).."s",
{{text="",texture="pipeworks_button_off.png"}, {text="",texture="pipeworks_button_on.png"}})
end
meta:set_string("formspec",
"size[8,11]"..
"list[current_name;line1;1,0;6,1;]"..
"list[current_name;line2;1,1;6,1;]"..
"list[current_name;line3;1,2;6,1;]"..
"list[current_name;line4;1,3;6,1;]"..
"list[current_name;line5;1,4;6,1;]"..
"list[current_name;line6;1,5;6,1;]"..
"image[0,0;1,1;pipeworks_white.png]"..
"image[0,1;1,1;pipeworks_black.png]"..
"image[0,2;1,1;pipeworks_green.png]"..
"image[0,3;1,1;pipeworks_yellow.png]"..
"image[0,4;1,1;pipeworks_blue.png]"..
"image[0,5;1,1;pipeworks_red.png]"..
buttons_formspec..
"list[current_player;main;0,7;8,4;]")
end
pipeworks.register_tube("pipeworks:mese_tube", "Sorting Pneumatic Tube Segment", mese_plain_textures, mese_noctr_textures,
mese_end_textures, mese_short_texture, mese_inv_texture,
{tube = {can_go = function(pos, node, velocity, stack)
local tbl, tbln = {}, 0
local found, foundn = {}, 0
local meta = minetest.get_meta(pos)
local inv = meta:get_inventory()
local name = stack:get_name()
for i, vect in ipairs(pipeworks.meseadjlist) do
if meta:get_int("l"..i.."s") == 1 then
local invname = "line"..i
local is_empty = true
for _, st in ipairs(inv:get_list(invname)) do
if not st:is_empty() then
is_empty = false
if st:get_name() == name then
foundn = foundn + 1
found[foundn] = vect
end
end
end
if is_empty then
tbln = tbln + 1
tbl[tbln] = vect
end
end
end
return (foundn > 0) and found or tbl
end},
on_construct = function(pos)
local meta = minetest.get_meta(pos)
local inv = meta:get_inventory()
for i = 1, 6 do
meta:set_int("l"..tostring(i).."s", 1)
inv:set_size("line"..tostring(i), 6*1)
end
update_formspec(pos)
meta:set_string("infotext", "Mese pneumatic tube")
end,
on_punch = update_formspec,
on_receive_fields = function(pos, formname, fields, sender)
fs_helpers.on_receive_fields(pos, fields)
update_formspec(pos)
end,
can_dig = function(pos, player)
update_formspec(pos) -- so non-virtual items would be dropped for old tubes
return true
end,
allow_metadata_inventory_put = function(pos, listname, index, stack, player)
update_formspec(pos) -- For old tubes
local inv = minetest.get_meta(pos):get_inventory()
local stack_copy = ItemStack(stack)
stack_copy:set_count(1)
inv:set_stack(listname, index, stack_copy)
return 0
end,
allow_metadata_inventory_take = function(pos, listname, index, stack, player)
update_formspec(pos) -- For old tubes
local inv = minetest.get_meta(pos):get_inventory()
inv:set_stack(listname, index, ItemStack(""))
return 0
end,
allow_metadata_inventory_move = function(pos, from_list, from_index, to_list, to_index, count, player)
update_formspec(pos) -- For old tubes
local inv = minetest.get_meta(pos):get_inventory()
inv:set_stack(from_list, from_index, ItemStack(""))
return 0
end,
}, true) -- Must use old tubes, since the textures are rotated with 6d ones
end
if pipeworks.enable_detector_tube then
local detector_plain_textures = {"pipeworks_detector_tube_plain.png", "pipeworks_detector_tube_plain.png", "pipeworks_detector_tube_plain.png",
"pipeworks_detector_tube_plain.png", "pipeworks_detector_tube_plain.png", "pipeworks_detector_tube_plain.png"}
local detector_inv_texture = "pipeworks_detector_tube_inv.png"
local detector_tube_step = 2 * tonumber(minetest.setting_get("dedicated_server_step"))
pipeworks.register_tube("pipeworks:detector_tube_on", "Detecting Pneumatic Tube Segment on (you hacker you)", detector_plain_textures, noctr_textures,
end_textures, short_texture, detector_inv_texture,
{tube = {can_go = function(pos, node, velocity, stack)
local meta = minetest.get_meta(pos)
local name = minetest.get_node(pos).name
local nitems = meta:get_int("nitems")+1
meta:set_int("nitems", nitems)
local saved_pos = vector.new(pos)
minetest.after(detector_tube_step, minetest.registered_nodes[name].item_exit, saved_pos)
return pipeworks.notvel(pipeworks.meseadjlist,velocity)
end},
groups = {mesecon = 2, not_in_creative_inventory = 1},
drop = "pipeworks:detector_tube_off_1",
mesecons = {receptor = {state = "on",
rules = pipeworks.mesecons_rules}},
item_exit = function(pos)
local meta = minetest.get_meta(pos)
local nitems = meta:get_int("nitems")-1
local node = minetest.get_node(pos)
local name = node.name
local fdir = node.param2
if nitems == 0 then
minetest.set_node(pos, {name = string.gsub(name, "on", "off"), param2 = fdir})
mesecon.receptor_off(pos, pipeworks.mesecons_rules)
else
meta:set_int("nitems", nitems)
end
end,
on_construct = function(pos)
local meta = minetest.get_meta(pos)
meta:set_int("nitems", 1)
local name = minetest.get_node(pos).name
local saved_pos = vector.new(pos)
minetest.after(detector_tube_step, minetest.registered_nodes[name].item_exit, saved_pos)
end
})
pipeworks.register_tube("pipeworks:detector_tube_off", "Detecting Pneumatic Tube Segment", detector_plain_textures, noctr_textures,
end_textures, short_texture, detector_inv_texture,
{tube = {can_go = function(pos, node, velocity, stack)
local node = minetest.get_node(pos)
local name = node.name
local fdir = node.param2
minetest.set_node(pos,{name = string.gsub(name, "off", "on"), param2 = fdir})
mesecon.receptor_on(pos, pipeworks.mesecons_rules)
return pipeworks.notvel(pipeworks.meseadjlist, velocity)
end},
groups = {mesecon = 2},
mesecons = {receptor = {state = "off",
rules = pipeworks.mesecons_rules}}
})
end
if pipeworks.enable_conductor_tube then
local conductor_plain_textures = {"pipeworks_conductor_tube_plain.png", "pipeworks_conductor_tube_plain.png", "pipeworks_conductor_tube_plain.png",
"pipeworks_conductor_tube_plain.png", "pipeworks_conductor_tube_plain.png", "pipeworks_conductor_tube_plain.png"}
local conductor_noctr_textures = {"pipeworks_conductor_tube_noctr.png", "pipeworks_conductor_tube_noctr.png", "pipeworks_conductor_tube_noctr.png",
"pipeworks_conductor_tube_noctr.png", "pipeworks_conductor_tube_noctr.png", "pipeworks_conductor_tube_noctr.png"}
local conductor_end_textures = {"pipeworks_conductor_tube_end.png", "pipeworks_conductor_tube_end.png", "pipeworks_conductor_tube_end.png",
"pipeworks_conductor_tube_end.png", "pipeworks_conductor_tube_end.png", "pipeworks_conductor_tube_end.png"}
local conductor_short_texture = "pipeworks_conductor_tube_short.png"
local conductor_inv_texture = "pipeworks_conductor_tube_inv.png"
local conductor_on_plain_textures = {"pipeworks_conductor_tube_on_plain.png", "pipeworks_conductor_tube_on_plain.png", "pipeworks_conductor_tube_on_plain.png",
"pipeworks_conductor_tube_on_plain.png", "pipeworks_conductor_tube_on_plain.png", "pipeworks_conductor_tube_on_plain.png"}
local conductor_on_noctr_textures = {"pipeworks_conductor_tube_on_noctr.png", "pipeworks_conductor_tube_on_noctr.png", "pipeworks_conductor_tube_on_noctr.png",
"pipeworks_conductor_tube_on_noctr.png", "pipeworks_conductor_tube_on_noctr.png", "pipeworks_conductor_tube_on_noctr.png"}
local conductor_on_end_textures = {"pipeworks_conductor_tube_on_end.png", "pipeworks_conductor_tube_on_end.png", "pipeworks_conductor_tube_on_end.png",
"pipeworks_conductor_tube_on_end.png", "pipeworks_conductor_tube_on_end.png", "pipeworks_conductor_tube_on_end.png"}
pipeworks.register_tube("pipeworks:conductor_tube_off", "Conducting Pneumatic Tube Segment", conductor_plain_textures, conductor_noctr_textures,
conductor_end_textures, conductor_short_texture, conductor_inv_texture,
{groups = {mesecon = 2},
mesecons = {conductor = {state = "off",
rules = pipeworks.mesecons_rules,
onstate = "pipeworks:conductor_tube_on_#id"}}
})
pipeworks.register_tube("pipeworks:conductor_tube_on", "Conducting Pneumatic Tube Segment on (you hacker you)", conductor_on_plain_textures, conductor_on_noctr_textures,
conductor_on_end_textures, conductor_short_texture, conductor_inv_texture,
{groups = {mesecon = 2, not_in_creative_inventory = 1},
drop = "pipeworks:conductor_tube_off_1",
mesecons = {conductor = {state = "on",
rules = pipeworks.mesecons_rules,
offstate = "pipeworks:conductor_tube_off_#id"}}
})
end
if pipeworks.enable_accelerator_tube then
local accelerator_noctr_textures = {"pipeworks_accelerator_tube_noctr.png", "pipeworks_accelerator_tube_noctr.png", "pipeworks_accelerator_tube_noctr.png",
"pipeworks_accelerator_tube_noctr.png", "pipeworks_accelerator_tube_noctr.png", "pipeworks_accelerator_tube_noctr.png"}
local accelerator_plain_textures = {"pipeworks_accelerator_tube_plain.png" ,"pipeworks_accelerator_tube_plain.png", "pipeworks_accelerator_tube_plain.png",
"pipeworks_accelerator_tube_plain.png", "pipeworks_accelerator_tube_plain.png", "pipeworks_accelerator_tube_plain.png"}
local accelerator_end_textures = {"pipeworks_accelerator_tube_end.png", "pipeworks_accelerator_tube_end.png", "pipeworks_accelerator_tube_end.png",
"pipeworks_accelerator_tube_end.png", "pipeworks_accelerator_tube_end.png", "pipeworks_accelerator_tube_end.png"}
local accelerator_short_texture = "pipeworks_accelerator_tube_short.png"
local accelerator_inv_texture = "pipeworks_accelerator_tube_inv.png"
pipeworks.register_tube("pipeworks:accelerator_tube", "Accelerating Pneumatic Tube Segment", accelerator_plain_textures,
accelerator_noctr_textures, accelerator_end_textures, accelerator_short_texture, accelerator_inv_texture,
{tube = {can_go = function(pos, node, velocity, stack)
velocity.speed = velocity.speed+1
return pipeworks.notvel(pipeworks.meseadjlist, velocity)
end}
})
end
if pipeworks.enable_crossing_tube then
local crossing_noctr_textures = {"pipeworks_crossing_tube_noctr.png", "pipeworks_crossing_tube_noctr.png", "pipeworks_crossing_tube_noctr.png",
"pipeworks_crossing_tube_noctr.png", "pipeworks_crossing_tube_noctr.png", "pipeworks_crossing_tube_noctr.png"}
local crossing_plain_textures = {"pipeworks_crossing_tube_plain.png" ,"pipeworks_crossing_tube_plain.png", "pipeworks_crossing_tube_plain.png",
"pipeworks_crossing_tube_plain.png", "pipeworks_crossing_tube_plain.png", "pipeworks_crossing_tube_plain.png"}
local crossing_end_textures = {"pipeworks_crossing_tube_end.png", "pipeworks_crossing_tube_end.png", "pipeworks_crossing_tube_end.png",
"pipeworks_crossing_tube_end.png", "pipeworks_crossing_tube_end.png", "pipeworks_crossing_tube_end.png"}
local crossing_short_texture = "pipeworks_crossing_tube_short.png"
local crossing_inv_texture = "pipeworks_crossing_tube_inv.png"
pipeworks.register_tube("pipeworks:crossing_tube", "Crossing Pneumatic Tube Segment", crossing_plain_textures,
crossing_noctr_textures, crossing_end_textures, crossing_short_texture, crossing_inv_texture,
{tube = {can_go = function(pos, node, velocity, stack)
return {velocity}
end}
})
end
if pipeworks.enable_sand_tube then
local sand_noctr_textures = {"pipeworks_sand_tube_noctr.png", "pipeworks_sand_tube_noctr.png", "pipeworks_sand_tube_noctr.png",
"pipeworks_sand_tube_noctr.png", "pipeworks_sand_tube_noctr.png", "pipeworks_sand_tube_noctr.png"}
local sand_plain_textures = {"pipeworks_sand_tube_plain.png", "pipeworks_sand_tube_plain.png", "pipeworks_sand_tube_plain.png",
"pipeworks_sand_tube_plain.png", "pipeworks_sand_tube_plain.png", "pipeworks_sand_tube_plain.png"}
local sand_end_textures = {"pipeworks_sand_tube_end.png", "pipeworks_sand_tube_end.png", "pipeworks_sand_tube_end.png",
"pipeworks_sand_tube_end.png", "pipeworks_sand_tube_end.png", "pipeworks_sand_tube_end.png"}
local sand_short_texture = "pipeworks_sand_tube_short.png"
local sand_inv_texture = "pipeworks_sand_tube_inv.png"
pipeworks.register_tube("pipeworks:sand_tube", "Vacuuming Pneumatic Tube Segment", sand_plain_textures, sand_noctr_textures, sand_end_textures,
sand_short_texture, sand_inv_texture,
{groups = {sand_tube = 1}})
minetest.register_abm({nodenames = {"group:sand_tube"},
interval = 1,
chance = 1,
action = function(pos, node, active_object_count, active_object_count_wider)
for _, object in ipairs(minetest.get_objects_inside_radius(pos, 2)) do
if not object:is_player() and object:get_luaentity() and object:get_luaentity().name == "__builtin:item" then
if object:get_luaentity().itemstring ~= "" then
pipeworks.tube_inject_item(pos, pos, vector.new(0, 0, 0), object:get_luaentity().itemstring)
end
object:get_luaentity().itemstring = ""
object:remove()
end
end
end
})
end
if pipeworks.enable_mese_sand_tube then
local mese_sand_noctr_textures = {"pipeworks_mese_sand_tube_noctr.png", "pipeworks_mese_sand_tube_noctr.png", "pipeworks_mese_sand_tube_noctr.png",
"pipeworks_mese_sand_tube_noctr.png", "pipeworks_mese_sand_tube_noctr.png", "pipeworks_mese_sand_tube_noctr.png"}
local mese_sand_plain_textures = {"pipeworks_mese_sand_tube_plain.png", "pipeworks_mese_sand_tube_plain.png", "pipeworks_mese_sand_tube_plain.png",
"pipeworks_mese_sand_tube_plain.png", "pipeworks_mese_sand_tube_plain.png", "pipeworks_mese_sand_tube_plain.png"}
local mese_sand_end_textures = {"pipeworks_mese_sand_tube_end.png", "pipeworks_mese_sand_tube_end.png", "pipeworks_mese_sand_tube_end.png",
"pipeworks_mese_sand_tube_end.png", "pipeworks_mese_sand_tube_end.png", "pipeworks_mese_sand_tube_end.png"}
local mese_sand_short_texture = "pipeworks_mese_sand_tube_short.png"
local mese_sand_inv_texture = "pipeworks_mese_sand_tube_inv.png"
pipeworks.register_tube("pipeworks:mese_sand_tube", "Adjustable Vacuuming Pneumatic Tube Segment", mese_sand_plain_textures, mese_sand_noctr_textures,
mese_sand_end_textures, mese_sand_short_texture,mese_sand_inv_texture,
{groups = {mese_sand_tube = 1},
on_construct = function(pos)
local meta = minetest.get_meta(pos)
meta:set_int("dist", 0)
meta:set_string("formspec",
"size[2,1]"..
"field[.5,.5;1.5,1;dist;distance;${dist}]")
meta:set_string("infotext", "Adjustable Vacuuming Pneumatic Tube Segment")
end,
on_receive_fields = function(pos,formname,fields,sender)
local meta = minetest.get_meta(pos)
local dist
_, dist = pcall(tonumber, fields.dist)
if dist and 0 <= dist and dist <= 8 then meta:set_int("dist", dist) end
end,
})
local function get_objects_with_square_radius(pos, rad)
rad = rad + .5;
local objs = {}
for _,object in ipairs(minetest.get_objects_inside_radius(pos, math.sqrt(3)*rad)) do
if not object:is_player() and object:get_luaentity() and object:get_luaentity().name == "__builtin:item" then
local opos = object:getpos()
if pos.x - rad <= opos.x and opos.x <= pos.x + rad and pos.y - rad <= opos.y and opos.y <= pos.y + rad and pos.z - rad <= opos.z and opos.z <= pos.z + rad then
objs[#objs + 1] = object
end
end
end
return objs
end
minetest.register_abm({nodenames = {"group:mese_sand_tube"},
interval = 1,
chance = 1,
action = function(pos, node, active_object_count, active_object_count_wider)
for _,object in ipairs(get_objects_with_square_radius(pos, minetest.get_meta(pos):get_int("dist"))) do
if not object:is_player() and object:get_luaentity() and object:get_luaentity().name == "__builtin:item" then
if object:get_luaentity().itemstring ~= "" then
pipeworks.tube_inject_item(pos, pos, vector.new(0, 0, 0), object:get_luaentity().itemstring)
end
object:get_luaentity().itemstring = ""
object:remove()
end
end
end
})
end
if pipeworks.enable_one_way_tube then
minetest.register_node("pipeworks:one_way_tube", {
description = "One way tube",
tiles = {"pipeworks_one_way_tube_top.png", "pipeworks_one_way_tube_top.png", "pipeworks_one_way_tube_output.png",
"pipeworks_one_way_tube_input.png", "pipeworks_one_way_tube_side.png", "pipeworks_one_way_tube_top.png"},
paramtype2 = "facedir",
drawtype = "nodebox",
paramtype = "light",
node_box = {type = "fixed",
fixed = {{-1/2, -9/64, -9/64, 1/2, 9/64, 9/64}}},
groups = {snappy = 2, choppy = 2, oddly_breakable_by_hand = 2, tubedevice = 1},
legacy_facedir_simple = true,
sounds = default.node_sound_wood_defaults(),
tube = {
connect_sides = {left = 1, right = 1},
can_go = function(pos, node, velocity, stack)
return {velocity}
end,
can_insert = function(pos, node, stack, direction)
local dir = minetest.facedir_to_right_dir(node.param2)
return vector.equals(dir, direction)
end,
priority = 75 -- Higher than normal tubes, but lower than receivers
},
})
end

View File

@ -0,0 +1,138 @@
if pipeworks.enable_sand_tube then
pipeworks.register_tube("pipeworks:sand_tube", {
description = "Vacuuming Pneumatic Tube Segment",
inventory_image = "pipeworks_sand_tube_inv.png",
short = "pipeworks_sand_tube_short.png",
noctr = { "pipeworks_sand_tube_noctr.png" },
plain = { "pipeworks_sand_tube_plain.png" },
ends = { "pipeworks_sand_tube_end.png" },
node_def = { groups = {vacuum_tube = 1}},
})
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" },
},
})
end
if pipeworks.enable_mese_sand_tube then
pipeworks.register_tube("pipeworks:mese_sand_tube", {
description = "Adjustable Vacuuming Pneumatic Tube Segment",
inventory_image = "pipeworks_mese_sand_tube_inv.png",
short = "pipeworks_mese_sand_tube_short.png",
noctr = { "pipeworks_mese_sand_tube_noctr.png" },
plain = { "pipeworks_mese_sand_tube_plain.png" },
ends = { "pipeworks_mese_sand_tube_end.png" },
node_def = {
groups = {vacuum_tube = 1},
on_construct = function(pos)
local meta = minetest.get_meta(pos)
meta:set_int("dist", 0)
meta:set_string("formspec", "size[2.1,0.8]"..
"image[0,0;1,1;pipeworks_mese_sand_tube_inv.png]"..
"field[1.3,0.4;1,1;dist;radius;${dist}]"..
default.gui_bg..
default.gui_bg_img)
meta:set_string("infotext", "Adjustable Vacuuming Pneumatic Tube Segment")
end,
on_receive_fields = function(pos,formname,fields,sender)
local meta = minetest.get_meta(pos)
local dist = tonumber(fields.dist)
if dist then
dist = math.max(0, dist)
dist = math.min(8, dist)
meta:set_int("dist", dist)
meta:set_string("infotext", ("Adjustable Vacuuming Pneumatic Tube Segment (%dm)"):format(dist))
end
end,
},
})
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( {
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"
},
})
end
local sqrt_3 = math.sqrt(3)
local tube_inject_item = pipeworks.tube_inject_item
local get_objects_inside_radius = minetest.get_objects_inside_radius
local function vacuum(pos, radius)
radius = radius + 0.5
for _, object in pairs(get_objects_inside_radius(pos, sqrt_3 * radius)) do
local lua_entity = object:get_luaentity()
if not object:is_player() and lua_entity and lua_entity.name == "__builtin:item" then
local obj_pos = object:getpos()
local x1, y1, z1 = pos.x, pos.y, pos.z
local x2, y2, z2 = obj_pos.x, obj_pos.y, obj_pos.z
if x1 - radius <= x2 and x2 <= x1 + radius
and y1 - radius <= y2 and y2 <= y1 + radius
and z1 - radius <= z2 and z2 <= z1 + radius then
if lua_entity.itemstring ~= "" then
tube_inject_item(pos, pos, vector.new(0, 0, 0), lua_entity.itemstring)
lua_entity.itemstring = ""
end
object:remove()
end
end
end
end
minetest.register_abm({nodenames = {"group:vacuum_tube"},
interval = 1,
chance = 1,
action = function(pos, node, active_object_count, active_object_count_wider)
if node.name == "pipeworks:sand_tube" then
vacuum(pos, 2)
else
local radius = minetest.get_meta(pos):get_int("dist")
vacuum(pos, radius)
end
end
})

View File

@ -90,7 +90,10 @@ local function wielder_on(data, wielder_pos, wielder_node)
setpos = delay(),
set_hp = delay(),
set_properties = delay(),
set_wielded_item = function(self, item) inv:set_stack(wield_inv_name, wieldindex, item) end,
set_wielded_item = function(self, item)
wieldstack = item
inv:set_stack(wield_inv_name, wieldindex, item)
end,
set_animation = delay(),
set_attach = delay(),
set_detach = delay(),
@ -317,13 +320,14 @@ if pipeworks.enable_node_breaker then
local oldwieldstack = ItemStack(wieldstack)
local on_use = (minetest.registered_items[wieldstack:get_name()] or {}).on_use
if on_use then
virtplayer:set_wielded_item(on_use(wieldstack, virtplayer, pointed_thing) or wieldstack)
wieldstack = on_use(wieldstack, virtplayer, pointed_thing) or wieldstack
virtplayer:set_wielded_item(wieldstack)
else
local under_node = minetest.get_node(pointed_thing.under)
local on_dig = (minetest.registered_nodes[under_node.name] or {on_dig=minetest.node_dig}).on_dig
on_dig(pointed_thing.under, under_node, virtplayer)
wieldstack = virtplayer:get_wielded_item()
end
wieldstack = virtplayer:get_wielded_item()
local wieldname = wieldstack:get_name()
if wieldname == oldwieldstack:get_name() then
-- don't mechanically wear out tool