nodecore-skyblock/nc_sieve/sieve.lua

302 lines
8.5 KiB
Lua

-- LUALOCALS < ---------------------------------------------------------
local minetest, nodecore, pairs
= minetest, nodecore, pairs
-- LUALOCALS > ---------------------------------------------------------
local modname = minetest.get_current_modname()
local wmodname = "nc_woodwork"
local side = "nc_tree_tree_side.png"
local top = wmodname.. "_plank.png"
local top_sieve = wmodname .. "_plank.png^[mask:"..modname.."_sieve.png^nc_tree_leaves.png"
local stop = "nc_terrain_stone.png"
local sside = "nc_terrain_stone.png"
local stop_sieve = "nc_terrain_stone.png^[mask:"..modname.."_sieve.png^nc_terrain_cobble.png"
function regsieve(suff,top,side,top_sieve,groups)
local mname = #suff == 0 and "Wooden" or suff:sub(1,1):upper()..suff:sub(2)
suff = #suff == 0 and suff or "_"..suff
minetest.register_node(modname .. ":table"..suff, {
description = mname.." Table",
drawtype = "nodebox",
node_box = nodecore.fixedbox(
{-0.5, 7/16, -0.5, 0.5, 0.5, 0.5},
{-0.5, -0.5, -0.5, -7/16, 7/16, -7/16},
{-0.5, -0.5, 7/16, -7/16, 7/16, 0.5},
{7/16, -0.5, -0.5, 0.5, 7/16, -7/16},
{7/16, -0.5, 7/16, 0.5, 7/16, 0.5}
),
selection_box = nodecore.fixedbox(),
collision_box = nodecore.fixedbox(),
tiles = { top, top, side },
groups = groups,
paramtype = "light",
sounds = nodecore.sounds("nc_tree_woody"),
})
minetest.register_node(modname .. ":table_broken"..suff, {
description = "Broken "..mname.." Table",
drawtype = "nodebox",
node_box = nodecore.fixedbox(
{-0.5, 7/16, -0.5, -0.5+4/16,0.5,0.5},
{0.5-4/16, 7/16, -0.5, 0.5, 0.5, 0.5},
{-8/32, 7/16, 8/32, 8/32, 0.5, 0.5},
{-8/32, 7/16, -0.5, 8/32, 0.5, -8/32},
{-0.5, -0.5, -0.5, -7/16, 7/16, -7/16},
{-0.5, -0.5, 7/16, -7/16, 7/16, 0.5},
{7/16, -0.5, -0.5, 0.5, 7/16, -7/16},
{7/16, -0.5, 7/16, 0.5, 7/16, 0.5}
),
selection_box = nodecore.fixedbox(),
collision_box = nodecore.fixedbox(),
tiles = { top, top, side },
groups = groups,
paramtype = "light",
sounds = nodecore.sounds("nc_tree_woody"),
})
minetest.register_node(modname .. ":sieve"..suff, {
description = mname.." Sieve",
drawtype = "nodebox",
use_texture_alpha = true,
node_box = nodecore.fixedbox(
{-4/16,7/16,-4/16,4/16,0.5,4/16},
{-0.5, 7/16, -0.5, -0.5+4/16,0.5,0.5},
{0.5-4/16, 7/16, -0.5, 0.5, 0.5, 0.5},
{-8/32, 7/16, 8/32, 8/32, 0.5, 0.5},
{-8/32, 7/16, -0.5, 8/32, 0.5, -8/32},
{-0.5, -0.5, -0.5, -7/16, 7/16, -7/16},
{-0.5, -0.5, 7/16, -7/16, 7/16, 0.5},
{7/16, -0.5, -0.5, 0.5, 7/16, -7/16},
{7/16, -0.5, 7/16, 0.5, 7/16, 0.5}
),
selection_box = nodecore.fixedbox(),
collision_box = nodecore.fixedbox(),
tiles = { top_sieve, top_sieve, side },
groups = groups,
paramtype = "light",
sounds = nodecore.sounds("nc_tree_woody"),
})
end
regsieve("",top,side,top_sieve,{
choppy = 1,
flammable = 2,
fire_fuel = 3,
})
regsieve("stone",stop,sside,stop_sieve,{
cracky = 2,
})
minetest.register_craftitem(modname..":random_dust",{
description = "Dust of random minerals",
inventory_image = modname.."_random_dust.png"
})
minetest.register_craftitem(modname..":super_random_dust",{
description = "Dust of very random minerals",
inventory_image = modname.."_random_dust.png"
})
nodecore.register_craft({
label = "break a wooden table",
action = "pummel",
toolgroups = {choppy = 1},
nodes = {
{match = modname .. ":table", replace = modname .. ":table_broken"}
},
})
nodecore.register_craft({
label = "break a stone table",
action = "pummel",
toolgroups = {cracky = 4},
nodes = {
{match = modname .. ":table_stone", replace = modname .. ":table_broken_stone"}
},
})
local duo = {
items={{name = modname..":random_dust", count = 1, scatter = 2}}
}
local duo2 = {
items={{name = modname..":random_dust", count = 2, scatter = 2}}
}
local duo3 = {
items={{name = modname..":super_random_dust", count = 2, scatter = 2}}
}
local duo4 = {
items={{name = modname..":super_random_dust", count = 4, scatter = 2}}
}
for _,dat in pairs({
{
sievables = {
["nc_terrain:gravel"] = duo,
["nc_terrain:gravel_loose"] = duo,
["nc_terrain:sand"] = duo2,
["nc_terrain:sand_loose"] = duo2,
["nc_tree:leaves_loose"] = {node = "nc_terrain:water_source"},
},
name = modname..":sieve"
},
{
sievables = {
["nc_terrain:gravel"] = duo3,
["nc_terrain:gravel_loose"] = duo3,
["nc_terrain:sand"] = duo4,
["nc_terrain:sand_loose"] = duo4,
["nc_tree:leaves_loose"] = {node = "nc_terrain:water_source"},
},
name = modname..":sieve_stone"
}
})
do
for k,v in pairs(dat.sievables) do
nodecore.register_craft({
label = "use a sieve with "..k,
action = "pummel",
toolgroups = {crumbly = 1},
nodes = {
{match = {name = k}, replace = v.node or "air"},
{y=-1,match = dat.name}
},
items = v.items
})
end
end
for _,dat in pairs({
{
drop = {
["nc_terrain:cobble"] = 30,
["nc_lode:cobble_loose"] = 10,
["nc_lux:cobble1_loose"] = 1,
["nc_sponge:sponge_living"]=1
},
name = modname..":random_dust"
},
{
ores = {
["nc_terrain:cobble"] = 50,
["nc_lode:cobble_loose"] = 50,
["nc_lux:cobble1_loose"] = 5,
["nc_sponge:sponge_living"]=5,
["rdust"]=1
},
name = modname..":super_random_dust"
}
})
do
nodecore.register_craft({
label = "pack random dust into cobble",
action = "pummel",
toolgroups = {thumpy = 3},
nodes = {
{match = {name = dat.name,count=16},replace = "nc_terrain:cobble"}
},
after = function(pos)
local chances = {}
local mc = 1
for k,v in pairs(dat.drop) do
for n=mc,mc-1+v do
chances[n] = k
end
mc=mc+v
end
local ore = chances[math.random(1,mc-1)]
if ore == "rdust" then
nodecore.item_eject(pos,modname..":super_random_dust",5,20)
else
minetest.set_node(pos,{name=ore})
end
end
})
end
nodecore.register_craft({
label = "assemble wood sieve",
norotate = true,
nodes = {
{y = -1, match = modname .. ":table_broken", replace = modname .. ":sieve"},
{match = "nc_tree:leaves_loose", replace = "air"},
}
})
nodecore.register_craft({
label = "assemble stone sieve",
norotate = true,
nodes = {
{y = -1, match = modname .. ":table_broken_stone", replace = modname .. ":sieve_stone"},
{match = "nc_terrain:cobble_loose", replace = "air"},
}
})
nodecore.register_craft({
label = "assemble wood table",
norotate = true,
nodes = {
{match = wmodname .. ":plank", replace = modname .. ":table"},
{x = -1, z = -1, match = wmodname .. ":staff", replace = "air"},
{x = 1, z = -1, match = wmodname .. ":staff", replace = "air"},
{x = -1, z = 1, match = wmodname .. ":staff", replace = "air"},
{x = 1, z = 1, match = wmodname .. ":staff", replace = "air"},
}
})
nodecore.register_craft({
label = "assemble wood table",
norotate = true,
nodes = {
{match = wmodname .. ":plank", replace = modname .. ":table"},
{x = 0, z = -1, match = wmodname .. ":staff", replace = "air"},
{x = 0, z = 1, match = wmodname .. ":staff", replace = "air"},
{x = -1, z = 0, match = wmodname .. ":staff", replace = "air"},
{x = 1, z = 0, match = wmodname .. ":staff", replace = "air"},
}
})
nodecore.register_craft({
label = "assemble stone table",
action = "pummel",
toolgroups = {thumpy = 4},
priority = 1,
norotate = true,
nodes = {
{match = "nc_terrain:cobble_loose", replace = modname .. ":table_stone"},
{x = -1, z = -1, match = "nc_lode:rod_annealed", replace = "air"},
{x = 1, z = -1, match = "nc_lode:rod_annealed", replace = "air"},
{x = -1, z = 1, match = "nc_lode:rod_annealed", replace = "air"},
{x = 1, z = 1, match = "nc_lode:rod_annealed", replace = "air"},
}
})
nodecore.register_craft({
label = "assemble stone table",
action = "pummel",
toolgroups = {thumpy = 4},
priority = 1,
norotate = true,
nodes = {
{match = "nc_terrain:cobble_loose", replace = modname .. ":table_stone"},
{x = 0, z = -1, match = "nc_lode:rod_annealed", replace = "air"},
{x = 0, z = 1, match = "nc_lode:rod_annealed", replace = "air"},
{x = -1, z = 0, match = "nc_lode:rod_annealed", replace = "air"},
{x = 1, z = 0, match = "nc_lode:rod_annealed", replace = "air"},
}
})