1
0
mirror of https://github.com/sys4-fr/server-nalc.git synced 2025-12-24 02:15:30 +01:00

[moreblocks] Updates

- Fix #302
- Add cherry tree/wood to the list of sawable items
This commit is contained in:
LeMagnesium
2015-10-11 16:16:22 +02:00
parent 11c8a7f060
commit 61822023cf
24 changed files with 587 additions and 349 deletions

View File

@@ -21,12 +21,14 @@ circular_saw.known_stairs = setmetatable({}, {
circular_saw.known_nodes = {}
-- How many microblocks does this shape at the output inventory cost:
-- It may cause slight loss, but no gain.
circular_saw.cost_in_microblocks = {
1, 1, 1, 1, 1, 1, 1, 2,
2, 3, 2, 4, 2, 4, 5, 6,
7, 1, 1, 2, 4, 6, 7, 8,
3, 1, 1, 2, 4, 4, 2, 7,
7, 2, 7, 6, 4, 6, 5, 4,
3, 1, 1, 2, 4, 4, 2, 6,
7, 3, 7, 7, 4, 8, 3, 2,
6, 2, 1, 3, 4,
}
circular_saw.names = {
@@ -65,11 +67,16 @@ circular_saw.names = {
{"slope", "_inner"},
{"slope", "_inner_half"},
{"slope", "_inner_half_raised"},
{"slope", "_inner_cut"},
{"slope", "_inner_cut_half"},
{"slope", "_inner_cut_half_raised"},
{"slope", "_outer"},
{"slope", "_outer_half"},
{"slope", "_outer_half_raised"},
{"slope", "_outer_cut"},
{"slope", "_outer_cut_half"},
{"slope", "_outer_cut_half_raised"},
{"slope", "_cut"},
}
function circular_saw:get_cost(inv, stackname)
@@ -91,7 +98,8 @@ function circular_saw:get_output_inv(modname, material, amount, max)
return list
end
for i, t in ipairs(circular_saw.names) do
for i = 1, #circular_saw.names do
local t = circular_saw.names[i]
local cost = circular_saw.cost_in_microblocks[i]
local balance = math.min(math.floor(amount/cost), max)
pos = pos + 1
@@ -232,9 +240,17 @@ function circular_saw.allow_metadata_inventory_put(
-- Only accept certain blocks as input which are known to be craftable into stairs:
if listname == "input" then
if not inv:is_empty("input") and
inv:get_stack("input", index):get_name() ~= stackname then
return 0
if not inv:is_empty("input") then
if inv:get_stack("input", index):get_name() ~= stackname then
return 0
end
end
if not inv:is_empty("micro") then
local microstackname = inv:get_stack("micro", 1):get_name():gsub("^.+:micro_", "", 1)
local cutstackname = stackname:gsub("^.+:", "", 1)
if microstackname ~= cutstackname then
return 0
end
end
for name, t in pairs(circular_saw.known_nodes) do
if name == stackname and inv:room_for_item("input", stack) then
@@ -294,7 +310,7 @@ gui_slots = "listcolors[#606060AA;#808080;#101010;#202020;#FFF]"
function circular_saw.on_construct(pos)
local meta = minetest.get_meta(pos)
local fancy_inv = default.gui_bg..default.gui_bg_img..default.gui_slots
meta:set_string("formspec", "size[11,9]"..fancy_inv..
meta:set_string("formspec", "size[11,10]"..fancy_inv..
"label[0,0;" ..S("Input\nmaterial").. "]" ..
"list[current_name;input;1.5,0;1,1;]" ..
"label[0,1;" ..S("Left-over").. "]" ..
@@ -303,8 +319,8 @@ function circular_saw.on_construct(pos)
"list[current_name;recycle;1.5,2;1,1;]" ..
"field[0.3,3.5;1,1;max_offered;" ..S("Max").. ":;${max_offered}]" ..
"button[1,3.2;1,1;Set;" ..S("Set").. "]" ..
"list[current_name;output;2.8,0;8,5;]" ..
"list[current_player;main;1.5,5.25;8,4;]")
"list[current_name;output;2.8,0;8,6;]" ..
"list[current_player;main;1.5,6.25;8,4;]")
meta:set_int("anz", 0) -- No microblocks inside yet.
meta:set_string("max_offered", 99) -- How many items of this kind are offered by default?
@@ -314,7 +330,7 @@ function circular_saw.on_construct(pos)
inv:set_size("input", 1) -- Input slot for full blocks of material x.
inv:set_size("micro", 1) -- Storage for 1-7 surplus microblocks.
inv:set_size("recycle", 1) -- Surplus partial blocks can be placed here.
inv:set_size("output", 5*8) -- 5x8 versions of stair-parts of material x.
inv:set_size("output", 6*8) -- 6x8 versions of stair-parts of material x.
circular_saw:reset(pos)
end