mirror of
https://github.com/minetest-mods/technic.git
synced 2024-12-23 17:30:30 +01:00
allow per-generator stack splitting
(default off)
This commit is contained in:
parent
11f20da744
commit
4eaf48290f
@ -1,5 +1,7 @@
|
||||
local S = technic.getter
|
||||
|
||||
local fs_helpers = pipeworks.fs_helpers
|
||||
|
||||
local tube = {
|
||||
insert_object = function(pos, node, stack, direction)
|
||||
local meta = minetest.get_meta(pos)
|
||||
@ -9,8 +11,10 @@ local tube = {
|
||||
can_insert = function(pos, node, stack, direction)
|
||||
local meta = minetest.get_meta(pos)
|
||||
local inv = meta:get_inventory()
|
||||
local onestack = stack:peek_item(1)
|
||||
return inv:room_for_item("src", onestack)
|
||||
if meta:get_int("splitstacks") == 1 then
|
||||
stack = stack:peek_item(1)
|
||||
end
|
||||
return inv:room_for_item("src", stack)
|
||||
end,
|
||||
connect_sides = {left=1, right=1, back=1, top=1, bottom=1},
|
||||
}
|
||||
@ -77,14 +81,29 @@ function technic.register_generator(data)
|
||||
if burn_totaltime == 0 then burn_totaltime = 1 end
|
||||
local percent = math.floor((burn_time / burn_totaltime) * 100)
|
||||
meta:set_string("infotext", desc.." ("..percent.."%)")
|
||||
meta:set_string("formspec",
|
||||
"size[8, 9]"..
|
||||
"label[0, 0;"..minetest.formspec_escape(desc).."]"..
|
||||
"list[current_name;src;3, 1;1, 1;]"..
|
||||
"image[4, 1;1, 1;default_furnace_fire_bg.png^[lowpart:"..
|
||||
(percent)..":default_furnace_fire_fg.png]"..
|
||||
"list[current_player;main;0, 5;8, 4;]"..
|
||||
"listring[]")
|
||||
|
||||
local form = ""
|
||||
if ltier ~= "lv" then
|
||||
form = fs_helpers.cycling_button(
|
||||
meta,
|
||||
"image_button[0,4.3;1,0.6",
|
||||
"splitstacks",
|
||||
{
|
||||
{text="", texture="pipeworks_button_off.png", addopts="false;false;pipeworks_button_interm.png"},
|
||||
{text="", texture="pipeworks_button_on.png", addopts="false;false;pipeworks_button_interm.png"}
|
||||
}
|
||||
).."label[0.9,4.31;Allow splitting incoming stacks from tubes]"
|
||||
end
|
||||
meta:set_string("formspec",
|
||||
"size[8, 9]"..
|
||||
"label[0, 0;"..minetest.formspec_escape(desc).."]"..
|
||||
"list[current_name;src;3, 1;1, 1;]"..
|
||||
"image[4, 1;1, 1;default_furnace_fire_bg.png^[lowpart:"..
|
||||
(percent)..":default_furnace_fire_fg.png]"..
|
||||
"list[current_player;main;0, 5;8, 4;]"..
|
||||
"listring[]"..
|
||||
form
|
||||
)
|
||||
end
|
||||
|
||||
minetest.register_node("technic:"..ltier.."_generator", {
|
||||
@ -104,7 +123,20 @@ function technic.register_generator(data)
|
||||
meta:set_int(data.tier.."_EU_supply", 0)
|
||||
meta:set_int("burn_time", 0)
|
||||
meta:set_int("tube_time", 0)
|
||||
meta:set_string("formspec", generator_formspec)
|
||||
local form = generator_formspec
|
||||
if ltier ~= "lv" then
|
||||
form = generator_formspec ..
|
||||
fs_helpers.cycling_button(
|
||||
meta,
|
||||
"image_button[0,4.3;1,0.6",
|
||||
"splitstacks",
|
||||
{
|
||||
{text="", texture="pipeworks_button_off.png", addopts="false;false;pipeworks_button_interm.png"},
|
||||
{text="", texture="pipeworks_button_on.png", addopts="false;false;pipeworks_button_interm.png"}
|
||||
}
|
||||
).."label[0.9,4.31;Allow splitting incoming stacks from tubes]"
|
||||
end
|
||||
meta:set_string("formspec", form)
|
||||
local inv = meta:get_inventory()
|
||||
inv:set_size("src", 1)
|
||||
end,
|
||||
@ -114,7 +146,27 @@ function technic.register_generator(data)
|
||||
allow_metadata_inventory_move = technic.machine_inventory_move,
|
||||
technic_run = run,
|
||||
after_place_node = data.tube and pipeworks.after_place,
|
||||
after_dig_node = technic.machine_after_dig_node
|
||||
after_dig_node = technic.machine_after_dig_node,
|
||||
on_receive_fields = function(pos, formname, fields, sender)
|
||||
if not pipeworks.may_configure(pos, sender) then return end
|
||||
fs_helpers.on_receive_fields(pos, fields)
|
||||
local meta = minetest.get_meta(pos)
|
||||
local form = generator_formspec
|
||||
if ltier ~= "lv" then
|
||||
form = generator_formspec ..
|
||||
fs_helpers.cycling_button(
|
||||
meta,
|
||||
"image_button[0,4.3;1,0.6",
|
||||
"splitstacks",
|
||||
{
|
||||
{text="", texture="pipeworks_button_off.png", addopts="false;false;pipeworks_button_interm.png"},
|
||||
{text="", texture="pipeworks_button_on.png", addopts="false;false;pipeworks_button_interm.png"}
|
||||
}
|
||||
).."label[0.9,4.31;Allow splitting incoming stacks from tubes]"
|
||||
end
|
||||
meta:set_string("formspec", form)
|
||||
end,
|
||||
|
||||
})
|
||||
|
||||
minetest.register_node("technic:"..ltier.."_generator_active", {
|
||||
@ -158,6 +210,19 @@ function technic.register_generator(data)
|
||||
burn_time = burn_time - 1
|
||||
meta:set_int("burn_time", burn_time)
|
||||
local percent = math.floor(burn_time / burn_totaltime * 100)
|
||||
|
||||
local formbuttons = ""
|
||||
if ltier ~= "lv" then
|
||||
form = fs_helpers.cycling_button(
|
||||
meta,
|
||||
"image_button[0,4.3;1,0.6",
|
||||
"splitstacks",
|
||||
{
|
||||
{text="", texture="pipeworks_button_off.png", addopts="false;false;pipeworks_button_interm.png"},
|
||||
{text="", texture="pipeworks_button_on.png", addopts="false;false;pipeworks_button_interm.png"}
|
||||
}
|
||||
).."label[0.9,4.31;Allow splitting incoming stacks from tubes]"
|
||||
end
|
||||
meta:set_string("formspec",
|
||||
"size[8, 9]"..
|
||||
"label[0, 0;"..minetest.formspec_escape(desc).."]"..
|
||||
@ -165,9 +230,45 @@ function technic.register_generator(data)
|
||||
"image[4, 1;1, 1;default_furnace_fire_bg.png^[lowpart:"..
|
||||
(percent)..":default_furnace_fire_fg.png]"..
|
||||
"list[current_player;main;0, 5;8, 4;]"..
|
||||
"listring[]")
|
||||
"listring[]"..
|
||||
form
|
||||
)
|
||||
return true
|
||||
end,
|
||||
on_receive_fields = function(pos, formname, fields, sender)
|
||||
if not pipeworks.may_configure(pos, sender) then return end
|
||||
fs_helpers.on_receive_fields(pos, fields)
|
||||
local meta = minetest.get_meta(pos)
|
||||
local form = generator_formspec
|
||||
if ltier ~= "lv" then
|
||||
form = generator_formspec ..
|
||||
fs_helpers.cycling_button(
|
||||
meta,
|
||||
"image_button[0,4.3;1,0.6",
|
||||
"splitstacks",
|
||||
{
|
||||
{text="", texture="pipeworks_button_off.png", addopts="false;false;pipeworks_button_interm.png"},
|
||||
{text="", texture="pipeworks_button_on.png", addopts="false;false;pipeworks_button_interm.png"}
|
||||
}
|
||||
).."label[0.9,4.31;Allow splitting incoming stacks from tubes]"
|
||||
end
|
||||
|
||||
local burn_totaltime = meta:get_int("burn_totaltime") or 0
|
||||
local burn_time = meta:get_int("burn_time")
|
||||
local percent = math.floor(burn_time / burn_totaltime * 100)
|
||||
|
||||
meta:set_string("formspec",
|
||||
"size[8, 9]"..
|
||||
"label[0, 0;"..minetest.formspec_escape(desc).."]"..
|
||||
"list[current_name;src;3, 1;1, 1;]"..
|
||||
"image[4, 1;1, 1;default_furnace_fire_bg.png^[lowpart:"..
|
||||
(percent)..":default_furnace_fire_fg.png]"..
|
||||
"list[current_player;main;0, 5;8, 4;]"..
|
||||
"listring[]"..
|
||||
form
|
||||
)
|
||||
end,
|
||||
|
||||
})
|
||||
|
||||
technic.register_machine(tier, "technic:"..ltier.."_generator", technic.producer)
|
||||
|
Loading…
Reference in New Issue
Block a user