Add Mese and Diamese pipes, and fix a few bugs
parent
5e44dd88e1
commit
b884f4baee
|
@ -0,0 +1,73 @@
|
|||
buildtest.pipes.makepipe(function(set, nodes, count, name, id, clas, type)
|
||||
if type=="liquid" then return end
|
||||
local top = "buildtest_pipe_diamond_top.png"
|
||||
local bttm = "buildtest_pipe_diamond_bottem.png"
|
||||
local side = "buildtest_pipe_diamond.png"
|
||||
local def = {
|
||||
sunlight_propagates = true,
|
||||
paramtype = 'light',
|
||||
walkable = true,
|
||||
climbable = false,
|
||||
diggable = true,
|
||||
drawtype = "nodebox",
|
||||
node_box = {
|
||||
type = "fixed",
|
||||
fixed = nodes
|
||||
},
|
||||
--------------------------
|
||||
description = clas.."Buildtest Diamese Pipe",
|
||||
tiles = {top,bttm,side,side,side,side},
|
||||
groups = {choppy=1,oddly_breakable_by_hand=3},
|
||||
buildtest = {
|
||||
slowdown=0.1,
|
||||
pipe=1,
|
||||
connects={
|
||||
buildtest.pipes.defaultPipes
|
||||
},
|
||||
pipe_groups = {
|
||||
type = type,
|
||||
},
|
||||
vconnects={
|
||||
buildtest.pipes.defaultVPipes
|
||||
},
|
||||
},
|
||||
drop = {
|
||||
max_items = 1,
|
||||
items = {
|
||||
{ items = {'buildtest:pipe_diamese_000000_'..id} }
|
||||
}
|
||||
},
|
||||
on_place = function(itemstack, placer, pointed_thing)
|
||||
buildtest.pipes.onp_funct(itemstack, placer, pointed_thing)
|
||||
local meta = minetest.get_meta(pointed_thing.above)
|
||||
--meta:set_string("formspec", buildtest.pipes.diamese.formspec)
|
||||
meta:set_string("infotext", "Diamese Pipe")
|
||||
local inv = meta:get_inventory()
|
||||
--inv:set_size("main", 10*6)
|
||||
for i=1,#buildtest.pipes.types.diamond.colours do
|
||||
local name = buildtest.pipes.types.diamond.colours[i]
|
||||
inv:set_size(name, 10)
|
||||
end
|
||||
end,
|
||||
on_rightclick = function(pos, node, clicker, itemstack)
|
||||
local posname = "nodemeta:"..pos.x..","..pos.y..","..pos.z
|
||||
local formspec = "invsize[11,11;]"
|
||||
--.."list["..posname..";main;1,0;10,6;]"
|
||||
.."list[current_player;main;0,7;8,4;]"
|
||||
for i=1,#buildtest.pipes.types.diamond.colours do
|
||||
local name = buildtest.pipes.types.diamond.colours[i]
|
||||
formspec = formspec.."list["..posname..";"..name..";1,"..(i-1)..";10,1;]label[0,"..(i-1)..";"..name.."]"
|
||||
end
|
||||
minetest.show_formspec(clicker:get_player_name(), "buildtest:pipe_diamese_"..name, formspec)
|
||||
end,
|
||||
on_dig = buildtest.pipes.ond_funct,
|
||||
--------------------------------------------------------------------------------
|
||||
allow_metadata_inventory_put = buildtest.autocraft.allow_metadata_inventory_put(nil), -- {["green"]=1, ["black"]=1, ["red"]=1, ["white"]=1, ["blue"]=1, ["yellow"]=1,}
|
||||
allow_metadata_inventory_take = buildtest.autocraft.allow_metadata_inventory_take(nil),
|
||||
allow_metadata_inventory_move = buildtest.autocraft.allow_metadata_inventory_move(nil, true),
|
||||
}
|
||||
if count~=1 then
|
||||
def.groups.not_in_creative_inventory=1
|
||||
end
|
||||
minetest.register_node("buildtest:pipe_diamese_"..name, def)
|
||||
end)
|
|
@ -91,6 +91,7 @@ buildtest.pipes.makepipe(function(set, nodes, count, name, id, clas, type)
|
|||
end)
|
||||
|
||||
buildtest.pipes.types.diamond.getDir = function(pos,cargo)
|
||||
if cargo==nil or cargo.name==nil then return nil end
|
||||
local inv = minetest.get_meta(pos):get_inventory()
|
||||
for i=1,#buildtest.pipes.types.diamond.colours do
|
||||
local name = buildtest.pipes.types.diamond.colours[i]
|
||||
|
|
|
@ -12,7 +12,7 @@ buildtest.pipes.makepipe(function(set, nodes, count, name, id, clas, type)
|
|||
fixed = nodes
|
||||
},
|
||||
--------------------------
|
||||
description = clas.."Buildtest Emeriald Pipe",
|
||||
description = clas.."Buildtest Emerald Pipe",
|
||||
tiles = {"buildtest_pipe_emr.png"},
|
||||
groups = {choppy=1,oddly_breakable_by_hand=3},
|
||||
buildtest = {
|
||||
|
|
|
@ -0,0 +1,64 @@
|
|||
--buildtest.pipes.types.cobble = {
|
||||
-- base = "default:cobble",
|
||||
--}
|
||||
|
||||
buildtest.pipes.makepipe(function(set, nodes, count, name, id, clas, type, toverlay)
|
||||
local def = {
|
||||
sunlight_propagates = true,
|
||||
paramtype = 'light',
|
||||
walkable = true,
|
||||
climbable = false,
|
||||
diggable = true,
|
||||
drawtype = "nodebox",
|
||||
node_box = {
|
||||
type = "fixed",
|
||||
fixed = nodes
|
||||
},
|
||||
--------------------------
|
||||
description = clas.."Buildtest Mese Pipe",
|
||||
tiles = {"buildtest_pipe_mese.png"..toverlay},
|
||||
groups = {choppy=1,oddly_breakable_by_hand=3},
|
||||
buildtest = {
|
||||
slowdown=0.1,
|
||||
pipe=1,
|
||||
connects={
|
||||
buildtest.pipes.defaultPipes
|
||||
},
|
||||
pipe_groups = {
|
||||
type = type,
|
||||
},
|
||||
vconnects={
|
||||
buildtest.pipes.defaultVPipes
|
||||
},
|
||||
},
|
||||
drop = {
|
||||
max_items = 1,
|
||||
items = {
|
||||
{ items = {'buildtest:pipe_mese_000000_'..id} }
|
||||
}
|
||||
},
|
||||
on_place = function(itemstack, placer, pointed_thing)
|
||||
buildtest.pipes.onp_funct(itemstack, placer, pointed_thing)
|
||||
local meta = minetest.get_meta(pointed_thing.above)
|
||||
meta:set_string("infotext", "Mese Pipe")
|
||||
local inv = meta:get_inventory()
|
||||
inv:set_size("main", 1)
|
||||
end,
|
||||
on_rightclick = function(pos, node, clicker, itemstack)
|
||||
local posname = "nodemeta:"..pos.x..","..pos.y..","..pos.z
|
||||
local formspec = "size[8,6]"..
|
||||
"list["..posname..";main;0,0;1,1;]"..
|
||||
"list[current_player;main;0,2;8,4;]"
|
||||
minetest.show_formspec(clicker:get_player_name(), "buildtest:pipe_mese_"..name, formspec)
|
||||
end,
|
||||
on_dig = buildtest.pipes.ond_funct,
|
||||
------------------------------------------------
|
||||
allow_metadata_inventory_put = buildtest.autocraft.allow_metadata_inventory_put(nil),
|
||||
allow_metadata_inventory_take = buildtest.autocraft.allow_metadata_inventory_take(nil),
|
||||
allow_metadata_inventory_move = buildtest.autocraft.allow_metadata_inventory_move(nil, true),
|
||||
}
|
||||
if count~=1 then
|
||||
def.groups.not_in_creative_inventory=1
|
||||
end
|
||||
minetest.register_node("buildtest:pipe_mese_"..name, def)
|
||||
end)
|
|
@ -276,10 +276,12 @@ buildtest.pipes.defaultPipes = {
|
|||
"buildtest:pipe_sandstone",
|
||||
"buildtest:pipe_obsidian",
|
||||
"buildtest:pipe_diamond",
|
||||
"buildtest:pipe_diamese",
|
||||
"buildtest:pipe_stripe",
|
||||
"buildtest:pipe_cobble",
|
||||
"buildtest:pipe_stone",
|
||||
"buildtest:pipe_iron",
|
||||
"buildtest:pipe_mese",
|
||||
"buildtest:pipe_gold",
|
||||
"buildtest:pipe_gate",
|
||||
--"buildtest:pipe_emr",
|
||||
|
|
|
@ -9,4 +9,7 @@ dofile(minetest.get_modpath("buildtest").."/pipes/sandstone.lua")
|
|||
dofile(minetest.get_modpath("buildtest").."/pipes/emriald.lua")
|
||||
dofile(minetest.get_modpath("buildtest").."/pipes/gate.lua")
|
||||
dofile(minetest.get_modpath("buildtest").."/pipes/stripe.lua")
|
||||
dofile(minetest.get_modpath("buildtest").."/pipes/mesecon.lua")
|
||||
dofile(minetest.get_modpath("buildtest").."/pipes/mesecon.lua")
|
||||
|
||||
dofile(minetest.get_modpath("buildtest").."/pipes/diamese.lua")
|
||||
dofile(minetest.get_modpath("buildtest").."/pipes/mese.lua")
|
|
@ -74,6 +74,7 @@ buildtest.pumps.send_power = function(pipepos, speed, movecount)
|
|||
local tosend = nil
|
||||
local pipeinv = minetest.get_meta(pipepos):get_inventory()
|
||||
local listname = buildtest.pumps.pulls[minetest.get_node(chestpos).name][1]
|
||||
local numitems = 1
|
||||
---------------------------------
|
||||
for i=1, inv:get_size(listname) do
|
||||
local cell = inv:get_stack(listname, i):to_table()
|
||||
|
@ -83,14 +84,21 @@ buildtest.pumps.send_power = function(pipepos, speed, movecount)
|
|||
movecount)
|
||||
|
||||
tosend=ItemStack(cell):to_table()
|
||||
tosend.count = move
|
||||
tosend.count = 1
|
||||
numitems = move
|
||||
cell.count = cell.count - move
|
||||
inv:set_stack(listname, i, cell)
|
||||
end
|
||||
end
|
||||
end
|
||||
if tosend==nil then return end
|
||||
local entity = buildtest.makeEnt(pipepos, tosend, speed, chestpos)
|
||||
local tbetween = 0.5 * (#buildtest.pumps.colours + 1 - speed) / numitems
|
||||
for i=1, numitems do
|
||||
minetest.after(tbetween * i, function()
|
||||
print(tbetween * i)
|
||||
local entity = buildtest.makeEnt(pipepos, tosend, speed, chestpos)
|
||||
end)
|
||||
end
|
||||
-- if entity then
|
||||
-- entity:setpos(chestpos)
|
||||
-- entity:setvelocity({x=0, y=0-speed, z=0})
|
||||
|
@ -231,7 +239,14 @@ buildtest.pumps.register_pump = function(name, textureBase, flags, def)
|
|||
-- }},
|
||||
}
|
||||
for name, val in pairs(flags) do
|
||||
def[name] = val
|
||||
if name~="groups" then
|
||||
def[name] = val
|
||||
end
|
||||
end
|
||||
if flags.groups~=nil then
|
||||
for name, val in pairs(flags.groups) do
|
||||
def.groups[name]=val
|
||||
end
|
||||
end
|
||||
if typeId~=1 then
|
||||
def.groups.not_in_creative_inventory=1
|
||||
|
|
|
@ -117,6 +117,18 @@ minetest.register_entity("buildtest:entity_flat", {
|
|||
end
|
||||
end
|
||||
|
||||
if strs:starts(posname, "buildtest:pipe_diamese_") then
|
||||
newDir = buildtest.pipes.types.diamond.getDir(self.nextpos, self.code)
|
||||
if newDir==nil then
|
||||
for i=1,6 do
|
||||
local tmpPos=buildtest.posADD(pos,buildtest.toXY(i))
|
||||
if strs:starts(minetest.get_node(tmpPos).name, "buildtest:pipe_gold")==true then
|
||||
newDir = buildtest.toXY(i)
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
if strs:starts(posname, "buildtest:pipe_stripe_") then
|
||||
local targetPos = self.addpos(self.object:getpos(), self.olddir)
|
||||
if minetest.get_node(targetPos).name == "air"
|
||||
|
@ -128,6 +140,12 @@ minetest.register_entity("buildtest:entity_flat", {
|
|||
end
|
||||
end
|
||||
|
||||
if strs:starts(posname, "buildtest:pipe_mese_") then
|
||||
local meta = minetest.get_meta(self.nextpos)
|
||||
local inv = meta:get_inventory()
|
||||
self.code = inv:get_stack("main", 1):to_table()
|
||||
end
|
||||
|
||||
if strs:starts(posname, "buildtest:pipe_gate") then
|
||||
local getRunAction = buildtest.pipes.types.gate.types[posname].getRunAction(self.nextpos).entProcess(self.content)
|
||||
end
|
||||
|
@ -278,6 +296,7 @@ minetest.register_entity("buildtest:entity_flat", {
|
|||
self.content,
|
||||
self.speed,
|
||||
self.direction,
|
||||
self.code,
|
||||
})
|
||||
end,
|
||||
|
||||
|
@ -302,4 +321,5 @@ minetest.register_entity("buildtest:entity_flat", {
|
|||
content={name="default:dirt",count=0},
|
||||
speed = 1,
|
||||
direction = {x=0,y=0,z=0},
|
||||
code = {},
|
||||
})
|
Loading…
Reference in New Issue