add the first atvomat machine, the mover

master
Jordach 2017-12-03 17:34:20 +00:00
parent 6deee4f21c
commit bb72704007
27 changed files with 431 additions and 2 deletions

Binary file not shown.

Binary file not shown.

BIN
blends/atvomat_mover.blend Normal file

Binary file not shown.

BIN
blends/atvomat_mover.blend1 Normal file

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

BIN
blends/chest_locked.blend1 Normal file

Binary file not shown.

Binary file not shown.

Binary file not shown.

1
mods/atvomat/depends.txt Normal file
View File

@ -0,0 +1 @@
core

Binary file not shown.

Binary file not shown.

View File

@ -1,3 +1,270 @@
-- avtomat - (automatico, automation)
-- avtomat, mover - (automatico, automation)
-- part of solar plains, by jordach
-- format for registering your own designations for the mover to take items from
--[[
atvomat.mover_input["node:name"] = { -- string, "node:name" is the target to pull items from.
1, -- int, the number of slots to scan for items in. 8*4 is the standard chest size.
"main", -- string, the name of the list to pull items from.
}
]]--
atvomat.mover_input = {}
-- format for registering a output, eg, from mover to insert items into
--[[
atvomat.mover_output["node:name"] = { -- string, "node:name" is the target for pushing items into
"main", -- string, the name of the list to push items into v[1]
"fuel", -- string, the name of the secondary slot for burnable items to be pushed into v[2]
false, -- bool, does the node need a node timer to be started? (example, furnace needs it to start smelting) v[3]
}
]]--
atvomat.mover_output = {}
-- list of burnable shit that has the burntime crap associated with it
--[[
format for burnable shit:
atvomat.mover_burnable["item:name"] = "" -- string, "item:name" is only required, but, in future, this might be different to make life easier
]]--
-- the mover is unlisted for the specfic reason which is what i won't go into, as pairs() may make atvomat first instead of core.
-- todo, automate this to detect anything wsith a burntime?
atvomat.mover_burnable = {}
atvomat.mover_burnable["core:coal_lump"] = ""
-- registration of extractable containers:
atvomat.mover_input["core:chest"] = {
32,
"main"
}
atvomat.mover_input["core:furnace"] = {
4,
"dst"
}
atvomat.mover_input["core:furnace_active"] = {
4,
"dst"
}
-- registration of insertable containers:
atvomat.mover_output["core:chest"] = {
"main",
"main",
false
}
atvomat.mover_output["core:chest_locked"] = {
"main",
"main",
false
}
atvomat.mover_output["core:furnace"] = {
"src",
"fuel",
true
}
atvomat.mover_output["core:furnace_active"] = {
"src",
"fuel",
true
}
local atmover =
"size[8,9]" ..
"list[current_name;main;3.5,2;1,1]" ..
"list[current_player;main;0,4.5;8,1;]" ..
"list[current_player;main;0,6;8,3;8]" ..
"liststring[current_name;main]" ..
"listring[current_player;main]" ..
"background[-0.45,-0.5;8.9,10;atvomat_mover_interface.png]"..
"listcolors[#3a4466;#8b9bb4;#ffffff;#4e5765;#ffffff]"
-- local function show_status(pos, )
-- end
minetest.register_node("atvomat:mover",{
description = "Mover (Moves Items from Red to Green)",
drawtype = "mesh",
mesh = "atvomat_mover.b3d",
paramtype2 = "facedir",
groups = {oddly_breakable_by_hand=3},
paramtype = "light",
tiles = {"atvomat_mover_mesh.png"},
on_construct = function(pos)
local meta = minetest.get_meta(pos)
meta:set_string("formspec", atmover)
local inv = meta:get_inventory()
inv:set_size("main", 1)
minetest.get_node_timer(pos):start(1.0)
end,
on_punch = function(pos)
minetest.get_node_timer(pos):start(1.0)
end,
on_place = minetest.rotate_and_place,
on_timer = function(pos, elapsed)
local fpos = mcore.get_node_from_front(table.copy(pos))
local rpos = mcore.get_node_from_rear(table.copy(pos))
local front_node = minetest.get_node_or_nil(fpos)
local rear_node = minetest.get_node_or_nil(rpos)
local mover_inv = minetest.get_meta(pos):get_inventory()
-- take items from rear first;
for k, v in pairs(atvomat.mover_input) do
if rear_node.name == k then
local inv = minetest.get_meta(rpos):get_inventory()
for i=1, v[1] do
local stack = inv:get_stack(v[2], i)
local stackname = stack:get_name()
if stackname ~= "" then
if mover_inv:room_for_item("main", stackname) then
stack:take_item(1)
mover_inv:add_item("main", stackname)
inv:set_stack(v[2], i, stack)
return true
end
end
end
end
end
-- push items out of the green side; pushing into other movers is considered last in the chain
local moverstack = mover_inv:get_stack("main", 1)
local moverstackname = moverstack:get_name()
for k, v in pairs(atvomat.mover_output) do
if front_node.name == k then
local inv = minetest.get_meta(fpos):get_inventory()
if inv:room_for_item(v[2], moverstackname) and moverstackname == "core:coal_lump" then
moverstack:take_item()
inv:add_item(v[2], moverstackname)
mover_inv:set_stack("main", 1, moverstack)
elseif inv:room_for_item(v[1], moverstackname) then
moverstack:take_item()
inv:add_item(v[1], moverstackname)
mover_inv:set_stack("main", 1, moverstack)
end
if v[3] ~= false then
minetest.get_node_timer(fpos):start(1.0)
end
return true
end
end
if front_node.name == "atvomat:mover" then
local inv = minetest.get_meta(fpos):get_inventory()
if minetest.get_node_timer(fpos):is_started() == false then
minetest.get_node_timer(fpos):start(1.0)
end
if inv:room_for_item("main", moverstackname) then
moverstack:take_item()
inv:add_item("main", moverstackname)
mover_inv:set_stack("main", 1, moverstack)
end
end
return true
end,
})
minetest.register_craft({
output = "atvomat:mover",
recipe = {
{"group:planks", "core:iron_ingot", ""},
{"core:chest", "core:mese_crystal", "core:chest"},
{"group:planks", "core:iron_ingot", ""}
},
})

