funnel added, gravel sieve adapter
@ -27,6 +27,10 @@ local STANDBY_TICKS = 10
|
|||||||
local COUNTDOWN_TICKS = 10
|
local COUNTDOWN_TICKS = 10
|
||||||
local CYCLE_TIME = 4
|
local CYCLE_TIME = 4
|
||||||
|
|
||||||
|
local get_random_gravel_ore = techage.gravelsieve_get_random_gravel_ore
|
||||||
|
local get_random_basalt_ore = techage.gravelsieve_get_random_basalt_ore
|
||||||
|
|
||||||
|
|
||||||
local function formspec(self, pos, mem)
|
local function formspec(self, pos, mem)
|
||||||
return "size[8,8]"..
|
return "size[8,8]"..
|
||||||
default.gui_bg..
|
default.gui_bg..
|
||||||
@ -74,33 +78,6 @@ local function allow_metadata_inventory_take(pos, listname, index, stack, player
|
|||||||
return stack:get_count()
|
return stack:get_count()
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
-- determine ore based on the calculated probability
|
|
||||||
local function get_random_gravel_ore()
|
|
||||||
for ore, probability in pairs(techage.ore_probability) do
|
|
||||||
if math.random(probability) == 1 then
|
|
||||||
return ItemStack(ore)
|
|
||||||
end
|
|
||||||
end
|
|
||||||
if math.random(2) == 1 then
|
|
||||||
return ItemStack("default:gravel")
|
|
||||||
else
|
|
||||||
return ItemStack("techage:sieved_gravel")
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
local function get_random_basalt_ore()
|
|
||||||
if math.random(40) == 1 then
|
|
||||||
return ItemStack("default:coal_lump")
|
|
||||||
elseif math.random(40) == 1 then
|
|
||||||
return ItemStack("default:iron_lump")
|
|
||||||
elseif math.random(2) == 1 then
|
|
||||||
return ItemStack("techage:basalt_gravel")
|
|
||||||
else
|
|
||||||
return ItemStack("techage:sieved_basalt_gravel")
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
local function sieving(pos, trd, mem, inv)
|
local function sieving(pos, trd, mem, inv)
|
||||||
local src, dst
|
local src, dst
|
||||||
if inv:contains_item("src", ItemStack("techage:basalt_gravel")) then
|
if inv:contains_item("src", ItemStack("techage:basalt_gravel")) then
|
||||||
|
83
basis/gravel_lib.lua
Normal file
@ -0,0 +1,83 @@
|
|||||||
|
--[[
|
||||||
|
|
||||||
|
TechAge
|
||||||
|
=======
|
||||||
|
|
||||||
|
Copyright (C) 2019 Joachim Stolberg
|
||||||
|
|
||||||
|
LGPLv2.1+
|
||||||
|
See LICENSE.txt for more information
|
||||||
|
|
||||||
|
Gravel Sieve basis functions
|
||||||
|
|
||||||
|
]]--
|
||||||
|
|
||||||
|
-- Increase the probability over the natural occurrence
|
||||||
|
local PROBABILITY_FACTOR = 2
|
||||||
|
|
||||||
|
-- Ore probability table (1/n)
|
||||||
|
local ore_probability = {
|
||||||
|
}
|
||||||
|
|
||||||
|
-- collect all registered ores and calculate the probability
|
||||||
|
local function add_ores()
|
||||||
|
for _,item in pairs(minetest.registered_ores) do
|
||||||
|
if minetest.registered_nodes[item.ore] then
|
||||||
|
local drop = minetest.registered_nodes[item.ore].drop
|
||||||
|
if type(drop) == "string"
|
||||||
|
and drop ~= item.ore
|
||||||
|
and drop ~= ""
|
||||||
|
and item.ore_type == "scatter"
|
||||||
|
and item.wherein == "default:stone"
|
||||||
|
and item.clust_scarcity ~= nil and item.clust_scarcity > 0
|
||||||
|
and item.clust_num_ores ~= nil and item.clust_num_ores > 0
|
||||||
|
and item.y_max ~= nil and item.y_min ~= nil then
|
||||||
|
local probability = (techage.ore_rarity / PROBABILITY_FACTOR) * item.clust_scarcity /
|
||||||
|
(item.clust_num_ores * ((item.y_max - item.y_min) / 65535))
|
||||||
|
if ore_probability[drop] == nil then
|
||||||
|
ore_probability[drop] = probability
|
||||||
|
else
|
||||||
|
-- harmonic sum
|
||||||
|
ore_probability[drop] = 1.0 / ((1.0 / ore_probability[drop]) +
|
||||||
|
(1.0 / probability))
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
local overall_probability = 0.0
|
||||||
|
for name,probability in pairs(ore_probability) do
|
||||||
|
minetest.log("info", string.format("[techage] %-32s %u", name, probability))
|
||||||
|
overall_probability = overall_probability + 1.0/probability
|
||||||
|
end
|
||||||
|
minetest.log("info", string.format("[techage] Overall probability %g", overall_probability))
|
||||||
|
end
|
||||||
|
|
||||||
|
minetest.after(1, add_ores)
|
||||||
|
|
||||||
|
|
||||||
|
-- determine ore based on the calculated probability
|
||||||
|
function techage.gravelsieve_get_random_gravel_ore()
|
||||||
|
for ore, probability in pairs(ore_probability) do
|
||||||
|
if math.random(probability) == 1 then
|
||||||
|
return ItemStack(ore)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
if math.random(2) == 1 then
|
||||||
|
return ItemStack("default:gravel")
|
||||||
|
else
|
||||||
|
return ItemStack("techage:sieved_gravel")
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
function techage.gravelsieve_get_random_basalt_ore()
|
||||||
|
if math.random(40) == 1 then
|
||||||
|
return ItemStack("default:coal_lump")
|
||||||
|
elseif math.random(40) == 1 then
|
||||||
|
return ItemStack("default:iron_lump")
|
||||||
|
elseif math.random(2) == 1 then
|
||||||
|
return ItemStack("techage:basalt_gravel")
|
||||||
|
else
|
||||||
|
return ItemStack("techage:sieved_basalt_gravel")
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
2
init.lua
@ -22,6 +22,7 @@ else
|
|||||||
|
|
||||||
-- Basis features
|
-- Basis features
|
||||||
dofile(MP.."/basis/lib.lua") -- helper functions
|
dofile(MP.."/basis/lib.lua") -- helper functions
|
||||||
|
dofile(MP.."/basis/gravel_lib.lua") -- ore probability
|
||||||
dofile(MP.."/basis/guide.lua") -- construction guide
|
dofile(MP.."/basis/guide.lua") -- construction guide
|
||||||
dofile(MP.."/basis/power.lua") -- power distribution
|
dofile(MP.."/basis/power.lua") -- power distribution
|
||||||
dofile(MP.."/basis/node_states.lua") -- state model
|
dofile(MP.."/basis/node_states.lua") -- state model
|
||||||
@ -44,6 +45,7 @@ else
|
|||||||
-- Iron Age
|
-- Iron Age
|
||||||
dofile(MP.."/iron_age/main.lua")
|
dofile(MP.."/iron_age/main.lua")
|
||||||
dofile(MP.."/iron_age/gravelsieve.lua")
|
dofile(MP.."/iron_age/gravelsieve.lua")
|
||||||
|
dofile(MP.."/iron_age/funnel.lua")
|
||||||
dofile(MP.."/iron_age/hammer.lua")
|
dofile(MP.."/iron_age/hammer.lua")
|
||||||
dofile(MP.."/iron_age/lighter.lua")
|
dofile(MP.."/iron_age/lighter.lua")
|
||||||
dofile(MP.."/iron_age/charcoalpile.lua")
|
dofile(MP.."/iron_age/charcoalpile.lua")
|
||||||
|
140
iron_age/funnel.lua
Normal file
@ -0,0 +1,140 @@
|
|||||||
|
--[[
|
||||||
|
|
||||||
|
TechAge
|
||||||
|
=======
|
||||||
|
|
||||||
|
Copyright (C) 2019 Joachim Stolberg
|
||||||
|
|
||||||
|
LGPLv2.1+
|
||||||
|
See LICENSE.txt for more information
|
||||||
|
|
||||||
|
Simple TA1 Funnel
|
||||||
|
|
||||||
|
]]--
|
||||||
|
|
||||||
|
-- for lazy programmers
|
||||||
|
local S = function(pos) if pos then return minetest.pos_to_string(pos) end end
|
||||||
|
local P = minetest.string_to_pos
|
||||||
|
local M = minetest.get_meta
|
||||||
|
|
||||||
|
-- Load support for intllib.
|
||||||
|
local MP = minetest.get_modpath("techage")
|
||||||
|
local I,_ = dofile(MP.."/intllib.lua")
|
||||||
|
|
||||||
|
local function scan_for_objects(pos, inv)
|
||||||
|
for _, object in pairs(minetest.get_objects_inside_radius(pos, 1)) do
|
||||||
|
local lua_entity = object:get_luaentity()
|
||||||
|
if not object:is_player() and lua_entity and lua_entity.name == "__builtin:item" then
|
||||||
|
if lua_entity.itemstring ~= "" then
|
||||||
|
local stack = ItemStack(lua_entity.itemstring)
|
||||||
|
if inv:room_for_item("main", stack) then
|
||||||
|
inv:add_item("main", stack)
|
||||||
|
object:remove()
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
local function push_item(pos, inv, meta)
|
||||||
|
if not inv:is_empty("main") then
|
||||||
|
local stack = inv:get_stack("main", 1)
|
||||||
|
local taken = stack:take_item(1)
|
||||||
|
if techage.push_items(pos, meta:get_int("push_dir"), taken) then
|
||||||
|
inv:set_stack("main", 1, stack)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
local function node_timer(pos, elapsed)
|
||||||
|
local meta = minetest.get_meta(pos)
|
||||||
|
local inv = meta:get_inventory()
|
||||||
|
if inv then
|
||||||
|
scan_for_objects(pos, inv)
|
||||||
|
push_item(pos, inv, meta)
|
||||||
|
end
|
||||||
|
return true
|
||||||
|
end
|
||||||
|
|
||||||
|
minetest.register_node("techage:funnel_ta1", {
|
||||||
|
description = I("TA1 Funnel"),
|
||||||
|
tiles = {
|
||||||
|
-- up, down, right, left, back, front
|
||||||
|
"default_cobble.png^techage_appl_funnel_top.png",
|
||||||
|
"default_cobble.png^techage_appl_funnel.png",
|
||||||
|
"default_cobble.png^techage_appl_funnel_right.png",
|
||||||
|
"default_cobble.png^techage_appl_funnel.png",
|
||||||
|
"default_cobble.png^techage_appl_funnel.png",
|
||||||
|
"default_cobble.png^techage_appl_funnel.png",
|
||||||
|
},
|
||||||
|
|
||||||
|
drawtype = "nodebox",
|
||||||
|
node_box = {
|
||||||
|
type = "fixed",
|
||||||
|
fixed = {
|
||||||
|
{-8/16, 2/16, -8/16, 8/16, 8/16, -6/16},
|
||||||
|
{-8/16, 2/16, 6/16, 8/16, 8/16, 8/16},
|
||||||
|
{-8/16, 2/16, -8/16, -6/16, 8/16, 8/16},
|
||||||
|
{ 6/16, 2/16, -8/16, 8/16, 8/16, 8/16},
|
||||||
|
{-6/16, 0/16, -6/16, 6/16, 3/16, 6/16},
|
||||||
|
{-5/16, -4/16, -5/16, 5/16, 0/16, 5/16},
|
||||||
|
{ 0/16, -4/16, -3/16, 11/16, 2/16, 3/16},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
selection_box = {
|
||||||
|
type = "fixed",
|
||||||
|
fixed = {
|
||||||
|
{-8/16, 2/16, -8/16, 8/16, 8/16, 8/16},
|
||||||
|
{-5/16, -4/16, -5/16, 5/16, 0/16, 5/16},
|
||||||
|
{ 0/16, -4/16, -3/16, 11/16, 2/16, 3/16},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
|
||||||
|
on_construct = function(pos)
|
||||||
|
local meta = minetest.get_meta(pos)
|
||||||
|
local inv = meta:get_inventory()
|
||||||
|
inv:set_size('main', 1)
|
||||||
|
end,
|
||||||
|
|
||||||
|
after_place_node = function(pos, placer)
|
||||||
|
techage.add_node(pos, "techage:funnel_ta1")
|
||||||
|
local node = minetest.get_node(pos)
|
||||||
|
M(pos):set_int("push_dir", techage.side_to_indir("L", node.param2))
|
||||||
|
minetest.get_node_timer(pos):start(2)
|
||||||
|
end,
|
||||||
|
|
||||||
|
on_timer = node_timer,
|
||||||
|
|
||||||
|
after_dig_node = function(pos, oldnode, oldmetadata, digger)
|
||||||
|
techage.remove_node(pos)
|
||||||
|
end,
|
||||||
|
|
||||||
|
on_rotate = screwdriver.disallow,
|
||||||
|
paramtype = "light",
|
||||||
|
sunlight_propagates = true,
|
||||||
|
paramtype2 = "facedir",
|
||||||
|
groups = {choppy=2, cracky=2, crumbly=2},
|
||||||
|
is_ground_content = false,
|
||||||
|
sounds = default.node_sound_wood_defaults(),
|
||||||
|
})
|
||||||
|
|
||||||
|
|
||||||
|
--minetest.register_craft({
|
||||||
|
-- output = "techage:funnel_ta1",
|
||||||
|
-- recipe = {
|
||||||
|
-- {"group:wood", "", "group:wood"},
|
||||||
|
-- {"default:steel_ingot", "default:mese_crystal", "tubelib:tubeS"},
|
||||||
|
-- {"group:wood", "", "group:wood"},
|
||||||
|
-- },
|
||||||
|
--})
|
||||||
|
|
||||||
|
techage.register_node("techage:funnel_ta1", {}, {
|
||||||
|
on_pull_item = nil, -- not needed
|
||||||
|
on_unpull_item = nil, -- not needed
|
||||||
|
|
||||||
|
on_push_item = function(pos, in_dir, stack)
|
||||||
|
local meta = minetest.get_meta(pos)
|
||||||
|
local inv = meta:get_inventory()
|
||||||
|
return techage.put_items(inv, "main", stack)
|
||||||
|
end,
|
||||||
|
})
|
@ -16,303 +16,142 @@
|
|||||||
local S = function(pos) if pos then return minetest.pos_to_string(pos) end end
|
local S = function(pos) if pos then return minetest.pos_to_string(pos) end end
|
||||||
local P = minetest.string_to_pos
|
local P = minetest.string_to_pos
|
||||||
local M = minetest.get_meta
|
local M = minetest.get_meta
|
||||||
-- Techage Related Data
|
|
||||||
local TRD = function(pos) return (minetest.registered_nodes[minetest.get_node(pos).name] or {}).techage end
|
|
||||||
|
|
||||||
-- Load support for intllib.
|
-- Load support for intllib.
|
||||||
local MP = minetest.get_modpath("techage")
|
local MP = minetest.get_modpath("techage")
|
||||||
local I,_ = dofile(MP.."/intllib.lua")
|
local I,_ = dofile(MP.."/intllib.lua")
|
||||||
|
|
||||||
-- Increase the probability over the natural occurrence
|
local get_random_gravel_ore = techage.gravelsieve_get_random_gravel_ore
|
||||||
local PROBABILITY_FACTOR = 3
|
local get_random_basalt_ore = techage.gravelsieve_get_random_basalt_ore
|
||||||
|
|
||||||
-- Ore probability table (1/n)
|
|
||||||
techage.ore_probability = {
|
|
||||||
}
|
|
||||||
|
|
||||||
-- collect all registered ores and calculate the probability
|
|
||||||
local function add_ores()
|
|
||||||
for _,item in pairs(minetest.registered_ores) do
|
|
||||||
if minetest.registered_nodes[item.ore] then
|
|
||||||
local drop = minetest.registered_nodes[item.ore].drop
|
|
||||||
if type(drop) == "string"
|
|
||||||
and drop ~= item.ore
|
|
||||||
and drop ~= ""
|
|
||||||
and item.ore_type == "scatter"
|
|
||||||
and item.wherein == "default:stone"
|
|
||||||
and item.clust_scarcity ~= nil and item.clust_scarcity > 0
|
|
||||||
and item.clust_num_ores ~= nil and item.clust_num_ores > 0
|
|
||||||
and item.y_max ~= nil and item.y_min ~= nil then
|
|
||||||
local probability = (techage.ore_rarity / PROBABILITY_FACTOR) * item.clust_scarcity /
|
|
||||||
(item.clust_num_ores * ((item.y_max - item.y_min) / 65535))
|
|
||||||
if techage.ore_probability[drop] == nil then
|
|
||||||
techage.ore_probability[drop] = probability
|
|
||||||
else
|
|
||||||
-- harmonic sum
|
|
||||||
techage.ore_probability[drop] = 1.0 / ((1.0 / techage.ore_probability[drop]) +
|
|
||||||
(1.0 / probability))
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
|
||||||
local overall_probability = 0.0
|
|
||||||
for name,probability in pairs(techage.ore_probability) do
|
|
||||||
minetest.log("info", string.format("[techage] %-32s %u", name, probability))
|
|
||||||
overall_probability = overall_probability + 1.0/probability
|
|
||||||
end
|
|
||||||
minetest.log("info", string.format("[techage] Overall probability %g", overall_probability))
|
|
||||||
end
|
|
||||||
|
|
||||||
minetest.after(1, add_ores)
|
|
||||||
|
|
||||||
local sieve_formspec =
|
|
||||||
"size[8,8]"..
|
|
||||||
default.gui_bg..
|
|
||||||
default.gui_bg_img..
|
|
||||||
default.gui_slots..
|
|
||||||
"list[context;src;1,1.5;1,1;]"..
|
|
||||||
"image[3,1.5;1,1;techage_form_arrow.png]"..
|
|
||||||
"list[context;dst;4,0;4,4;]"..
|
|
||||||
"list[current_player;main;0,4.2;8,4;]"..
|
|
||||||
"listring[context;dst]"..
|
|
||||||
"listring[current_player;main]"..
|
|
||||||
"listring[context;src]"..
|
|
||||||
"listring[current_player;main]"
|
|
||||||
|
|
||||||
|
|
||||||
local function allow_metadata_inventory_put(pos, listname, index, stack, player)
|
|
||||||
if minetest.is_protected(pos, player:get_player_name()) then
|
|
||||||
return 0
|
|
||||||
end
|
|
||||||
local meta = minetest.get_meta(pos)
|
|
||||||
local inv = meta:get_inventory()
|
|
||||||
if listname == "src" then
|
|
||||||
return stack:get_count()
|
|
||||||
elseif listname == "dst" then
|
|
||||||
return 0
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
local function allow_metadata_inventory_move(pos, from_list, from_index, to_list, to_index, count, player)
|
|
||||||
local meta = minetest.get_meta(pos)
|
|
||||||
local inv = meta:get_inventory()
|
|
||||||
local stack = inv:get_stack(from_list, from_index)
|
|
||||||
return allow_metadata_inventory_put(pos, to_list, to_index, stack, player)
|
|
||||||
end
|
|
||||||
|
|
||||||
local function allow_metadata_inventory_take(pos, listname, index, stack, player)
|
|
||||||
if minetest.is_protected(pos, player:get_player_name()) then
|
|
||||||
return 0
|
|
||||||
end
|
|
||||||
return stack:get_count()
|
|
||||||
end
|
|
||||||
|
|
||||||
-- handle the sieve animation
|
-- handle the sieve animation
|
||||||
local function swap_node(pos, meta, start)
|
local function swap_node(pos)
|
||||||
local node = minetest.get_node(pos)
|
local node = minetest.get_node(pos)
|
||||||
local idx = meta:get_int("idx")
|
local idx = string.byte(node.name, -1) - 48
|
||||||
if start then
|
|
||||||
if idx == 3 then
|
|
||||||
idx = 0
|
|
||||||
end
|
|
||||||
else
|
|
||||||
idx = (idx + 1) % 4
|
idx = (idx + 1) % 4
|
||||||
end
|
minetest.swap_node(pos, {name = "techage:sieve"..idx, param2 = node.param2})
|
||||||
meta:set_int("idx", idx)
|
return idx == 3 -- true if done
|
||||||
node.name = meta:get_string("node_name")..idx
|
|
||||||
minetest.swap_node(pos, node)
|
|
||||||
return idx == 3
|
|
||||||
end
|
end
|
||||||
|
|
||||||
-- place ores to dst according to the calculated probability
|
local function push_items(pos, items)
|
||||||
local function random_ore(inv, src)
|
local pos1 = {x=pos.x, y=pos.y-1, z=pos.z}
|
||||||
local num
|
local node = minetest.get_node(pos1)
|
||||||
for ore, probability in pairs(techage.ore_probability) do
|
minetest.add_item({x=pos.x, y=pos.y-0.4, z=pos.z}, items)
|
||||||
if math.random(probability) == 1 then
|
|
||||||
local item = ItemStack(ore)
|
|
||||||
if inv:room_for_item("dst", item) then
|
|
||||||
inv:add_item("dst", item)
|
|
||||||
return true -- ore placed
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
|
||||||
return false -- gravel has to be moved
|
|
||||||
end
|
end
|
||||||
|
|
||||||
|
local function keep_running(pos, elapsed)
|
||||||
|
local inv = M(pos):get_inventory()
|
||||||
|
if swap_node(pos) then
|
||||||
|
local src, dst
|
||||||
|
|
||||||
local function add_gravel_to_dst(meta, inv)
|
if inv:contains_item("src", ItemStack("techage:basalt_gravel")) then
|
||||||
-- maintain a counter for gravel kind selection
|
dst, src = get_random_basalt_ore(), ItemStack("techage:basalt_gravel")
|
||||||
local gravel_cnt = meta:get_int("gravel_cnt") + 1
|
elseif inv:contains_item("src", ItemStack("default:gravel")) then
|
||||||
meta:set_int("gravel_cnt", gravel_cnt)
|
dst, src = get_random_gravel_ore(), ItemStack("default:gravel")
|
||||||
|
|
||||||
if (gravel_cnt % 2) == 0 then -- gravel or sieved gravel?
|
|
||||||
inv:add_item("dst", ItemStack("default:gravel")) -- add to dest
|
|
||||||
else
|
else
|
||||||
inv:add_item("dst", ItemStack("techage:sieved_gravel")) -- add to dest
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
|
|
||||||
-- move gravel and ores to dst
|
|
||||||
local function move_src2dst(meta, pos, inv, src, dst)
|
|
||||||
if inv:room_for_item("dst", dst) and inv:contains_item("src", src) then
|
|
||||||
local res = swap_node(pos, meta, false)
|
|
||||||
if res then -- time to move one item?
|
|
||||||
if src:get_name() == "default:gravel" then -- will we find ore?
|
|
||||||
if not random_ore(inv, src) then -- no ore found?
|
|
||||||
add_gravel_to_dst(meta, inv)
|
|
||||||
end
|
|
||||||
else
|
|
||||||
inv:add_item("dst", ItemStack("techage:sieved_gravel")) -- add to dest
|
|
||||||
end
|
|
||||||
inv:remove_item("src", src)
|
|
||||||
end
|
|
||||||
return true -- process finished
|
|
||||||
end
|
|
||||||
return false -- process still running
|
|
||||||
end
|
|
||||||
|
|
||||||
-- timer callback, alternatively called by on_punch
|
|
||||||
local function sieve_node_timer(pos, elapsed)
|
|
||||||
local meta = minetest.get_meta(pos)
|
|
||||||
local inv = meta:get_inventory()
|
|
||||||
local gravel = ItemStack("default:gravel")
|
|
||||||
local gravel_sieved = ItemStack("techage:sieved_gravel")
|
|
||||||
|
|
||||||
if move_src2dst(meta, pos, inv, gravel) then
|
|
||||||
return true
|
|
||||||
elseif move_src2dst(meta, pos, inv, gravel_sieved) then
|
|
||||||
return true
|
|
||||||
else
|
|
||||||
minetest.get_node_timer(pos):stop()
|
|
||||||
return false
|
return false
|
||||||
end
|
end
|
||||||
|
push_items(pos, dst)
|
||||||
|
inv:remove_item("src", src)
|
||||||
|
end
|
||||||
|
return not inv:is_empty("src")
|
||||||
end
|
end
|
||||||
|
|
||||||
|
local function on_construct(pos)
|
||||||
|
local meta = minetest.get_meta(pos)
|
||||||
|
meta:set_string("infotext", I("TA1 Gravel Sieve"))
|
||||||
|
local inv = meta:get_inventory()
|
||||||
|
inv:set_size('src', 1)
|
||||||
|
end
|
||||||
|
|
||||||
|
local function on_punch(pos, node, puncher, pointed_thing)
|
||||||
|
local wielded_item = puncher:get_wielded_item():get_name()
|
||||||
|
if wielded_item == "default:gravel" or wielded_item == "techage:basalt_gravel" then
|
||||||
|
local inv = M(pos):get_inventory()
|
||||||
|
local stack = ItemStack(wielded_item)
|
||||||
|
if inv:room_for_item("src", stack) then
|
||||||
|
inv:add_item("src", stack)
|
||||||
|
minetest.swap_node(pos, {name = "techage:sieve0"})
|
||||||
|
minetest.get_node_timer(pos):start(1)
|
||||||
|
local w = puncher:get_wielded_item()
|
||||||
|
if not(minetest.setting_getbool("creative_mode")) then
|
||||||
|
w:take_item(1)
|
||||||
|
puncher:set_wielded_item(w)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
local tiles_data = {
|
||||||
|
-- up, down, right, left, back, front
|
||||||
|
"techage_sieve_gravel_ta1.png",
|
||||||
|
"techage_sieve_gravel_ta1.png",
|
||||||
|
"techage_sieve_sieve_ta1.png",
|
||||||
|
"techage_sieve_sieve_ta1.png",
|
||||||
|
"techage_sieve_sieve_ta1.png",
|
||||||
|
"techage_sieve_sieve_ta1.png",
|
||||||
|
}
|
||||||
|
|
||||||
for idx = 0,4 do
|
|
||||||
local nodebox_data = {
|
local nodebox_data = {
|
||||||
{ -8/16, -8/16, -8/16, 8/16, 4/16, -6/16 },
|
{ -8/16, -3/16, -8/16, 8/16, 4/16, -6/16 },
|
||||||
{ -8/16, -8/16, 6/16, 8/16, 4/16, 8/16 },
|
{ -8/16, -3/16, 6/16, 8/16, 4/16, 8/16 },
|
||||||
{ -8/16, -8/16, -8/16, -6/16, 4/16, 8/16 },
|
{ -8/16, -3/16, -8/16, -6/16, 4/16, 8/16 },
|
||||||
{ 6/16, -8/16, -8/16, 8/16, 4/16, 8/16 },
|
{ 6/16, -3/16, -8/16, 8/16, 4/16, 8/16 },
|
||||||
|
|
||||||
|
{ -8/16, -8/16, -8/16, -6/16, -3/16, -6/16 },
|
||||||
|
{ 6/16, -8/16, -8/16, 8/16, -3/16, -6/16 },
|
||||||
|
{ -8/16, -8/16, 6/16, -6/16, -3/16, 8/16 },
|
||||||
|
{ 6/16, -8/16, 6/16, 8/16, -3/16, 8/16 },
|
||||||
|
|
||||||
{ -6/16, -2/16, -6/16, 6/16, 8/16, 6/16 },
|
{ -6/16, -2/16, -6/16, 6/16, 8/16, 6/16 },
|
||||||
}
|
}
|
||||||
nodebox_data[5][5] = (8 - 2*idx) / 16
|
|
||||||
|
|
||||||
local node_name
|
|
||||||
local description
|
|
||||||
local tiles_data
|
|
||||||
local tube_info
|
|
||||||
local not_in_creative_inventory
|
|
||||||
node_name = "techage:sieve"
|
|
||||||
description = I("TA1 Gravel Sieve")
|
|
||||||
tiles_data = {
|
|
||||||
-- up, down, right, left, back, front
|
|
||||||
"techage_handsieve_gravel.png",
|
|
||||||
"techage_handsieve_gravel.png",
|
|
||||||
"techage_handsieve_sieve.png",
|
|
||||||
"techage_handsieve_sieve.png",
|
|
||||||
"techage_handsieve_sieve.png",
|
|
||||||
"techage_handsieve_sieve.png",
|
|
||||||
}
|
|
||||||
|
|
||||||
|
for idx = 0,3 do
|
||||||
|
nodebox_data[9][5] = (8 - 2*idx) / 16
|
||||||
if idx == 3 then
|
if idx == 3 then
|
||||||
tiles_data[1] = "techage_handsieve_top.png"
|
tiles_data[1] = "techage_sieve_top_ta1.png"
|
||||||
not_in_creative_inventory = 0
|
|
||||||
else
|
|
||||||
not_in_creative_inventory = 1
|
|
||||||
end
|
end
|
||||||
|
|
||||||
|
minetest.register_node("techage:sieve"..idx, {
|
||||||
minetest.register_node(node_name..idx, {
|
description = I("TA1 Gravel Sieve"),
|
||||||
description = description,
|
|
||||||
tiles = tiles_data,
|
tiles = tiles_data,
|
||||||
drawtype = "nodebox",
|
drawtype = "nodebox",
|
||||||
drop = node_name,
|
|
||||||
|
|
||||||
tube = tube_info, -- NEW
|
|
||||||
|
|
||||||
node_box = {
|
node_box = {
|
||||||
type = "fixed",
|
type = "fixed",
|
||||||
fixed = nodebox_data,
|
fixed = nodebox_data,
|
||||||
},
|
},
|
||||||
selection_box = {
|
selection_box = {
|
||||||
type = "fixed",
|
type = "fixed",
|
||||||
fixed = { -8/16, -8/16, -8/16, 8/16, 4/16, 8/16 },
|
fixed = { -8/16, -3/16, -8/16, 8/16, 4/16, 8/16 },
|
||||||
},
|
},
|
||||||
|
|
||||||
on_timer = sieve_node_timer,
|
on_construct = idx == 3 and on_construct or nil,
|
||||||
|
on_punch = idx == 3 and on_punch or nil,
|
||||||
on_construct = function(pos)
|
on_timer = keep_running,
|
||||||
local meta = minetest.get_meta(pos)
|
|
||||||
meta:set_int("idx", idx) -- for the 4 sieve phases
|
|
||||||
meta:set_int("gravel_cnt", 0) -- counter to switch between gravel and sieved gravel
|
|
||||||
meta:set_string("node_name", node_name)
|
|
||||||
meta:set_string("formspec", sieve_formspec)
|
|
||||||
local inv = meta:get_inventory()
|
|
||||||
inv:set_size('src', 1)
|
|
||||||
inv:set_size('dst', 16)
|
|
||||||
end,
|
|
||||||
|
|
||||||
after_place_node = function(pos, placer)
|
|
||||||
local meta = minetest.get_meta(pos)
|
|
||||||
meta:set_string("infotext", I("TA1 Gravel Sieve"))
|
|
||||||
end,
|
|
||||||
|
|
||||||
on_metadata_inventory_move = function(pos)
|
|
||||||
local meta = minetest.get_meta(pos)
|
|
||||||
swap_node(pos, meta, true)
|
|
||||||
end,
|
|
||||||
|
|
||||||
on_metadata_inventory_take = function(pos)
|
|
||||||
local meta = minetest.get_meta(pos)
|
|
||||||
local inv = meta:get_inventory()
|
|
||||||
if inv:is_empty("src") then
|
|
||||||
-- sieve should be empty
|
|
||||||
meta:set_int("idx", 2)
|
|
||||||
swap_node(pos, meta, false)
|
|
||||||
meta:set_int("gravel_cnt", 0)
|
|
||||||
end
|
|
||||||
end,
|
|
||||||
|
|
||||||
on_metadata_inventory_put = function(pos)
|
|
||||||
local meta = minetest.get_meta(pos)
|
|
||||||
swap_node(pos, meta, true)
|
|
||||||
end,
|
|
||||||
|
|
||||||
on_punch = function(pos, node, puncher, pointed_thing)
|
|
||||||
local meta = minetest.get_meta(pos)
|
|
||||||
local inv = meta:get_inventory()
|
|
||||||
if inv:is_empty("dst") and inv:is_empty("src") then
|
|
||||||
minetest.node_punch(pos, node, puncher, pointed_thing)
|
|
||||||
else
|
|
||||||
sieve_node_timer(pos, 0)
|
|
||||||
end
|
|
||||||
end,
|
|
||||||
|
|
||||||
on_dig = function(pos, node, puncher, pointed_thing)
|
|
||||||
local meta = minetest.get_meta(pos)
|
|
||||||
local inv = meta:get_inventory()
|
|
||||||
if inv:is_empty("dst") and inv:is_empty("src") then
|
|
||||||
minetest.node_dig(pos, node, puncher, pointed_thing)
|
|
||||||
end
|
|
||||||
end,
|
|
||||||
|
|
||||||
allow_metadata_inventory_put = allow_metadata_inventory_put,
|
|
||||||
allow_metadata_inventory_move = allow_metadata_inventory_move,
|
|
||||||
allow_metadata_inventory_take = allow_metadata_inventory_take,
|
|
||||||
|
|
||||||
paramtype = "light",
|
paramtype = "light",
|
||||||
sounds = default.node_sound_wood_defaults(),
|
sounds = default.node_sound_wood_defaults(),
|
||||||
paramtype2 = "facedir",
|
paramtype2 = "facedir",
|
||||||
sunlight_propagates = true,
|
sunlight_propagates = true,
|
||||||
is_ground_content = false,
|
is_ground_content = false,
|
||||||
groups = {choppy=2, cracky=1, not_in_creative_inventory=not_in_creative_inventory},
|
groups = {choppy = 2, cracky = 1},
|
||||||
drop = node_name.."3",
|
drop = "techage:sieve3",
|
||||||
})
|
})
|
||||||
end
|
end
|
||||||
|
|
||||||
|
techage.register_node("techage:sieve0", {"techage:sieve1", "techage:sieve2", "techage:sieve3"}, {
|
||||||
|
on_push_item = function(pos, in_dir, stack)
|
||||||
|
local meta = minetest.get_meta(pos)
|
||||||
|
local inv = meta:get_inventory()
|
||||||
|
if inv:room_for_item("src", stack) then
|
||||||
|
inv:add_item("src", stack)
|
||||||
|
minetest.get_node_timer(pos):start(1)
|
||||||
|
return true
|
||||||
|
end
|
||||||
|
return false
|
||||||
|
end,
|
||||||
|
})
|
||||||
|
|
||||||
minetest.register_node("techage:sieved_gravel", {
|
minetest.register_node("techage:sieved_gravel", {
|
||||||
description = I("Sieved Gravel"),
|
description = I("Sieved Gravel"),
|
||||||
tiles = {"default_gravel.png"},
|
tiles = {"default_gravel.png"},
|
||||||
@ -354,15 +193,3 @@ minetest.register_craft({
|
|||||||
minetest.register_alias("techage:sieve", "techage:sieve3")
|
minetest.register_alias("techage:sieve", "techage:sieve3")
|
||||||
minetest.register_alias("techage:auto_sieve", "techage:auto_sieve3")
|
minetest.register_alias("techage:auto_sieve", "techage:auto_sieve3")
|
||||||
|
|
||||||
-- adaption to Circular Saw
|
|
||||||
--if minetest.get_modpath("moreblocks") then
|
|
||||||
|
|
||||||
-- stairsplus:register_all("techage", "compressed_gravel", "techage:compressed_gravel", {
|
|
||||||
-- description= I("Compressed Gravel"),
|
|
||||||
-- groups={cracky=2, crumbly=2, choppy=2, not_in_creative_inventory=1},
|
|
||||||
-- tiles = {"techage_compressed_gravel.png"},
|
|
||||||
-- sounds = default.node_sound_stone_defaults(),
|
|
||||||
-- })
|
|
||||||
--end
|
|
||||||
|
|
||||||
|
|
||||||
|
Before Width: | Height: | Size: 171 B After Width: | Height: | Size: 156 B |
Before Width: | Height: | Size: 1.3 KiB After Width: | Height: | Size: 656 B |
BIN
textures/techage_appl_funnel.png
Normal file
After Width: | Height: | Size: 159 B |
BIN
textures/techage_appl_funnel_right.png
Normal file
After Width: | Height: | Size: 169 B |
BIN
textures/techage_appl_funnel_top.png
Normal file
After Width: | Height: | Size: 273 B |
Before Width: | Height: | Size: 246 B After Width: | Height: | Size: 243 B |
Before Width: | Height: | Size: 352 B |
Before Width: | Height: | Size: 305 B After Width: | Height: | Size: 216 B |
Before Width: | Height: | Size: 467 B |
Before Width: | Height: | Size: 1.3 KiB After Width: | Height: | Size: 380 B |
Before Width: | Height: | Size: 291 B After Width: | Height: | Size: 250 B |
Before Width: | Height: | Size: 1.3 KiB After Width: | Height: | Size: 485 B |
Before Width: | Height: | Size: 2.2 KiB After Width: | Height: | Size: 2.2 KiB |
BIN
textures/techage_sieve_sieve_ta1.png
Normal file
After Width: | Height: | Size: 452 B |
Before Width: | Height: | Size: 315 B After Width: | Height: | Size: 315 B |