mirror of
https://github.com/joe7575/techpack.git
synced 2024-08-21 05:34:07 +02:00
V1.15 Controllers command added, chest commands improved
This commit is contained in:
parent
4d89c729a6
commit
c5048186d6
@ -1,4 +1,4 @@
|
|||||||
# TechPack V1.14
|
# TechPack V1.15
|
||||||
|
|
||||||
TechPack, a Mining, Crafting, & Farming Modpack for Minetest.
|
TechPack, a Mining, Crafting, & Farming Modpack for Minetest.
|
||||||
|
|
||||||
@ -93,6 +93,7 @@ tubelib_addons1 optional: unified_inventory
|
|||||||
- 2018-08-14 V1.12 * Teleporter node added
|
- 2018-08-14 V1.12 * Teleporter node added
|
||||||
- 2018-08-28 V1.13 * Smartline Controller completely revised. Liquid Sampler added
|
- 2018-08-28 V1.13 * Smartline Controller completely revised. Liquid Sampler added
|
||||||
- 2018-09-10 V1.14 * Distributor performance improved, chest commands added
|
- 2018-09-10 V1.14 * Distributor performance improved, chest commands added
|
||||||
|
- 2018-09-15 V1.15 * Smartline Controller command added, chest commands improved
|
||||||
|
|
||||||
|
|
||||||
See ![releasenotes.txt](https://github.com/joe7575/techpack/blob/master/releasenotes.md) for further information
|
See ![releasenotes.txt](https://github.com/joe7575/techpack/blob/master/releasenotes.md) for further information
|
@ -1,6 +1,25 @@
|
|||||||
# Release Notes of the ModPack TechPack [techpack]
|
# Release Notes of the ModPack TechPack [techpack]
|
||||||
|
|
||||||
|
|
||||||
|
## V1.15 (2018-09-15)
|
||||||
|
|
||||||
|
### Additions
|
||||||
|
- Tubelib has a new helper function "get_inv_state()" used by the chests.
|
||||||
|
- The Lua Controller got a new command "$get_player_action()" to read the chest player state.
|
||||||
|
- SmartLine Controller got a new command to turn Distributor filter ports on/off.
|
||||||
|
- Chests send on/off commands for each player interaction to a node with a predefined number.
|
||||||
|
- Chests support the "player_action" command request.
|
||||||
|
- Chests support the "set_number" Programmer command to program a node number.
|
||||||
|
|
||||||
|
### Changes
|
||||||
|
- Chests now return the state "empty", loader" **and** "full".
|
||||||
|
"full" is returned, when no empty stack is available.
|
||||||
|
|
||||||
|
### Fixes
|
||||||
|
- Distributor and HighPerf Distributor item counter bugfixes.
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
## V1.14 Beta (2018-09-10)
|
## V1.14 Beta (2018-09-10)
|
||||||
|
|
||||||
### Additions
|
### Additions
|
||||||
|
@ -36,6 +36,17 @@ sl_controller.register_function("get_status", {
|
|||||||
' example: sts = $get_status("1234")'
|
' example: sts = $get_status("1234")'
|
||||||
})
|
})
|
||||||
|
|
||||||
|
sl_controller.register_function("get_player_action", {
|
||||||
|
cmnd = function(self, num)
|
||||||
|
num = tostring(num or "")
|
||||||
|
return unpack(tubelib.send_request(num, "player_action", nil) or {"","",""})
|
||||||
|
end,
|
||||||
|
help = " $get_player_action(num) ,\n"..
|
||||||
|
" Read player action status from a Tubelib chest. See\n"..
|
||||||
|
" https://github.com/joe7575/techpack/wiki/nodes\n"..
|
||||||
|
' example: player, action, item = $get_player_action("1234")'
|
||||||
|
})
|
||||||
|
|
||||||
sl_controller.register_function("get_counter", {
|
sl_controller.register_function("get_counter", {
|
||||||
cmnd = function(self, num)
|
cmnd = function(self, num)
|
||||||
num = tostring(num or "")
|
num = tostring(num or "")
|
||||||
|
@ -524,3 +524,43 @@ smartline.icta_register_condition("playerdetector", {
|
|||||||
return "detector("..sl.fmt_number(data.number)..","..data.name:sub(1,8)..")"
|
return "detector("..sl.fmt_number(data.number)..","..data.name:sub(1,8)..")"
|
||||||
end,
|
end,
|
||||||
})
|
})
|
||||||
|
|
||||||
|
smartline.icta_register_action("set_filter", {
|
||||||
|
title = "turn Distributor filter on/off",
|
||||||
|
formspec = {
|
||||||
|
{
|
||||||
|
type = "numbers",
|
||||||
|
name = "number",
|
||||||
|
label = "distri number",
|
||||||
|
default = "",
|
||||||
|
},
|
||||||
|
{
|
||||||
|
type = "textlist",
|
||||||
|
name = "color",
|
||||||
|
label = "filter port",
|
||||||
|
choices = "red,green,blue,yellow",
|
||||||
|
default = "red",
|
||||||
|
},
|
||||||
|
{
|
||||||
|
type = "textlist",
|
||||||
|
name = "value",
|
||||||
|
label = "state",
|
||||||
|
choices = "on,off",
|
||||||
|
default = "on",
|
||||||
|
},
|
||||||
|
{
|
||||||
|
type = "label",
|
||||||
|
name = "lbl",
|
||||||
|
label = "turn Distributor filter port on/off\n",
|
||||||
|
},
|
||||||
|
},
|
||||||
|
button = function(data, environ)
|
||||||
|
return 'turn('..sl.fmt_number(data.number)..","..data.color..","..data.value..')'
|
||||||
|
end,
|
||||||
|
code = function(data, environ)
|
||||||
|
local payload = '{slot = "'..data.color..'", val = "'..data.value..'"}'
|
||||||
|
local s = 'tubelib.send_message("%s", "%s", nil, "filter", %s)'
|
||||||
|
return string.format(s, data.number, environ.owner, payload)
|
||||||
|
end,
|
||||||
|
})
|
||||||
|
|
||||||
|
@ -424,6 +424,27 @@ function tubelib.fuelstate(meta, listname, item)
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
-- Return "full", "loaded", or "empty" depending
|
||||||
|
-- on the inventory load.
|
||||||
|
-- Full is returned, when no empty stack is available.
|
||||||
|
function tubelib.get_inv_state(meta, listname)
|
||||||
|
if meta == nil or meta.get_inventory == nil then return nil end
|
||||||
|
local inv = meta:get_inventory()
|
||||||
|
local state
|
||||||
|
if inv:is_empty(listname) then
|
||||||
|
state = "empty"
|
||||||
|
else
|
||||||
|
local list = inv:get_list(listname)
|
||||||
|
state = "full"
|
||||||
|
local num = 0
|
||||||
|
for i, item in ipairs(list) do
|
||||||
|
if item:is_empty() then
|
||||||
|
return "loaded"
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
return state
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
-------------------------------------------------------------------------------
|
-------------------------------------------------------------------------------
|
||||||
|
@ -277,7 +277,7 @@ local function keep_running(pos, elapsed)
|
|||||||
if not tubelib.push_items(pos, side, item, player_name) then -- <<=== tubelib
|
if not tubelib.push_items(pos, side, item, player_name) then -- <<=== tubelib
|
||||||
tubelib.put_item(meta, "src", item)
|
tubelib.put_item(meta, "src", item)
|
||||||
else
|
else
|
||||||
counter[listname] = counter[listname] + 1
|
counter[listname] = counter[listname] + num
|
||||||
moved_items = moved_items + num
|
moved_items = moved_items + num
|
||||||
busy = true
|
busy = true
|
||||||
end
|
end
|
||||||
|
@ -12,12 +12,44 @@
|
|||||||
|
|
||||||
]]--
|
]]--
|
||||||
|
|
||||||
|
local PlayerActions = {}
|
||||||
|
local InventoryState = {}
|
||||||
|
|
||||||
|
|
||||||
|
local function store_action(pos, player, action, stack)
|
||||||
|
local meta = minetest.get_meta(pos)
|
||||||
|
local name = player and player:get_player_name() or ""
|
||||||
|
local number = meta:get_string("number")
|
||||||
|
local item = stack:get_name().." "..stack:get_count()
|
||||||
|
PlayerActions[number] = {name, action, item}
|
||||||
|
end
|
||||||
|
|
||||||
|
local function send_off_command(pos)
|
||||||
|
local meta = minetest.get_meta(pos)
|
||||||
|
local dest_num = meta:get_string("dest_num")
|
||||||
|
local own_num = meta:get_string("number")
|
||||||
|
local owner = meta:get_string("owner")
|
||||||
|
tubelib.send_message(dest_num, owner, nil, "off", own_num)
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
|
local function send_command(pos)
|
||||||
|
local meta = minetest.get_meta(pos)
|
||||||
|
local dest_num = meta:get_string("dest_num")
|
||||||
|
if dest_num ~= "" then
|
||||||
|
local own_num = meta:get_string("number")
|
||||||
|
local owner = meta:get_string("owner")
|
||||||
|
tubelib.send_message(dest_num, owner, nil, "on", own_num)
|
||||||
|
minetest.after(1, send_off_command, pos)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
local function allow_metadata_inventory_put(pos, listname, index, stack, player)
|
local function allow_metadata_inventory_put(pos, listname, index, stack, player)
|
||||||
if minetest.is_protected(pos, player:get_player_name()) then
|
if minetest.is_protected(pos, player:get_player_name()) then
|
||||||
return 0
|
return 0
|
||||||
end
|
end
|
||||||
minetest.log("action", player:get_player_name().." moves "..stack:get_name()..
|
store_action(pos, player, "put", stack)
|
||||||
" to chest at "..minetest.pos_to_string(pos))
|
send_command(pos)
|
||||||
return stack:get_count()
|
return stack:get_count()
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -25,8 +57,8 @@ local function allow_metadata_inventory_take(pos, listname, index, stack, player
|
|||||||
if minetest.is_protected(pos, player:get_player_name()) then
|
if minetest.is_protected(pos, player:get_player_name()) then
|
||||||
return 0
|
return 0
|
||||||
end
|
end
|
||||||
minetest.log("action", player:get_player_name().." takes "..stack:get_name()..
|
store_action(pos, player, "take", stack)
|
||||||
" from chest at "..minetest.pos_to_string(pos))
|
send_command(pos)
|
||||||
return stack:get_count()
|
return stack:get_count()
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -63,6 +95,7 @@ minetest.register_node("tubelib_addons1:chest", {
|
|||||||
local meta = minetest.get_meta(pos)
|
local meta = minetest.get_meta(pos)
|
||||||
local number = tubelib.add_node(pos, "tubelib_addons1:chest")
|
local number = tubelib.add_node(pos, "tubelib_addons1:chest")
|
||||||
meta:set_string("number", number)
|
meta:set_string("number", number)
|
||||||
|
meta:set_string("owner", placer:get_player_name())
|
||||||
meta:set_string("formspec", formspec())
|
meta:set_string("formspec", formspec())
|
||||||
meta:set_string("infotext", "Tubelib Protected Chest "..number)
|
meta:set_string("infotext", "Tubelib Protected Chest "..number)
|
||||||
end,
|
end,
|
||||||
@ -71,7 +104,7 @@ minetest.register_node("tubelib_addons1:chest", {
|
|||||||
if minetest.is_protected(pos, player:get_player_name()) then
|
if minetest.is_protected(pos, player:get_player_name()) then
|
||||||
return false
|
return false
|
||||||
end
|
end
|
||||||
local meta = minetest.get_meta(pos);
|
local meta = minetest.get_meta(pos)
|
||||||
local inv = meta:get_inventory()
|
local inv = meta:get_inventory()
|
||||||
return inv:is_empty("main")
|
return inv:is_empty("main")
|
||||||
end,
|
end,
|
||||||
@ -116,7 +149,19 @@ tubelib.register_node("tubelib_addons1:chest", {}, {
|
|||||||
on_recv_message = function(pos, topic, payload)
|
on_recv_message = function(pos, topic, payload)
|
||||||
if topic == "state" then
|
if topic == "state" then
|
||||||
local meta = minetest.get_meta(pos)
|
local meta = minetest.get_meta(pos)
|
||||||
return tubelib.fuelstate(meta, "main")
|
return tubelib.get_inv_state(meta, "main")
|
||||||
|
elseif topic == "player_action" then
|
||||||
|
local meta = minetest.get_meta(pos)
|
||||||
|
local number = meta:get_string("number")
|
||||||
|
return PlayerActions[number]
|
||||||
|
elseif topic == "set_numbers" then
|
||||||
|
if tubelib.check_numbers(payload) then
|
||||||
|
local meta = minetest.get_meta(pos)
|
||||||
|
meta:set_string("dest_num", payload)
|
||||||
|
local number = meta:get_string("number")
|
||||||
|
meta:set_string("infotext", "Tubelib Protected Chest "..number.." connected with "..payload)
|
||||||
|
return true
|
||||||
|
end
|
||||||
else
|
else
|
||||||
return "unsupported"
|
return "unsupported"
|
||||||
end
|
end
|
||||||
|
@ -14,13 +14,44 @@
|
|||||||
|
|
||||||
]]--
|
]]--
|
||||||
|
|
||||||
|
local PlayerActions = {}
|
||||||
|
local InventoryState = {}
|
||||||
|
|
||||||
|
|
||||||
|
local function store_action(pos, player, action, stack)
|
||||||
|
local meta = minetest.get_meta(pos)
|
||||||
|
local name = player and player:get_player_name() or ""
|
||||||
|
local number = meta:get_string("number")
|
||||||
|
local item = stack:get_name().." "..stack:get_count()
|
||||||
|
PlayerActions[number] = {name, action, item}
|
||||||
|
end
|
||||||
|
|
||||||
|
local function send_off_command(pos)
|
||||||
|
local meta = minetest.get_meta(pos)
|
||||||
|
local dest_num = meta:get_string("dest_num")
|
||||||
|
local own_num = meta:get_string("number")
|
||||||
|
local owner = meta:get_string("owner")
|
||||||
|
tubelib.send_message(dest_num, owner, nil, "off", own_num)
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
|
local function send_command(pos)
|
||||||
|
local meta = minetest.get_meta(pos)
|
||||||
|
local dest_num = meta:get_string("dest_num")
|
||||||
|
if dest_num ~= "" then
|
||||||
|
local own_num = meta:get_string("number")
|
||||||
|
local owner = meta:get_string("owner")
|
||||||
|
tubelib.send_message(dest_num, owner, nil, "on", own_num)
|
||||||
|
minetest.after(1, send_off_command, pos)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
local function allow_metadata_inventory_put(pos, listname, index, stack, player)
|
local function allow_metadata_inventory_put(pos, listname, index, stack, player)
|
||||||
if minetest.is_protected(pos, player:get_player_name()) then
|
if minetest.is_protected(pos, player:get_player_name()) then
|
||||||
return 0
|
return 0
|
||||||
end
|
end
|
||||||
minetest.log("action", player:get_player_name().." moves "..stack:get_name()..
|
store_action(pos, player, "put", stack)
|
||||||
" to chest at "..minetest.pos_to_string(pos))
|
send_command(pos)
|
||||||
return stack:get_count()
|
return stack:get_count()
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -28,8 +59,8 @@ local function allow_metadata_inventory_take(pos, listname, index, stack, player
|
|||||||
if minetest.is_protected(pos, player:get_player_name()) then
|
if minetest.is_protected(pos, player:get_player_name()) then
|
||||||
return 0
|
return 0
|
||||||
end
|
end
|
||||||
minetest.log("action", player:get_player_name().." takes "..stack:get_name()..
|
store_action(pos, player, "take", stack)
|
||||||
" from chest at "..minetest.pos_to_string(pos))
|
send_command(pos)
|
||||||
return stack:get_count()
|
return stack:get_count()
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -66,6 +97,7 @@ minetest.register_node("tubelib_addons3:chest", {
|
|||||||
local meta = minetest.get_meta(pos)
|
local meta = minetest.get_meta(pos)
|
||||||
local number = tubelib.add_node(pos, "tubelib_addons3:chest")
|
local number = tubelib.add_node(pos, "tubelib_addons3:chest")
|
||||||
meta:set_string("number", number)
|
meta:set_string("number", number)
|
||||||
|
meta:set_string("owner", placer:get_player_name())
|
||||||
meta:set_string("formspec", formspec())
|
meta:set_string("formspec", formspec())
|
||||||
meta:set_string("infotext", "HighPerf Chest "..number)
|
meta:set_string("infotext", "HighPerf Chest "..number)
|
||||||
end,
|
end,
|
||||||
@ -74,7 +106,7 @@ minetest.register_node("tubelib_addons3:chest", {
|
|||||||
if minetest.is_protected(pos, player:get_player_name()) then
|
if minetest.is_protected(pos, player:get_player_name()) then
|
||||||
return false
|
return false
|
||||||
end
|
end
|
||||||
local meta = minetest.get_meta(pos);
|
local meta = minetest.get_meta(pos)
|
||||||
local inv = meta:get_inventory()
|
local inv = meta:get_inventory()
|
||||||
return inv:is_empty("main")
|
return inv:is_empty("main")
|
||||||
end,
|
end,
|
||||||
@ -126,7 +158,19 @@ tubelib.register_node("tubelib_addons3:chest", {}, {
|
|||||||
on_recv_message = function(pos, topic, payload)
|
on_recv_message = function(pos, topic, payload)
|
||||||
if topic == "state" then
|
if topic == "state" then
|
||||||
local meta = minetest.get_meta(pos)
|
local meta = minetest.get_meta(pos)
|
||||||
return tubelib.fuelstate(meta, "main")
|
return tubelib.get_inv_state(meta, "main")
|
||||||
|
elseif topic == "player_action" then
|
||||||
|
local meta = minetest.get_meta(pos)
|
||||||
|
local number = meta:get_string("number")
|
||||||
|
return PlayerActions[number]
|
||||||
|
elseif topic == "set_numbers" then
|
||||||
|
if tubelib.check_numbers(payload) then
|
||||||
|
local meta = minetest.get_meta(pos)
|
||||||
|
meta:set_string("dest_num", payload)
|
||||||
|
local number = meta:get_string("number")
|
||||||
|
meta:set_string("infotext", "HighPerf Chest "..number.." connected with "..payload)
|
||||||
|
return true
|
||||||
|
end
|
||||||
else
|
else
|
||||||
return "unsupported"
|
return "unsupported"
|
||||||
end
|
end
|
||||||
|
@ -74,7 +74,7 @@ local function random_list_elem(list)
|
|||||||
end
|
end
|
||||||
|
|
||||||
local function distributor_formspec(state, filter)
|
local function distributor_formspec(state, filter)
|
||||||
return "size[10,8.5]"..
|
return "size[10.5,8.5]"..
|
||||||
default.gui_bg..
|
default.gui_bg..
|
||||||
default.gui_bg_img..
|
default.gui_bg_img..
|
||||||
default.gui_slots..
|
default.gui_slots..
|
||||||
@ -85,15 +85,15 @@ local function distributor_formspec(state, filter)
|
|||||||
"checkbox[3,1;filter2;On;"..dump(filter[2]).."]"..
|
"checkbox[3,1;filter2;On;"..dump(filter[2]).."]"..
|
||||||
"checkbox[3,2;filter3;On;"..dump(filter[3]).."]"..
|
"checkbox[3,2;filter3;On;"..dump(filter[3]).."]"..
|
||||||
"checkbox[3,3;filter4;On;"..dump(filter[4]).."]"..
|
"checkbox[3,3;filter4;On;"..dump(filter[4]).."]"..
|
||||||
"image[3.6,0;0.3,1;tubelib_red.png]"..
|
"image[4,0;0.3,1;tubelib_red.png]"..
|
||||||
"image[3.6,1;0.3,1;tubelib_green.png]"..
|
"image[4,1;0.3,1;tubelib_green.png]"..
|
||||||
"image[3.6,2;0.3,1;tubelib_blue.png]"..
|
"image[4,2;0.3,1;tubelib_blue.png]"..
|
||||||
"image[3.6,3;0.3,1;tubelib_yellow.png]"..
|
"image[4,3;0.3,1;tubelib_yellow.png]"..
|
||||||
"list[context;red;4,0;6,1;]"..
|
"list[context;red;4.5,0;6,1;]"..
|
||||||
"list[context;green;4,1;6,1;]"..
|
"list[context;green;4.5,1;6,1;]"..
|
||||||
"list[context;blue;4,2;6,1;]"..
|
"list[context;blue;4.5,2;6,1;]"..
|
||||||
"list[context;yellow;4,3;6,1;]"..
|
"list[context;yellow;4.5,3;6,1;]"..
|
||||||
"list[current_player;main;1,4.5;8,4;]"..
|
"list[current_player;main;1.25,4.5;8,4;]"..
|
||||||
"listring[context;src]"..
|
"listring[context;src]"..
|
||||||
"listring[current_player;main]"
|
"listring[current_player;main]"
|
||||||
end
|
end
|
||||||
@ -240,6 +240,7 @@ local function keep_running(pos, elapsed)
|
|||||||
|
|
||||||
if stack:get_count() > 0 then
|
if stack:get_count() > 0 then
|
||||||
local name = stack:get_name()
|
local name = stack:get_name()
|
||||||
|
local num = stack:get_count()
|
||||||
local second_try = false
|
local second_try = false
|
||||||
-- try configured output ports
|
-- try configured output ports
|
||||||
local side = random_list_elem(kvFilterItemNames[name])
|
local side = random_list_elem(kvFilterItemNames[name])
|
||||||
@ -247,7 +248,7 @@ local function keep_running(pos, elapsed)
|
|||||||
if tubelib.push_items(pos, side, stack, player_name) then
|
if tubelib.push_items(pos, side, stack, player_name) then
|
||||||
stack:set_count(0)
|
stack:set_count(0)
|
||||||
local color = Side2Color[side]
|
local color = Side2Color[side]
|
||||||
counter[color] = counter[color] + 1
|
counter[color] = counter[color] + num
|
||||||
busy = true
|
busy = true
|
||||||
else
|
else
|
||||||
second_try = true -- port blocked
|
second_try = true -- port blocked
|
||||||
@ -263,7 +264,7 @@ local function keep_running(pos, elapsed)
|
|||||||
if tubelib.push_items(pos, side, stack, player_name) then
|
if tubelib.push_items(pos, side, stack, player_name) then
|
||||||
stack:set_count(0)
|
stack:set_count(0)
|
||||||
local color = Side2Color[side]
|
local color = Side2Color[side]
|
||||||
counter[color] = counter[color] + 1
|
counter[color] = counter[color] + num
|
||||||
busy = true
|
busy = true
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
Loading…
Reference in New Issue
Block a user