mirror of
https://github.com/joe7575/techpack.git
synced 2024-11-22 07:13:48 +01:00
v1.14 Distributor performance improved, chest commands added
This commit is contained in:
parent
b9eee1f388
commit
9074a38b32
@ -92,5 +92,7 @@ tubelib_addons1 optional: unified_inventory
|
||||
- 2018-08-13 V1.11 * Detector node added
|
||||
- 2018-08-14 V1.12 * Teleporter node added
|
||||
- 2018-08-28 V1.13 * Smartline Controller completely revised. Liquid Sampler added
|
||||
- 2018-09-10 V1.14 * Distributor performance improved, chest commands added
|
||||
|
||||
|
||||
See ![releasenotes.txt](https://github.com/joe7575/techpack/blob/master/releasenotes.md) for further information
|
@ -459,8 +459,9 @@ minetest.register_craft({
|
||||
|
||||
minetest.register_craft({
|
||||
output = "gravelsieve:auto_sieve",
|
||||
type = "shapeless",
|
||||
recipe = {
|
||||
{"gravelsieve:sieve", "default:mese_crystal", "default:mese_crystal"},
|
||||
"gravelsieve:sieve", "default:mese_crystal", "default:mese_crystal",
|
||||
},
|
||||
})
|
||||
|
||||
|
@ -1,6 +1,19 @@
|
||||
# Release Notes of the ModPack TechPack [techpack]
|
||||
|
||||
|
||||
## V1.14 Beta (2018-09-10)
|
||||
|
||||
### Additions
|
||||
- The Tubelib chests now provide the states ("empty"/"loaded")
|
||||
- The SmartLine Controller got the command "chest state request" for Tubelib chests
|
||||
- Minetest fuel recipe for Bio Fuel added
|
||||
|
||||
### Changes
|
||||
- The Distributor is now able to push up to 20 items per slot and phase (instead of 6).
|
||||
- The Distributor now uses an unconfigured port for blocked/rejected items.
|
||||
- The Tubelib Protected Chest got a new texture.
|
||||
- The Harvester is now HighPerf Pusher compatible.
|
||||
|
||||
|
||||
## V1.13.4 Beta (2018-09-08)
|
||||
|
||||
@ -8,6 +21,7 @@
|
||||
- SmartLine Controller got some form/submenu updates
|
||||
|
||||
|
||||
|
||||
## V1.13.3 Beta (2018-09-06)
|
||||
|
||||
### Additions
|
||||
@ -17,6 +31,7 @@
|
||||
- Parameter 'side' bugfix (used e.g. for on_push_item(...))
|
||||
|
||||
|
||||
|
||||
## V1.13.2 Beta (2018-09-05)
|
||||
|
||||
### Changes
|
||||
@ -25,6 +40,8 @@
|
||||
### Fixes
|
||||
- Recipe bug for SaferLua Controller fixed
|
||||
|
||||
|
||||
|
||||
## V1.13.1 Beta (2018-09-02)
|
||||
|
||||
### Changes
|
||||
@ -36,6 +53,7 @@
|
||||
in its own chest, the items went lost.
|
||||
|
||||
|
||||
|
||||
## V1.13 Beta (2018-08-28)
|
||||
|
||||
### Additions
|
||||
|
@ -221,6 +221,45 @@ smartline.icta_register_condition("fuel", {
|
||||
end,
|
||||
})
|
||||
|
||||
smartline.icta_register_condition("chest", {
|
||||
title = "chest state request",
|
||||
formspec = {
|
||||
{
|
||||
type = "digits",
|
||||
name = "number",
|
||||
label = "chest number",
|
||||
default = "",
|
||||
},
|
||||
{
|
||||
type = "textlist",
|
||||
name = "operand",
|
||||
label = "",
|
||||
choices = "is,is not",
|
||||
default = "is",
|
||||
},
|
||||
{
|
||||
type = "textlist",
|
||||
name = "value",
|
||||
label = "",
|
||||
choices = "empty,loaded",
|
||||
default = "empty",
|
||||
},
|
||||
{
|
||||
type = "label",
|
||||
name = "lbl",
|
||||
label = "Read the state from a Tubelib chest\n"..
|
||||
"and other similar nodes.",
|
||||
},
|
||||
},
|
||||
button = function(data, environ) -- default button label
|
||||
return 'sts('..sl.fmt_number(data.number)..","..data.operand..' '..data.value..')'
|
||||
end,
|
||||
code = function(data, environ)
|
||||
return 'tubelib.send_request("'..data.number..'", "state", "")',
|
||||
sl.operand(data.operand)..'"'..data.value..'"'
|
||||
end,
|
||||
})
|
||||
|
||||
smartline.icta_register_condition("signaltower", {
|
||||
title = "Signal Tower state request",
|
||||
formspec = {
|
||||
|
@ -341,19 +341,20 @@ function tubelib.get_item(meta, listname)
|
||||
return nil
|
||||
end
|
||||
|
||||
-- Get one item from the given ItemList, specified by stack number (1..n).
|
||||
-- Get one (or more) item(s) from the given ItemList, specified by stack number (1..n).
|
||||
-- Returns nil if ItemList is empty.
|
||||
function tubelib.get_this_item(meta, listname, number)
|
||||
function tubelib.get_this_item(meta, listname, list_number, num_items)
|
||||
if meta == nil or meta.get_inventory == nil then return nil end
|
||||
local inv = meta:get_inventory()
|
||||
if inv:is_empty(listname) then
|
||||
return nil
|
||||
end
|
||||
|
||||
local items = inv:get_stack(listname, number)
|
||||
if num_items == nil then num_items = 1 end
|
||||
local items = inv:get_stack(listname, list_number)
|
||||
if items:get_count() > 0 then
|
||||
local taken = items:take_item(1)
|
||||
inv:set_stack(listname, number, items)
|
||||
local taken = items:take_item(num_items)
|
||||
inv:set_stack(listname, list_number, items)
|
||||
return taken
|
||||
end
|
||||
return nil
|
||||
|
@ -19,6 +19,7 @@
|
||||
response is "running", "stopped", "standby", or "not supported"
|
||||
]]--
|
||||
|
||||
local MAX_NUM_PER_CYC = 20 -- maximum number of items, which can be pushed per slot
|
||||
local NUM_FILTER_ELEM = 6
|
||||
local NUM_FILTER_SLOTS = 4
|
||||
local TICKS_TO_SLEEP = 5
|
||||
@ -50,16 +51,12 @@ local function invlist_num_entries(list)
|
||||
return res
|
||||
end
|
||||
|
||||
-- Return a flat table with all items
|
||||
-- Return a gapless table with all items
|
||||
local function invlist_entries_as_list(list)
|
||||
local res = {}
|
||||
for _,items in ipairs(list) do
|
||||
local name = items:get_name()
|
||||
local count = items:get_count()
|
||||
if name ~= "" then
|
||||
for i = 1,count do
|
||||
res[#res+1] = name
|
||||
end
|
||||
if items:get_count() > 0 then
|
||||
res[#res+1] = {items:get_name(), items:get_count()}
|
||||
end
|
||||
end
|
||||
return res
|
||||
@ -68,14 +65,27 @@ end
|
||||
|
||||
local function AddToTbl(kvTbl, new_items)
|
||||
for _, l in ipairs(new_items) do
|
||||
kvTbl[l] = true
|
||||
kvTbl[l[1]] = true
|
||||
end
|
||||
return kvTbl
|
||||
end
|
||||
|
||||
|
||||
-- return the number of items to be pushed to an unconfigured slot
|
||||
local function num_items(moved_items, name, filter_item_names, rejected_item_names)
|
||||
if filter_item_names[name] == nil then -- not configured in one filter?
|
||||
if moved_items < MAX_NUM_PER_CYC then
|
||||
return math.min(4, MAX_NUM_PER_CYC - moved_items)
|
||||
end
|
||||
end
|
||||
if rejected_item_names[name] then -- rejected item from another slot?
|
||||
if moved_items < MAX_NUM_PER_CYC then
|
||||
return math.min(rejected_item_names[name], MAX_NUM_PER_CYC - moved_items)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
local function distributor_formspec(state, filter)
|
||||
return "size[10,8.5]"..
|
||||
return "size[10.5,8.5]"..
|
||||
default.gui_bg..
|
||||
default.gui_bg_img..
|
||||
default.gui_slots..
|
||||
@ -86,15 +96,15 @@ local function distributor_formspec(state, filter)
|
||||
"checkbox[3,1;filter2;On;"..dump(filter[2]).."]"..
|
||||
"checkbox[3,2;filter3;On;"..dump(filter[3]).."]"..
|
||||
"checkbox[3,3;filter4;On;"..dump(filter[4]).."]"..
|
||||
"image[3.6,0;0.3,1;tubelib_red.png]"..
|
||||
"image[3.6,1;0.3,1;tubelib_green.png]"..
|
||||
"image[3.6,2;0.3,1;tubelib_blue.png]"..
|
||||
"image[3.6,3;0.3,1;tubelib_yellow.png]"..
|
||||
"list[context;red;4,0;6,1;]"..
|
||||
"list[context;green;4,1;6,1;]"..
|
||||
"list[context;blue;4,2;6,1;]"..
|
||||
"list[context;yellow;4,3;6,1;]"..
|
||||
"list[current_player;main;1,4.5;8,4;]"..
|
||||
"image[4,0;0.3,1;tubelib_red.png]"..
|
||||
"image[4,1;0.3,1;tubelib_green.png]"..
|
||||
"image[4,2;0.3,1;tubelib_blue.png]"..
|
||||
"image[4,3;0.3,1;tubelib_yellow.png]"..
|
||||
"list[context;red;4.5,0;6,1;]"..
|
||||
"list[context;green;4.5,1;6,1;]"..
|
||||
"list[context;blue;4.5,2;6,1;]"..
|
||||
"list[context;yellow;4.5,3;6,1;]"..
|
||||
"list[current_player;main;1.25,4.5;8,4;]"..
|
||||
"listring[context;src]"..
|
||||
"listring[current_player;main]"
|
||||
end
|
||||
@ -109,8 +119,8 @@ local function allow_metadata_inventory_put(pos, listname, index, stack, player)
|
||||
end
|
||||
if listname == "src" then
|
||||
return stack:get_count()
|
||||
elseif invlist_num_entries(list) < NUM_FILTER_ELEM then
|
||||
return 1
|
||||
elseif invlist_num_entries(list) < MAX_NUM_PER_CYC then
|
||||
return stack:get_count()
|
||||
end
|
||||
return 0
|
||||
end
|
||||
@ -154,7 +164,8 @@ local function filter_settings(pos)
|
||||
|
||||
FilterCache[hash] = {
|
||||
kvFilterItemNames = kvFilterItemNames,
|
||||
kvSide2ItemNames = kvSide2ItemNames
|
||||
kvSide2ItemNames = kvSide2ItemNames,
|
||||
kvRejectedItemNames = {},
|
||||
}
|
||||
end
|
||||
|
||||
@ -225,25 +236,29 @@ local function keep_running(pos, elapsed)
|
||||
-- read data from Cache
|
||||
-- all filter items as key/value {<item:name> = true,...}
|
||||
local kvFilterItemNames = FilterCache[hash].kvFilterItemNames
|
||||
-- filter items of one slot as list {<item:name>,...}
|
||||
local names = FilterCache[hash].kvSide2ItemNames[side]
|
||||
-- filter items of one slot as list {{<item:name>, <num-items>},...}
|
||||
local items = FilterCache[hash].kvSide2ItemNames[side]
|
||||
-- rejected items from other filter slots
|
||||
local rejected = FilterCache[hash].kvRejectedItemNames
|
||||
|
||||
if names == nil then
|
||||
if items == nil then
|
||||
-- this slot is empty
|
||||
return true
|
||||
end
|
||||
|
||||
local busy = false
|
||||
-- move items from configured filters to the output
|
||||
if next(names) then
|
||||
for _,name in ipairs(names) do
|
||||
if next(items) then
|
||||
for _,item in ipairs(items) do
|
||||
local name, num = item[1], item[2]
|
||||
if kvSrc[name] then
|
||||
local item = tubelib.get_this_item(meta, "src", kvSrc[name]) -- <<=== tubelib
|
||||
local item = tubelib.get_this_item(meta, "src", kvSrc[name], num) -- <<=== tubelib
|
||||
if item then
|
||||
if not tubelib.push_items(pos, side, item, player_name) then -- <<=== tubelib
|
||||
tubelib.put_item(meta, "src", item)
|
||||
rejected[name] = num
|
||||
else
|
||||
counter[listname] = counter[listname] + 1
|
||||
counter[listname] = counter[listname] + num
|
||||
busy = true
|
||||
end
|
||||
end
|
||||
@ -252,20 +267,27 @@ local function keep_running(pos, elapsed)
|
||||
end
|
||||
|
||||
-- move additional items from unconfigured filters to the output
|
||||
if next(names) == nil then
|
||||
if next(items) == nil then
|
||||
local moved_items = 0
|
||||
for name,_ in pairs(kvSrc) do
|
||||
if kvFilterItemNames[name] == nil then -- not in the filter so far?
|
||||
local item = tubelib.get_this_item(meta, "src", kvSrc[name]) -- <<=== tubelib
|
||||
local num = num_items(moved_items, name, kvFilterItemNames, rejected)
|
||||
if num then
|
||||
local item = tubelib.get_this_item(meta, "src", kvSrc[name], num) -- <<=== tubelib
|
||||
if item then
|
||||
if not tubelib.push_items(pos, side, item, player_name) then -- <<=== tubelib
|
||||
tubelib.put_item(meta, "src", item)
|
||||
else
|
||||
counter[listname] = counter[listname] + 1
|
||||
moved_items = moved_items + num
|
||||
busy = true
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
-- delete list for next slot round
|
||||
if moved_items > 0 then
|
||||
FilterCache[hash].kvRejectedItemNames = {}
|
||||
end
|
||||
end
|
||||
|
||||
if busy == true then
|
||||
|
@ -45,12 +45,12 @@ minetest.register_node("tubelib_addons1:chest", {
|
||||
description = "Tubelib Protected Chest",
|
||||
tiles = {
|
||||
-- up, down, right, left, back, front
|
||||
"default_chest_top.png",
|
||||
"default_chest_top.png",
|
||||
"default_chest_side.png",
|
||||
"default_chest_side.png",
|
||||
"default_chest_side.png",
|
||||
"default_chest_lock.png",
|
||||
"default_chest_top.png^tubelib_addons1_frame.png",
|
||||
"default_chest_top.png^tubelib_addons1_frame.png",
|
||||
"default_chest_side.png^tubelib_addons1_frame.png",
|
||||
"default_chest_side.png^tubelib_addons1_frame.png",
|
||||
"default_chest_side.png^tubelib_addons1_frame.png",
|
||||
"default_chest_lock.png^tubelib_addons1_frame.png",
|
||||
},
|
||||
|
||||
on_construct = function(pos)
|
||||
@ -61,8 +61,10 @@ minetest.register_node("tubelib_addons1:chest", {
|
||||
|
||||
after_place_node = function(pos, placer)
|
||||
local meta = minetest.get_meta(pos)
|
||||
local number = tubelib.add_node(pos, "tubelib_addons1:chest")
|
||||
meta:set_string("number", number)
|
||||
meta:set_string("formspec", formspec())
|
||||
meta:set_string("infotext", "Tubelib Protected Chest")
|
||||
meta:set_string("infotext", "Tubelib Protected Chest "..number)
|
||||
end,
|
||||
|
||||
can_dig = function(pos,player)
|
||||
@ -76,6 +78,7 @@ minetest.register_node("tubelib_addons1:chest", {
|
||||
|
||||
on_dig = function(pos, node, puncher, pointed_thing)
|
||||
minetest.node_dig(pos, node, puncher, pointed_thing)
|
||||
tubelib.remove_node(pos)
|
||||
end,
|
||||
|
||||
allow_metadata_inventory_put = allow_metadata_inventory_put,
|
||||
@ -111,6 +114,11 @@ tubelib.register_node("tubelib_addons1:chest", {}, {
|
||||
end,
|
||||
|
||||
on_recv_message = function(pos, topic, payload)
|
||||
return "unsupported"
|
||||
if topic == "state" then
|
||||
local meta = minetest.get_meta(pos)
|
||||
return tubelib.fuelstate(meta, "main")
|
||||
else
|
||||
return "unsupported"
|
||||
end
|
||||
end,
|
||||
})
|
||||
|
@ -414,6 +414,10 @@ minetest.register_craft({
|
||||
|
||||
|
||||
tubelib.register_node("tubelib_addons1:harvester_base", {}, {
|
||||
on_pull_stack = function(pos, side)
|
||||
local meta = minetest.get_meta(pos)
|
||||
return tubelib.get_stack(meta, "main")
|
||||
end,
|
||||
on_pull_item = function(pos, side)
|
||||
local meta = minetest.get_meta(pos)
|
||||
return tubelib.get_item(meta, "main")
|
||||
|
@ -271,6 +271,12 @@ minetest.register_craftitem("tubelib_addons1:biofuel", {
|
||||
inventory_image = "tubelib_addons1_biofuel.png",
|
||||
})
|
||||
|
||||
minetest.register_craft({
|
||||
type = "fuel",
|
||||
recipe = "tubelib_addons1:biofuel",
|
||||
burntime = 12,
|
||||
})
|
||||
|
||||
|
||||
minetest.register_craft({
|
||||
output = "tubelib_addons1:reformer",
|
||||
|
BIN
tubelib_addons1/textures/tubelib_addons1_frame.png
Normal file
BIN
tubelib_addons1/textures/tubelib_addons1_frame.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 269 B |
@ -64,8 +64,10 @@ minetest.register_node("tubelib_addons3:chest", {
|
||||
|
||||
after_place_node = function(pos, placer)
|
||||
local meta = minetest.get_meta(pos)
|
||||
local number = tubelib.add_node(pos, "tubelib_addons3:chest")
|
||||
meta:set_string("number", number)
|
||||
meta:set_string("formspec", formspec())
|
||||
meta:set_string("infotext", "HighPerf Chest")
|
||||
meta:set_string("infotext", "HighPerf Chest "..number)
|
||||
end,
|
||||
|
||||
can_dig = function(pos,player)
|
||||
@ -79,6 +81,7 @@ minetest.register_node("tubelib_addons3:chest", {
|
||||
|
||||
on_dig = function(pos, node, puncher, pointed_thing)
|
||||
minetest.node_dig(pos, node, puncher, pointed_thing)
|
||||
tubelib.remove_node(pos)
|
||||
end,
|
||||
|
||||
allow_metadata_inventory_put = allow_metadata_inventory_put,
|
||||
@ -121,6 +124,11 @@ tubelib.register_node("tubelib_addons3:chest", {}, {
|
||||
end,
|
||||
|
||||
on_recv_message = function(pos, topic, payload)
|
||||
return "unsupported"
|
||||
if topic == "state" then
|
||||
local meta = minetest.get_meta(pos)
|
||||
return tubelib.fuelstate(meta, "main")
|
||||
else
|
||||
return "unsupported"
|
||||
end
|
||||
end,
|
||||
})
|
||||
|
Loading…
Reference in New Issue
Block a user