Binary file not shown.

After

Width:  |  Height:  |  Size: 283 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 219 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 204 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 205 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 786 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 514 B

View File

@ -1,3 +1,50 @@
-- avtomat - (automatico, automation)
-- part of solar plains, by jordach
local rdir = {}
rdir[0] = minetest.dir_to_facedir({x=-1,y= 0,z= 0},true)
rdir[1] = minetest.dir_to_facedir({x= 0,y= 0,z=-1},true)
rdir[2] = minetest.dir_to_facedir({x= 0,y= 1,z= 0},true)
rdir[3] = minetest.dir_to_facedir({x= 0,y=-1,z= 0},true)
rdir[4] = minetest.dir_to_facedir({x= 1,y= 0,z= 0},true)
rdir[5] = minetest.dir_to_facedir({x= 0,y= 0,z= 1},true)
print(dump(rdir[0]))
print(dump(rdir[1]))
print(dump(rdir[2]))
print(dump(rdir[3]))
print(dump(rdir[4]))
print(dump(rdir[5]))
minetest.register_craftitem("atvomat:convincer", {
description = "Engineer's Convincer",
inventory_image = "atvomat_convincer.png",
stack_max = 1,
on_use = function(itemstack, user, pointed_thing)
if pointed_thing.type == "node" then
local node = minetest.get_node(pointed_thing.under)
local fdir = mcore.facedir_stripper(node)
print(fdir)
print(dump(user:get_look_dir()))
if node.name == "atvomat:mover" then
minetest.set_node(pointed_thing.under, {name="atvomat:mover", param2 = minetest.dir_to_facedir(user:get_look_dir(), true) })
end
end
return itemstack
end,
})

View File

@ -918,6 +918,7 @@ minetest.register_node("core:chest", {
meta:set_string("formspec", mcore.chest_formspec)
local inv = meta:get_inventory()
inv:set_size("main", 8*4)
end,
can_dig = function(pos,player)
local meta = minetest.get_meta(pos);

View File

@ -140,4 +140,117 @@ function mob:on_rightclick(clicker)
self.object:set_animation(mob_anim[self.anim_type], 30, 0, false)
end
minetest.register_entity("core:tester", mob)
minetest.register_entity("core:tester", mob)
-- get 3d facedir to simple axis;
-- 0 = y+ 1 = z+ 2 = z- 3 = x+ 4 = x- 5 = y-
function mcore.facedir_stripper(node)
local number = node.param2/4
local chara = tostring(number)
number = tonumber(chara:sub(1,1))
return number
end
function mcore.get_node_from_front(pos)
--pos is the standard pos table provided by minetest, eg: pos = {x=int, y=int, z=int}
local node = minetest.get_node_or_nil(pos)
local facedir = mcore.facedir_stripper(node)
local npos = pos
if facedir == 0 then
npos.y = npos.y + 1
return npos
elseif facedir == 1 then
npos.z = npos.z + 1
return npos
elseif facedir == 2 then
npos.z = npos.z - 1
return npos
elseif facedir == 3 then
npos.x = npos.x + 1
return npos
elseif facedir == 4 then
npos.x = npos.x - 1
return npos
elseif facedir == 5 then
npos.y = npos.y - 1
return npos
end
end
function mcore.get_node_from_rear(pos)
--pos is the standard pos table provided by minetest, eg: pos = {x=int, y=int, z=int}
local node = minetest.get_node_or_nil(pos)
local facedir = mcore.facedir_stripper(node)
local npos = pos
if facedir == 0 then
npos.y = npos.y - 1
return npos
elseif facedir == 1 then
npos.z = npos.z - 1
return npos
elseif facedir == 2 then
npos.z = npos.z + 1
return npos
elseif facedir == 3 then
npos.x = npos.x - 1
return npos
elseif facedir == 4 then
npos.x = npos.x + 1
return npos
elseif facedir == 5 then
npos.y = npos.y + 1
return npos
end
end

Binary file not shown.

Binary file not shown.

Binary file not shown.

Before

Width:  |  Height:  |  Size: 806 B

After

Width:  |  Height:  |  Size: 838 B