ta4 injector added, ta4 pusher and distributor changed, maintenance and minor bugfixes

This commit is contained in:
Joachim Stolberg 2020-04-25 21:06:19 +02:00
parent bf07927382
commit 9a4a8c58c2
29 changed files with 637 additions and 182 deletions

View File

@ -47,7 +47,7 @@ local function formspec(self, pos, nvm)
"listring[current_player;main]".. "listring[current_player;main]"..
"listring[context;dst]" .. "listring[context;dst]" ..
"listring[current_player;main]".. "listring[current_player;main]"..
default.get_hotbar_bg(0, 4) default.get_hotbar_bg(0, 5.4)
end end
local function count_index(invlist) local function count_index(invlist)

View File

@ -16,6 +16,9 @@
local M = minetest.get_meta local M = minetest.get_meta
local S = techage.S local S = techage.S
local MP = minetest.get_modpath(minetest.get_current_modname())
local mConf = dofile(MP.."/basis/conf_inv.lua")
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
@ -145,17 +148,95 @@ minetest.register_node("techage:chest_ta3", {
sounds = default.node_sound_wood_defaults(), sounds = default.node_sound_wood_defaults(),
}) })
local function formspec4() techage.register_node({"techage:chest_ta2", "techage:chest_ta3"}, {
on_pull_item = function(pos, in_dir, num, item_name)
local meta = minetest.get_meta(pos)
local inv = meta:get_inventory()
return techage.get_items(pos, inv, "main", num)
end,
on_push_item = function(pos, in_dir, stack)
local meta = minetest.get_meta(pos)
local inv = meta:get_inventory()
return techage.put_items(inv, "main", stack)
end,
on_unpull_item = function(pos, in_dir, stack)
local meta = minetest.get_meta(pos)
local inv = meta:get_inventory()
return techage.put_items(inv, "main", stack)
end,
on_recv_message = function(pos, src, topic, payload)
if topic == "state" then
local meta = minetest.get_meta(pos)
local inv = meta:get_inventory()
return techage.get_inv_state(inv, "main")
else
return "unsupported"
end
end,
})
local function formspec4(pos)
return "size[10,9]".. return "size[10,9]"..
"tabheader[0,0;tab;"..S("Inventory,Configuration")..";1;;true]"..
default.gui_bg.. default.gui_bg..
default.gui_bg_img.. default.gui_bg_img..
default.gui_slots.. default.gui_slots..
"list[context;main;0,0;10,5;]".. "list[context;main;0,0;10,5;]"..
mConf.preassigned_stacks(pos, 10, 5)..
"list[current_player;main;1,5.3;8,4;]".. "list[current_player;main;1,5.3;8,4;]"..
"listring[context;main]".. "listring[context;main]"..
"listring[current_player;main]" "listring[current_player;main]"
end end
local function formspec4_cfg(pos)
return "size[10,9]"..
"tabheader[0,0;tab;"..S("Inventory,Configuration")..";2;;true]"..
default.gui_bg..
default.gui_bg_img..
default.gui_slots..
"list[context;conf;0,0;10,5;]"..
"list[current_player;main;1,5.3;8,4;]"..
"listring[context;conf]"..
"listring[current_player;main]"
end
local function ta4_allow_metadata_inventory_put(pos, listname, index, stack, player)
if minetest.is_protected(pos, player:get_player_name()) then
return 0
end
if listname == "main" then
return stack:get_count()
else
return mConf.allow_conf_inv_put(pos, listname, index, stack, player)
end
end
local function ta4_allow_metadata_inventory_take(pos, listname, index, stack, player)
if minetest.is_protected(pos, player:get_player_name()) then
return 0
end
if listname == "main" then
return stack:get_count()
else
return mConf.allow_conf_inv_take(pos, listname, index, stack, player)
end
end
local function ta4_allow_metadata_inventory_move(pos, from_list, from_index, to_list, to_index, count, player)
if minetest.is_protected(pos, player:get_player_name()) then
return 0
end
if from_list == "main" then
return count
else
return mConf.allow_conf_inv_move(pos, from_list, from_index, to_list, to_index, count, player)
end
end
minetest.register_node("techage:chest_ta4", { minetest.register_node("techage:chest_ta4", {
description = S("TA4 Protected Chest"), description = S("TA4 Protected Chest"),
tiles = { tiles = {
@ -172,6 +253,7 @@ minetest.register_node("techage:chest_ta4", {
local meta = minetest.get_meta(pos) local meta = minetest.get_meta(pos)
local inv = meta:get_inventory() local inv = meta:get_inventory()
inv:set_size('main', 50) inv:set_size('main', 50)
inv:set_size('conf', 50)
end, end,
after_place_node = function(pos, placer) after_place_node = function(pos, placer)
@ -179,18 +261,36 @@ minetest.register_node("techage:chest_ta4", {
local number = techage.add_node(pos, "techage:chest_ta4") local number = techage.add_node(pos, "techage:chest_ta4")
meta:set_string("node_number", number) meta:set_string("node_number", number)
meta:set_string("owner", placer:get_player_name()) meta:set_string("owner", placer:get_player_name())
meta:set_string("formspec", formspec4()) meta:set_string("formspec", formspec4(pos))
meta:set_string("infotext", S("TA4 Protected Chest").." "..number) meta:set_string("infotext", S("TA4 Protected Chest").." "..number)
end, end,
on_receive_fields = function(pos, formname, fields, player)
if minetest.is_protected(pos, player:get_player_name()) then
return
end
local meta = minetest.get_meta(pos)
local mem = techage.get_mem(pos)
if fields.tab == "1" then
mem.filter = nil
meta:set_string("formspec", formspec4(pos))
elseif fields.tab == "2" then
meta:set_string("formspec", formspec4_cfg(pos))
elseif fields.quit == "true" then
mem.filter = nil
end
end,
techage_set_numbers = function(pos, numbers, player_name) techage_set_numbers = function(pos, numbers, player_name)
return techage.logic.set_numbers(pos, numbers, player_name, S("TA4 Protected Chest")) return techage.logic.set_numbers(pos, numbers, player_name, S("TA4 Protected Chest"))
end, end,
can_dig = can_dig, can_dig = can_dig,
after_dig_node = after_dig_node, after_dig_node = after_dig_node,
allow_metadata_inventory_put = allow_metadata_inventory_put, allow_metadata_inventory_put = ta4_allow_metadata_inventory_put,
allow_metadata_inventory_take = allow_metadata_inventory_take, allow_metadata_inventory_take = ta4_allow_metadata_inventory_take,
allow_metadata_inventory_move = ta4_allow_metadata_inventory_move,
paramtype2 = "facedir", paramtype2 = "facedir",
groups = {choppy=2, cracky=2, crumbly=2}, groups = {choppy=2, cracky=2, crumbly=2},
@ -198,28 +298,68 @@ minetest.register_node("techage:chest_ta4", {
sounds = default.node_sound_wood_defaults(), sounds = default.node_sound_wood_defaults(),
}) })
techage.register_node({"techage:chest_ta2", "techage:chest_ta3", "techage:chest_ta4"}, {
techage.register_node({"techage:chest_ta4"}, {
on_pull_item = function(pos, in_dir, num, item_name) on_pull_item = function(pos, in_dir, num, item_name)
local meta = minetest.get_meta(pos) local meta = minetest.get_meta(pos)
local inv = meta:get_inventory() local inv = meta:get_inventory()
if item_name and inv:get_size("main") == 50 then -- TA4 chest? local mem = techage.get_mem(pos)
local taken = inv:remove_item("main", {name = item_name, count = num}) mem.filter = mem.filter or mConf.item_filter(pos, 50)
if taken:get_count() > 0 then mem.chest_configured = mem.chest_configured or #mem.filter["unconfigured"] < 50
return taken
if inv:is_empty("main") then
return nil
end
if item_name then
if mem.filter[item_name] then -- configured item
local taken = inv:remove_item("main", {name = item_name, count = num})
if taken:get_count() > 0 then
return taken
end
elseif not mem.chest_configured then
local taken = inv:remove_item("main", {name = item_name, count = num})
if taken:get_count() > 0 then
return taken
end
end
else -- no item given
if mem.chest_configured then
return mConf.take_item(pos, inv, "main", num, mem.filter["unconfigured"] or {})
else
return techage.get_items(pos, inv, "main", num)
end end
else
return techage.get_items(pos, inv, "main", num)
end end
end, end,
on_push_item = function(pos, in_dir, stack) on_push_item = function(pos, in_dir, item, idx)
local meta = minetest.get_meta(pos) local meta = minetest.get_meta(pos)
local inv = meta:get_inventory() local inv = meta:get_inventory()
return techage.put_items(inv, "main", stack) local mem = techage.get_mem(pos)
mem.filter = mem.filter or mConf.item_filter(pos, 50)
mem.chest_configured = mem.chest_configured or #mem.filter["unconfigured"] < 50
if mem.chest_configured then
local name = item:get_name()
local stacks = mem.filter[name] or mem.filter["unconfigured"]
return mConf.put_items(pos, inv, "main", item, stacks, idx)
else
return techage.put_items(inv, "main", item, idx)
end
end, end,
on_unpull_item = function(pos, in_dir, stack) on_unpull_item = function(pos, in_dir, stack)
local meta = minetest.get_meta(pos) local meta = minetest.get_meta(pos)
local inv = meta:get_inventory() local inv = meta:get_inventory()
return techage.put_items(inv, "main", stack) local mem = techage.get_mem(pos)
mem.filter = mem.filter or mConf.item_filter(pos, 50)
mem.chest_configured = mem.chest_configured or #mem.filter["unconfigured"] < 50
if mem.chest_configured then
local name = item:get_name()
local stacks = mem.filter[name] or mem.filter["unconfigured"]
return mConf.put_items(pos, inv, "main", item, stacks)
else
return techage.put_items(inv, "main", item)
end
end, end,
on_recv_message = function(pos, src, topic, payload) on_recv_message = function(pos, src, topic, payload)

View File

@ -219,7 +219,7 @@ function techage.register_consumer(base_name, inv_name, tiles, tNode, validState
selection_box = tNode.selection_box, selection_box = tNode.selection_box,
can_dig = tNode.can_dig, can_dig = tNode.can_dig,
on_rotate = screwdriver.disallow, on_rotate = tNode.on_rotate or screwdriver.disallow,
on_timer = node_timer, on_timer = node_timer,
on_receive_fields = tNode.on_receive_fields, on_receive_fields = tNode.on_receive_fields,
on_rightclick = tNode.on_rightclick, on_rightclick = tNode.on_rightclick,
@ -251,7 +251,7 @@ function techage.register_consumer(base_name, inv_name, tiles, tNode, validState
node_box = tNode.node_box, node_box = tNode.node_box,
selection_box = tNode.selection_box, selection_box = tNode.selection_box,
on_rotate = screwdriver.disallow, on_rotate = tNode.on_rotate or screwdriver.disallow,
on_timer = node_timer, on_timer = node_timer,
on_receive_fields = tNode.on_receive_fields, on_receive_fields = tNode.on_receive_fields,
on_rightclick = tNode.on_rightclick, on_rightclick = tNode.on_rightclick,

View File

@ -41,8 +41,6 @@ local function filter_settings(pos)
local filter = minetest.deserialize(meta:get_string("filter")) or {false,false,false,false} local filter = minetest.deserialize(meta:get_string("filter")) or {false,false,false,false}
local ItemFilter = {} -- {<item:name> = {dir,...}] local ItemFilter = {} -- {<item:name> = {dir,...}]
local OpenPorts = {} -- {dir, ...} local OpenPorts = {} -- {dir, ...}
local FilterItems = {} -- {<item:name>, <item:name>, ...} for sequencing only
local FilterItemIdx = {} -- {<item:name> = <slot-idx>, <item:name> = <slot-idx>, ...} for sequencing only
-- collect all filter settings -- collect all filter settings
for idx,slot in ipairs(SlotColors) do for idx,slot in ipairs(SlotColors) do
if filter[idx] == true then if filter[idx] == true then
@ -58,8 +56,6 @@ local function filter_settings(pos)
ItemFilter[name] = {} ItemFilter[name] = {}
end end
table.insert(ItemFilter[name], out_dir) table.insert(ItemFilter[name], out_dir)
table.insert(FilterItems, name)
FilterItemIdx[name] = idx2
end end
end end
end end
@ -69,8 +65,6 @@ local function filter_settings(pos)
FilterCache[minetest.hash_node_position(pos)] = { FilterCache[minetest.hash_node_position(pos)] = {
ItemFilter = ItemFilter, ItemFilter = ItemFilter,
OpenPorts = OpenPorts, OpenPorts = OpenPorts,
FilterItems = FilterItems,
FilterItemIdx = FilterItemIdx,
} }
end end
@ -82,40 +76,13 @@ local function get_filter_settings(pos)
-- ["default:cobble"] = {4}, -- ["default:cobble"] = {4},
-- } -- }
-- local OpenPorts = {3} -- local OpenPorts = {3}
-- local FilterItems = {"default:dirt",...} -- return ItemFilter, OpenPorts
-- return ItemFilter, OpenPorts, FilterItems
local hash = minetest.hash_node_position(pos) local hash = minetest.hash_node_position(pos)
if FilterCache[hash] == nil then if FilterCache[hash] == nil then
filter_settings(pos) filter_settings(pos)
end end
return FilterCache[hash].ItemFilter, FilterCache[hash].OpenPorts, FilterCache[hash].FilterItems return FilterCache[hash].ItemFilter, FilterCache[hash].OpenPorts
end
local function get_slot_index(pos, name)
local hash = minetest.hash_node_position(pos)
if FilterCache[hash] == nil then
filter_settings(pos)
end
return FilterCache[hash].FilterItemIdx[name]
end
local function order_checkbox(pos, filter)
local cnt = 0
if CRD(pos).stage == 2 then return "" end
for _,val in ipairs(filter) do
if val then cnt = cnt + 1 end
end
if cnt == 1 then
local order = M(pos):get_int("order") == 1 and "true" or "false"
return "checkbox[2,0;order;1:1;"..order.."]"..
"tooltip[2,0;1,1;"..S("Force order of filter items")..";#0C3D32;#FFFFFF]"
else
M(pos):set_int("order", 0) -- disable sequencing
end
return ""
end end
local function blocking_checkbox(pos, filter) local function blocking_checkbox(pos, filter)
@ -127,8 +94,8 @@ local function blocking_checkbox(pos, filter)
end end
if cnt > 1 and #open_ports > 0 then if cnt > 1 and #open_ports > 0 then
local blocking = M(pos):get_int("blocking") == 1 and "true" or "false" local blocking = M(pos):get_int("blocking") == 1 and "true" or "false"
return "checkbox[2,0;blocking;>>|;"..blocking.."]".. return "checkbox[3,3.9;blocking;"..S("blocking mode")..";"..blocking.."]"..
"tooltip[2,0;1,1;"..S("Block configured items for open ports")..";#0C3D32;#FFFFFF]" "tooltip[3,3.9;1,1;"..S("Block configured items for open ports")..";#0C3D32;#FFFFFF]"
else else
M(pos):set_int("blocking", 0) -- disable blocking M(pos):set_int("blocking", 0) -- disable blocking
end end
@ -137,18 +104,16 @@ end
local function formspec(self, pos, nvm) local function formspec(self, pos, nvm)
local filter = minetest.deserialize(M(pos):get_string("filter")) or {false,false,false,false} local filter = minetest.deserialize(M(pos):get_string("filter")) or {false,false,false,false}
local order = order_checkbox(pos, filter)
local blocking = blocking_checkbox(pos, filter) local blocking = blocking_checkbox(pos, filter)
return "size[10.5,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..
"list[context;src;0,0;2,4;]".. "list[context;src;0,0;2,4;]"..
order..
blocking.. blocking..
"image[2,1.5;1,1;techage_form_arrow.png]".. "image[2,1.5;1,1;techage_form_arrow.png]"..
"image_button[2,3;1,1;"..self:get_state_button_image(nvm)..";state_button;]".. "image_button[0,4.8;1,1;"..self:get_state_button_image(nvm)..";state_button;]"..
"tooltip[2,3;1,1;"..self:get_state_tooltip(nvm).."]".. "tooltip[0,4.8;1,1;"..self:get_state_tooltip(nvm).."]"..
"checkbox[3,0;filter1;On;"..dump(filter[1]).."]".. "checkbox[3,0;filter1;On;"..dump(filter[1]).."]"..
"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]).."]"..
@ -161,10 +126,10 @@ local function formspec(self, pos, nvm)
"list[context;green;4.5,1;6,1;]".. "list[context;green;4.5,1;6,1;]"..
"list[context;blue;4.5,2;6,1;]".. "list[context;blue;4.5,2;6,1;]"..
"list[context;yellow;4.5,3;6,1;]".. "list[context;yellow;4.5,3;6,1;]"..
"list[current_player;main;1.25,4.5;8,4;]".. "list[current_player;main;1.25,4.8;8,4;]"..
"listring[context;src]".. "listring[context;src]"..
"listring[current_player;main]".. "listring[current_player;main]"..
default.get_hotbar_bg(1.25,4.5) default.get_hotbar_bg(1.25,4.8)
end end
local function allow_metadata_inventory_put(pos, listname, index, stack, player) local function allow_metadata_inventory_put(pos, listname, index, stack, player)
@ -284,41 +249,7 @@ local function distributing(pos, inv, crd, nvm)
if num_pushed == 0 then if num_pushed == 0 then
crd.State:blocked(pos, nvm) crd.State:blocked(pos, nvm)
else else
crd.State:keep_running(pos, nvm, COUNTDOWN_TICKS, sum_num_pushed) crd.State:keep_running(pos, nvm, COUNTDOWN_TICKS)
end
end
local function sequencing(pos, inv, crd, nvm)
local _,open_ports, filter_items = get_filter_settings(pos)
local offs = nvm.last_index or 1
local num_filters = 0 -- already processed
local num_pushed = 0
local push_dir = open_ports[1] or 1
local blocked = true
while num_pushed < crd.num_items and num_filters < 7 do
local stack = filter_items[offs] and ItemStack(filter_items[offs])
if stack then
if not inv:contains_item("src", stack) then
break
end
if techage.push_items(pos, push_dir, stack, offs) then
num_pushed = num_pushed + 1
inv:remove_item("src", stack)
blocked = false
end
end
offs = (offs % 6) + 1
num_filters = num_filters + 1
end
nvm.last_index = offs
if blocked then
crd.State:blocked(pos, nvm)
elseif num_pushed == 0 then
crd.State:standby(pos, nvm)
else
crd.State:keep_running(pos, nvm, COUNTDOWN_TICKS, num_pushed)
end end
end end
@ -329,11 +260,7 @@ local function keep_running(pos, elapsed)
local crd = CRD(pos) local crd = CRD(pos)
local inv = M(pos):get_inventory() local inv = M(pos):get_inventory()
if not inv:is_empty("src") then if not inv:is_empty("src") then
if M(pos):get_int("order") == 1 then distributing(pos, inv, crd, nvm)
sequencing(pos, inv, crd, nvm)
else
distributing(pos, inv, crd, nvm)
end
else else
crd.State:idle(pos, nvm) crd.State:idle(pos, nvm)
end end
@ -355,10 +282,6 @@ local function on_receive_fields(pos, formname, fields, player)
filter[3] = fields.filter3 == "true" filter[3] = fields.filter3 == "true"
elseif fields.filter4 ~= nil then elseif fields.filter4 ~= nil then
filter[4] = fields.filter4 == "true" filter[4] = fields.filter4 == "true"
elseif fields.order ~= nil and CRD(pos).stage > 2 then
meta:set_int("order", fields.order == "true" and 1 or 0)
local nvm = techage.get_nvm(pos)
nvm.last_index = 1 -- start from the beginning
elseif fields.blocking ~= nil then elseif fields.blocking ~= nil then
meta:set_int("blocking", fields.blocking == "true" and 1 or 0) meta:set_int("blocking", fields.blocking == "true" and 1 or 0)
end end
@ -431,26 +354,6 @@ tiles.act = {
"techage_filling_ta#.png^techage_frame_ta#.png^techage_appl_distri_blue.png", "techage_filling_ta#.png^techage_frame_ta#.png^techage_appl_distri_blue.png",
} }
local function put_items(pos, item)
local order = M(pos):get_int("order") == 1
local inv = M(pos):get_inventory()
if order then
local name = item:get_name()
local idx = get_slot_index(pos, name)
if idx then
local stack = inv:get_stack("src", idx)
if stack:item_fits(item) then
stack:add_item(item)
inv:set_stack("src", idx, stack)
return true
end
end
return false
else
return techage.put_items(inv, "src", item)
end
end
local tubing = { local tubing = {
on_pull_item = function(pos, in_dir, num) on_pull_item = function(pos, in_dir, num)
local inv = M(pos):get_inventory() local inv = M(pos):get_inventory()
@ -458,10 +361,12 @@ local tubing = {
end, end,
on_push_item = function(pos, in_dir, stack) on_push_item = function(pos, in_dir, stack)
CRD(pos).State:start_if_standby(pos) CRD(pos).State:start_if_standby(pos)
return put_items(pos, stack) local inv = M(pos):get_inventory()
return techage.put_items(inv, "src", stack)
end, end,
on_unpull_item = function(pos, in_dir, stack) on_unpull_item = function(pos, in_dir, stack)
return put_items(pos, stack) local inv = M(pos):get_inventory()
return techage.put_items(inv, "src", stack)
end, end,
on_recv_message = function(pos, src, topic, payload) on_recv_message = function(pos, src, topic, payload)
if topic == "info" then if topic == "info" then
@ -528,7 +433,7 @@ local node_name_ta2, node_name_ta3, node_name_ta4 =
groups = {choppy=2, cracky=2, crumbly=2}, groups = {choppy=2, cracky=2, crumbly=2},
sounds = default.node_sound_wood_defaults(), sounds = default.node_sound_wood_defaults(),
num_items = {0,4,12,36}, num_items = {0,4,12,24},
}) })
minetest.register_craft({ minetest.register_craft({

View File

@ -219,7 +219,7 @@ local node_name_ta2, node_name_ta3, node_name_ta4 =
groups = {choppy=2, cracky=2, crumbly=2}, groups = {choppy=2, cracky=2, crumbly=2},
sounds = default.node_sound_wood_defaults(), sounds = default.node_sound_wood_defaults(),
num_items = {0,1,1,1}, num_items = {0,1,1,1},
power_consumption = {0,8,12,18}, power_consumption = {0,8,12,12},
}, },
{false, true, true, true}) -- TA2/TA3/TA4 {false, true, true, true}) -- TA2/TA3/TA4

View File

@ -42,7 +42,7 @@ local function ta4_formspec(self, pos, nvm)
"box[0,-0.1;7.8,0.5;#c6e8ff]".. "box[0,-0.1;7.8,0.5;#c6e8ff]"..
"label[3,-0.1;"..minetest.colorize("#000000", S("Pusher")).."]".. "label[3,-0.1;"..minetest.colorize("#000000", S("Pusher")).."]"..
techage.question_mark_help(8, S("Optionally configure\nthe pusher with one item")).. techage.question_mark_help(8, S("Optionally configure\nthe pusher with one item"))..
"list[context;main;3.5,1;1,1;]".. "list[context;main;3.5,0.8;1,1;]"..
"image_button[3.5,2;1,1;".. self:get_state_button_image(nvm) ..";state_button;]".. "image_button[3.5,2;1,1;".. self:get_state_button_image(nvm) ..";state_button;]"..
"tooltip[3.5,2;1,1;"..self:get_state_tooltip(nvm).."]".. "tooltip[3.5,2;1,1;"..self:get_state_tooltip(nvm).."]"..
"list[current_player;main;0,3.5;8,4;]".. "list[current_player;main;0,3.5;8,4;]"..

View File

@ -205,7 +205,7 @@ local function quarry_task(pos, crd, nvm)
if item_name then if item_name then
if add_to_inv(pos, item_name) then if add_to_inv(pos, item_name) then
minetest.remove_node(qpos) minetest.remove_node(qpos)
crd.State:keep_running(pos, nvm, COUNTDOWN_TICKS, 1) crd.State:keep_running(pos, nvm, COUNTDOWN_TICKS)
else else
crd.State:blocked(pos, nvm, S("inventory full")) crd.State:blocked(pos, nvm, S("inventory full"))
end end

View File

@ -157,6 +157,22 @@ local function get_item(pos, nvm, item_name, count)
end end
end end
end end
elseif M(pos):get_int("priority") == 1 then
-- Take any items. The position within the inventory is from right to left
for idx = 8,1,-1 do
local item = nvm.inventory[idx]
if item.name ~= "" and (stack.name == nil or stack.name == item.name) then
local num = math.min(item.count, count - stack.count, max_stacksize(item.name))
if M(pos):get_int("assignment") == 1 and num == item.count then
-- never take the last item
num = num - 1
end
stack = move_items_to_stack(item, stack, num)
if stack.count == count then
return ItemStack(stack)
end
end
end
else else
-- Take any items. The position within the inventory -- Take any items. The position within the inventory
-- is incremented each time so that different item stacks will be considered. -- is incremented each time so that different item stacks will be considered.
@ -212,17 +228,20 @@ local function formspec(pos)
local inv = M(pos):get_inventory() local inv = M(pos):get_inventory()
local size = get_stacksize(pos) local size = get_stacksize(pos)
local assignment = M(pos):get_int("assignment") == 1 and "true" or "false" local assignment = M(pos):get_int("assignment") == 1 and "true" or "false"
return "size[8,8]".. local priority = M(pos):get_int("priority") == 1 and "true" or "false"
return "size[8,8.3]"..
default.gui_bg.. default.gui_bg..
default.gui_bg_img.. default.gui_bg_img..
default.gui_slots.. default.gui_slots..
formspec_container(0, 0, nvm, inv).. formspec_container(0, 0, nvm, inv)..
"button[1,3;2,1;unlock;"..S("Unlock").."]".. "button[0,3.5;3,1;unlock;"..S("Unlock").."]"..
"tooltip[1,3;2,1;"..S("Unlock connected chest\nif all slots are below 2000")..";#0C3D32;#FFFFFF]".. "tooltip[0,3.5;3,1;"..S("Unlock connected chest\nif all slots are below 2000")..";#0C3D32;#FFFFFF]"..
"label[4,3;"..S("Size")..": 8x"..size.."]".. "label[0,3;"..S("Size")..": 8x"..size.."]"..
"checkbox[4,3.3;assignment;"..S("keep assignment")..";"..assignment.."]".. "checkbox[4,3;assignment;"..S("keep assignment")..";"..assignment.."]"..
"tooltip[4,3.5;2,0.6;"..S("Never completely empty the slots\nwith the pusher to keep the items assignment")..";#0C3D32;#FFFFFF]".. "tooltip[4,3;2,0.6;"..S("Never completely empty the slots\nwith the pusher to keep the item assignment")..";#0C3D32;#FFFFFF]"..
"list[current_player;main;0,4.3;8,4;]".. "checkbox[4,3.6;priority;"..S("right to left")..";"..priority.."]"..
"tooltip[4,3.6;2,0.6;"..S("Empty the slots always \nfrom right to left")..";#0C3D32;#FFFFFF]"..
"list[current_player;main;0,4.6;8,4;]"..
"listring[context;main]".. "listring[context;main]"..
"listring[current_player;main]" "listring[current_player;main]"
end end
@ -392,6 +411,10 @@ local function on_receive_fields(pos, formname, fields, player)
if fields.assignment then if fields.assignment then
M(pos):set_int("assignment", fields.assignment == "true" and 1 or 0) M(pos):set_int("assignment", fields.assignment == "true" and 1 or 0)
end end
if fields.priority then
M(pos):set_int("priority", fields.priority == "true" and 1 or 0)
end
M(pos):set_string("formspec", formspec(pos)) M(pos):set_string("formspec", formspec(pos))
end end
@ -404,6 +427,14 @@ local function can_dig(pos, player)
return inv:is_empty("main") and inv_empty(nvm) return inv:is_empty("main") and inv_empty(nvm)
end end
local function on_rotate(pos, node, user, mode, new_param2)
if get_stacksize(pos) == STACK_SIZE then
return screwdriver.rotate_simple(pos, node, user, mode, new_param2)
else
return screwdriver.disallow(pos, node, user, mode, new_param2)
end
end
local function after_dig_node(pos, oldnode, oldmetadata, digger) local function after_dig_node(pos, oldnode, oldmetadata, digger)
techage.remove_node(pos) techage.remove_node(pos)
convert_to_chest_again(pos, oldnode, digger) convert_to_chest_again(pos, oldnode, digger)
@ -445,6 +476,7 @@ minetest.register_node("techage:ta4_chest", {
return techage.logic.set_numbers(pos, numbers, player_name, DESCRIPTION) return techage.logic.set_numbers(pos, numbers, player_name, DESCRIPTION)
end, end,
on_rotate = on_rotate,
on_rightclick = on_rightclick, on_rightclick = on_rightclick,
on_receive_fields = on_receive_fields, on_receive_fields = on_receive_fields,
can_dig = can_dig, can_dig = can_dig,

View File

@ -0,0 +1,214 @@
--[[
TechAge
=======
Copyright (C) 2020 Joachim Stolberg
GPL v3
See LICENSE.txt for more information
TA4 Injector
]]--
-- for lazy programmers
local M = minetest.get_meta
local S = techage.S
-- Consumer Related Data
local CRD = function(pos) return (minetest.registered_nodes[techage.get_node_lvm(pos).name] or {}).consumer end
local STANDBY_TICKS = 2
local COUNTDOWN_TICKS = 4
local CYCLE_TIME = 3
local function formspec(self, pos, nvm)
if CRD(pos).stage == 4 then -- TA4 node?
return "size[8,7.2]"..
default.gui_bg..
default.gui_bg_img..
default.gui_slots..
"box[0,-0.1;7.8,0.5;#c6e8ff]"..
"label[3,-0.1;"..minetest.colorize("#000000", S("Injector")).."]"..
techage.question_mark_help(8, S("Configure up to 8 items \nto be pushed by the injector"))..
"list[context;filter;0,0.8;8,1;]"..
"image_button[3.5,2;1,1;".. self:get_state_button_image(nvm) ..";state_button;]"..
"tooltip[3.5,2;1,1;"..self:get_state_tooltip(nvm).."]"..
"list[current_player;main;0,3.5;8,4;]"..
"listring[context;filter]"..
"listring[current_player;main]"
end
end
local function allow_metadata_inventory_put(pos, listname, index, stack, player)
if minetest.is_protected(pos, player:get_player_name()) then
return 0
end
local nvm = techage.get_nvm(pos)
if CRD(pos).State:get_state(nvm) ~= techage.STOPPED then
return 0
end
local inv = M(pos):get_inventory()
local list = inv:get_list(listname)
if list[index]:get_count() == 0 then
stack:set_count(1)
inv:set_stack(listname, index, stack)
return 0
end
return 0
end
local function allow_metadata_inventory_take(pos, listname, index, stack, player)
if minetest.is_protected(pos, player:get_player_name()) then
return 0
end
local nvm = techage.get_nvm(pos)
if CRD(pos).State:get_state(nvm) ~= techage.STOPPED then
return 0
end
local inv = M(pos):get_inventory()
inv:set_stack(listname, index, nil)
return 0
end
local function pushing(pos, crd, meta, nvm)
local pull_dir = meta:get_int("pull_dir")
local push_dir = meta:get_int("push_dir")
local inv = M(pos):get_inventory()
local filter = inv:get_list("filter")
local pushed = false
local pulled = false
for idx, item in ipairs(filter) do
local name = item:get_name()
if name ~= "" then
local items = techage.pull_items(pos, pull_dir, 1, name)
if items ~= nil then
pulled = true
if techage.push_items(pos, push_dir, items, idx) then
pushed = true
else -- place item back
techage.unpull_items(pos, pull_dir, items)
end
end
end
end
if not pulled then
crd.State:idle(pos, nvm)
elseif not pushed then
crd.State:blocked(pos, nvm)
else
crd.State:keep_running(pos, nvm, COUNTDOWN_TICKS)
end
end
local function keep_running(pos, elapsed)
local nvm = techage.get_nvm(pos)
local crd = CRD(pos)
pushing(pos, crd, M(pos), nvm)
end
local function on_receive_fields(pos, formname, fields, player)
if minetest.is_protected(pos, player:get_player_name()) then
return
end
local nvm = techage.get_nvm(pos)
CRD(pos).State:state_button_event(pos, nvm, fields)
M(pos):set_string("formspec", formspec(CRD(pos).State, pos, nvm))
end
local tiles = {}
-- '#' will be replaced by the stage number
-- '{power}' will be replaced by the power PNG
tiles.pas = {
"techage_filling_ta#.png^techage_frame_ta#_top.png^techage_appl_arrow.png",
"techage_filling_ta#.png^techage_frame_ta#.png",
"techage_filling_ta#.png^techage_frame_ta#.png^techage_appl_outp.png",
"techage_filling_ta#.png^techage_frame_ta#.png^techage_appl_inp.png",
"techage_appl_pusher.png^[transformR180]^techage_frame_ta#.png^techage_appl_injector.png",
"techage_appl_pusher.png^techage_frame_ta#.png^techage_appl_injector.png",
}
tiles.act = {
-- up, down, right, left, back, front
"techage_filling_ta#.png^techage_frame_ta#_top.png^techage_appl_arrow.png",
"techage_filling_ta#.png^techage_frame_ta#.png",
"techage_filling_ta#.png^techage_frame_ta#.png^techage_appl_outp.png",
"techage_filling_ta#.png^techage_frame_ta#.png^techage_appl_inp.png",
{
image = "techage_appl_pusher14.png^[transformR180]^techage_frame14_ta#.png^techage_appl_injector14.png",
backface_culling = false,
animation = {
type = "vertical_frames",
aspect_w = 32,
aspect_h = 32,
length = 2.0,
},
},
{
image = "techage_appl_pusher14.png^techage_frame14_ta#.png^techage_appl_injector14.png",
backface_culling = false,
animation = {
type = "vertical_frames",
aspect_w = 32,
aspect_h = 32,
length = 2.0,
},
},
}
local tubing = {
-- push item through the injector in opposit direction
on_push_item = function(pos, in_dir, stack)
return in_dir == M(pos):get_int("pull_dir") and techage.push_items(pos, in_dir, stack)
end,
is_pusher = true, -- is a pulling/pushing node
on_recv_message = function(pos, src, topic, payload)
return CRD(pos).State:on_receive_message(pos, topic, payload)
end,
}
local _, _, node_name_ta4 =
techage.register_consumer("injector", S("Injector"), tiles, {
cycle_time = CYCLE_TIME,
standby_ticks = STANDBY_TICKS,
formspec = formspec,
tubing = tubing,
after_place_node = function(pos, placer)
local meta = M(pos)
local node = minetest.get_node(pos)
meta:set_int("pull_dir", techage.side_to_outdir("L", node.param2))
meta:set_int("push_dir", techage.side_to_outdir("R", node.param2))
local inv = M(pos):get_inventory()
inv:set_size('filter', 8)
local nvm = techage.get_nvm(pos)
M(pos):set_string("formspec", formspec(CRD(pos).State, pos, nvm))
end,
allow_metadata_inventory_put = allow_metadata_inventory_put,
allow_metadata_inventory_take = allow_metadata_inventory_take,
on_receive_fields = on_receive_fields,
node_timer = keep_running,
on_rotate = screwdriver.disallow,
groups = {choppy=2, cracky=2, crumbly=2},
is_ground_content = false,
sounds = default.node_sound_wood_defaults(),
num_items = {0,2,6,12},
}, {false, false, false, true})
minetest.register_craft({
output = node_name_ta4,
recipe = {
{"", "techage:aluminum", ""},
{"", "techage:ta4_pusher_pas", ""},
{"", "basic_materials:ic", ""},
},
})

109
basis/conf_inv.lua Normal file
View File

@ -0,0 +1,109 @@
--[[
TechAge
=======
Copyright (C) 2020 Joachim Stolberg
GPL v3
See LICENSE.txt for more information
Configured inventory lib
Assuming the inventory has the name "conf"
]]--
-- for lazy programmers
local M = minetest.get_meta
local inv_lib = {}
function inv_lib.preassigned_stacks(pos, xsize, ysize)
local inv = M(pos):get_inventory()
local tbl = {}
for idx = 1, xsize * ysize do
local item_name = inv:get_stack("conf", idx):get_name()
if item_name ~= "" then
local x = (idx - 1) % xsize
local y = math.floor(idx / xsize)
tbl[#tbl+1] = "item_image["..x..","..y..";1,1;"..item_name.."]"
end
end
return table.concat(tbl, "")
end
function inv_lib.item_filter(pos, size)
local inv = M(pos):get_inventory()
local filter = {}
for idx = 1, size do
local item_name = inv:get_stack("conf", idx):get_name()
if item_name == "" then item_name = "unconfigured" end
if not filter[item_name] then
filter[item_name] = {}
end
table.insert(filter[item_name], idx)
end
return filter
end
function inv_lib.allow_conf_inv_put(pos, listname, index, stack, player)
local inv = M(pos):get_inventory()
local list = inv:get_list(listname)
if list[index]:get_count() == 0 then
stack:set_count(1)
inv:set_stack(listname, index, stack)
return 0
end
return 0
end
function inv_lib.allow_conf_inv_take(pos, listname, index, stack, player)
local inv = M(pos):get_inventory()
inv:set_stack(listname, index, nil)
return 0
end
function inv_lib.allow_conf_inv_move(pos, from_list, from_index, to_list, to_index, count, player)
local inv = minetest.get_meta(pos):get_inventory()
local stack = inv:get_stack(to_list, to_index)
if stack:get_count() == 0 then
return 1
else
return 0
end
end
function inv_lib.put_items(pos, inv, listname, item, stacks, idx)
for _, i in ipairs(stacks) do
if not idx or idx == i then
local stack = inv:get_stack(listname, i)
if stack:item_fits(item) then
stack:add_item(item)
inv:set_stack(listname, i, stack)
return true
end
end
end
return false
end
function inv_lib.take_item(pos, inv, listname, num, stacks)
local mem = techage.get_mem(pos)
local size = #stacks
mem.ta_startpos = mem.ta_startpos or 1
for idx = mem.ta_startpos, mem.ta_startpos + size do
idx = (idx % size) + 1
local stack = inv:get_stack(listname, idx)
local taken = stack:take_item(num)
if taken:get_count() > 0 then
inv:set_stack(listname, idx, stack)
mem.ta_startpos = idx
return taken
end
end
end
return inv_lib

View File

@ -53,7 +53,6 @@ Node states:
Node nvm data: Node nvm data:
"techage_state" - node state, like "RUNNING" "techage_state" - node state, like "RUNNING"
"techage_item_meter" - node item/runtime counter
"techage_countdown" - countdown to standby mode "techage_countdown" - countdown to standby mode
]]-- ]]--
@ -190,7 +189,6 @@ function NodeStates:node_init(pos, nvm, number)
if self.infotext_name then if self.infotext_name then
M(pos):set_string("infotext", self.infotext_name.." "..number..": stopped") M(pos):set_string("infotext", self.infotext_name.." "..number..": stopped")
end end
nvm.techage_item_meter = 0
if self.formspec_func then if self.formspec_func then
M(pos):set_string("formspec", self.formspec_func(self, pos, nvm)) M(pos):set_string("formspec", self.formspec_func(self, pos, nvm))
end end
@ -400,13 +398,12 @@ end
-- To be called after successful node action to raise the timer -- To be called after successful node action to raise the timer
-- and keep the node in state RUNNING -- and keep the node in state RUNNING
function NodeStates:keep_running(pos, nvm, val, num_items) function NodeStates:keep_running(pos, nvm, val)
-- set to RUNNING if not already done -- set to RUNNING if not already done
if nvm.techage_state ~= RUNNING then if nvm.techage_state ~= RUNNING then
self:start(pos, nvm) self:start(pos, nvm)
end end
nvm.techage_countdown = val or 4 nvm.techage_countdown = val or 4
nvm.techage_item_meter = (nvm.techage_item_meter or 0) + (num_items or 1)
end end
-- Start/stop node based on button events. -- Start/stop node based on button events.

View File

@ -158,10 +158,13 @@ techage.Items = {
ta4_gravelsieve = "techage:ta4_gravelsieve_pas", ta4_gravelsieve = "techage:ta4_gravelsieve_pas",
ta4_grinder = "techage:ta4_grinder_pas", ta4_grinder = "techage:ta4_grinder_pas",
ta4_detector = "techage:ta4_detector_off", ta4_detector = "techage:ta4_detector_off",
ta4_chest = "techage:ta4_chest", ta4_chest = "techage:chest_ta4",
ta4_8x2000_chest = "techage:ta4_chest",
ta4_growlight = "techage:growlight_on", ta4_growlight = "techage:growlight_on",
ta4_streetlamp = "techage_ta4_streetlamp.png", ta4_streetlamp = "techage_ta4_streetlamp.png",
ta4_industriallamp = "techage:industriallamp4_off", ta4_industriallamp = "techage:industriallamp4_off",
ta4_quarry = "techage:ta4_quarry_pas", ta4_quarry = "techage:ta4_quarry_pas",
ta4_electronicfab = "techage:ta4_electronic_fab_pas",
ta4_injector = "techage:ta4_injector_pas",
--ta4_ "", --ta4_ "",
} }

View File

@ -175,6 +175,8 @@ techage.manual_DE.aTitel = {
"3,TA4 Kiessieb / Gravel Sieve", "3,TA4 Kiessieb / Gravel Sieve",
"3,TA4 Mühle / Grinder", "3,TA4 Mühle / Grinder",
"3,TA4 Steinbrecher / Quarry", "3,TA4 Steinbrecher / Quarry",
"3,TA4 Elektronikfabrik / Electronic Fab",
"3,TA4 Injektor / Injector",
} }
techage.manual_DE.aText = { techage.manual_DE.aText = {
@ -1358,6 +1360,8 @@ techage.manual_DE.aText = {
"\n", "\n",
"Die Funktion entspricht der von TA3. Die Kiste kann aber mehr Inhalt aufnehmen.\n".. "Die Funktion entspricht der von TA3. Die Kiste kann aber mehr Inhalt aufnehmen.\n"..
"\n".. "\n"..
"Zusätzlich besitzt die TA4 Kiste ein Schatteninventar zur Konfiguration. Hier können bestimmte Speicherplätze mit einem Item vorbelegt werden. Vorbelegte Speicherplätze werden beim Füllen nur mit diesen Items belegt. Zum Leeren eines vorbelegten Speicherplatzes wird ein TA4 Schieber oder TA4 Injektor mit entsprechender Konfiguration benötigt.\n"..
"\n"..
"\n".. "\n"..
"\n", "\n",
"Die TA4 8x2000 Kiste hat kein normales Inventar wir andere Kisten\\, sondern verfügt über 8 Speicher\\, wobei jeder Speicher bis zu 2000 Items einer Sorte aufnehmen kann. Über die orangefarbenen Taster können Items in den Speicher verschoben bzw. wieder heraus geholt werden. Die Kiste kann auch wie sonst üblich mit einem Schieber (TA2\\, TA3 oder TA4) gefüllt bzw. geleert werden.\n".. "Die TA4 8x2000 Kiste hat kein normales Inventar wir andere Kisten\\, sondern verfügt über 8 Speicher\\, wobei jeder Speicher bis zu 2000 Items einer Sorte aufnehmen kann. Über die orangefarbenen Taster können Items in den Speicher verschoben bzw. wieder heraus geholt werden. Die Kiste kann auch wie sonst üblich mit einem Schieber (TA2\\, TA3 oder TA4) gefüllt bzw. geleert werden.\n"..
@ -1386,7 +1390,7 @@ techage.manual_DE.aText = {
"\n".. "\n"..
"\n", "\n",
"Die Funktion entspricht der von TA2.\n".. "Die Funktion entspricht der von TA2.\n"..
"Die Verarbeitungsleistung beträgt 36 Items alle 4 s.\n".. "Die Verarbeitungsleistung beträgt 24 Items alle 4 s.\n"..
"\n".. "\n"..
"\n".. "\n"..
"\n", "\n",
@ -1407,6 +1411,19 @@ techage.manual_DE.aText = {
"\n".. "\n"..
"\n".. "\n"..
"\n", "\n",
"Die Funktion entspricht der von TA2\\, nur werden hier verschiedene Chips produziert.\n"..
"Die Verarbeitungsleistung beträgt ein Chip alle 6 s. Der Block benötigt hierfür 12 ku Strom.\n"..
"\n"..
"\n"..
"\n",
"Der Injektor ist ein TA4 Schieber mit speziellen Eigenschaften. Er besitzt ein Menü zur Konfiguration. Hier können bis zu 8 Items konfiguriert werden. Er entnimmt nur diese Items einer Kiste (TA4 Kiste oder TA4 8x2000 Kiste) um sie an Maschinen mit Rezepturen weiterzugeben (Autocrafter\\, Industrieofen und Elektronikfabrik). \n"..
"\n"..
"Beim Weitergeben wird in der Zielmaschine pro Item nur eine Position im Inventar genutzt. Sind bspw. nur die ersten drei Einträge im Injektor konfiguriert\\, so werden auch nur die ersten drei Speicherplätze im Inventar der Maschine belegt. Damit wir ein Überlauf im Inventar der Maschine verhindert. \n"..
"\n"..
"Die Verarbeitungsleistung beträgt bis zu 8 Items alle 3 Sekunden.\n"..
"\n"..
"\n"..
"\n",
} }
techage.manual_DE.aItemName = { techage.manual_DE.aItemName = {
@ -1579,11 +1596,13 @@ techage.manual_DE.aItemName = {
"ta4_tube", "ta4_tube",
"ta4_pusher", "ta4_pusher",
"ta4_chest", "ta4_chest",
"ta4_chest", "ta4_8x2000_chest",
"ta4_distributor", "ta4_distributor",
"ta4_gravelsieve", "ta4_gravelsieve",
"ta4_grinder", "ta4_grinder",
"ta4_quarry", "ta4_quarry",
"ta4_electronicfab",
"ta4_injector",
} }
techage.manual_DE.aPlanTable = { techage.manual_DE.aPlanTable = {
@ -1761,5 +1780,7 @@ techage.manual_DE.aPlanTable = {
"", "",
"", "",
"", "",
"",
"",
} }

View File

@ -110,7 +110,7 @@ local function node_timer(pos, elapsed)
if nvm.liquid.amount < CAPACITY then if nvm.liquid.amount < CAPACITY then
nvm.taken = power.consumer_alive(pos, Cable, CYCLE_TIME) nvm.taken = power.consumer_alive(pos, Cable, CYCLE_TIME)
generating(pos, nvm) generating(pos, nvm)
State:keep_running(pos, nvm, 1, 0) -- count items State:keep_running(pos, nvm, 1) -- TODO warum hier 1 und nicht COUNTDOWN_TICKS?
else else
State:blocked(pos, nvm, S("full")) State:blocked(pos, nvm, S("full"))
power.consumer_stop(pos, Cable) power.consumer_stop(pos, Cable)

View File

@ -99,7 +99,7 @@ local function node_timer(pos, elapsed)
local outdir = M(pos):get_int("outdir") local outdir = M(pos):get_int("outdir")
nvm.given = power.generator_alive(pos, Cable, CYCLE_TIME, outdir) nvm.given = power.generator_alive(pos, Cable, CYCLE_TIME, outdir)
consuming(pos, nvm) consuming(pos, nvm)
State:keep_running(pos, nvm, 1, 0) -- count items State:keep_running(pos, nvm, 1) -- TODO warum hier 1 und nicht COUNTDOWN_TICKS?
else else
State:standby(pos, nvm) State:standby(pos, nvm)
nvm.given = 0 nvm.given = 0

View File

@ -24,6 +24,11 @@ minetest.register_craft({
recipe = { recipe = {
{'default:copper_ingot', 'techage:ta4_carbon_fiber', 'default:copper_ingot'}, {'default:copper_ingot', 'techage:ta4_carbon_fiber', 'default:copper_ingot'},
{'techage:baborium_ingot', 'techage:ta4_carbon_fiber', 'techage:baborium_ingot'}, {'techage:baborium_ingot', 'techage:ta4_carbon_fiber', 'techage:baborium_ingot'},
{"techage:lye", 'techage:ta4_carbon_fiber', 'techage:lye'}, {"techage:canister_lye", 'techage:ta4_carbon_fiber', "techage:canister_lye"},
}, },
replacements = {
{"techage:canister_lye", "techage:ta3_canister_empty"},
{"techage:canister_lye", "techage:ta3_canister_empty"},
}
}) })

View File

@ -110,7 +110,8 @@ else
dofile(MP.."/basic_machines/liquidsampler.lua") dofile(MP.."/basic_machines/liquidsampler.lua")
dofile(MP.."/basic_machines/quarry.lua") dofile(MP.."/basic_machines/quarry.lua")
dofile(MP.."/basic_machines/ta4_chest.lua") dofile(MP.."/basic_machines/ta4_chest.lua")
dofile(MP.."/basic_machines/ta4_injector.lua")
-- Liquids II -- Liquids II
dofile(MP.."/liquids/tank.lua") dofile(MP.."/liquids/tank.lua")
dofile(MP.."/liquids/filler.lua") dofile(MP.."/liquids/filler.lua")

View File

@ -33,6 +33,7 @@ Biome=Biom
Block configured items for open ports=Blockiere konfigurierte Gegenstände für offene Ausgänge Block configured items for open ports=Blockiere konfigurierte Gegenstände für offene Ausgänge
Build derrick=Errichte Ölturm Build derrick=Errichte Ölturm
Compressed Gravel=Komprimiertes Kies Compressed Gravel=Komprimiertes Kies
Configure up to 8 items @nto be pushed by the injector=Konfiguriere bis zu 8 Gegenstände \n die vom Injektor weitergegeben werden sollen
Consum. 1=Konsum. 1 Consum. 1=Konsum. 1
Consum. 2=Konsum. 2 Consum. 2=Konsum. 2
Current power:=Strom aktuell: Current power:=Strom aktuell:
@ -48,6 +49,7 @@ Ele Power Source=Ele Kraftquelle
Electricity=Strom Electricity=Strom
Electrolyzer=Eletrolyseur Electrolyzer=Eletrolyseur
Electronic Fab=Elektronikfabrik Electronic Fab=Elektronikfabrik
Empty the slots always @nfrom right to left=Speicherplätze von rechts nach links leeren
Energy storage=Engergiespeicher Energy storage=Engergiespeicher
Energy stored:=Energie gespeichert Energy stored:=Energie gespeichert
Enter=Eingeben Enter=Eingeben
@ -59,7 +61,6 @@ Firebox=Feuerkasten
Flint and Iron=Flint and Iron Flint and Iron=Flint and Iron
Flowing Oil=Fließendes Öl Flowing Oil=Fließendes Öl
Flywheel=Schwungrad Flywheel=Schwungrad
Force order of filter items=Erzwinge Reihenfolge
Fuel Cell=Brennstoffzelle Fuel Cell=Brennstoffzelle
Fuel Menu=Brennstoff Menü Fuel Menu=Brennstoff Menü
Fuel cell=Brennstoffzelle Fuel cell=Brennstoffzelle
@ -81,9 +82,11 @@ Hole size=Lochgröße
Hydrogen Cylinder Large=Wasserstoffflasche groß Hydrogen Cylinder Large=Wasserstoffflasche groß
Hydrogen Cylinder Small=Wasserstoffflasche klein Hydrogen Cylinder Small=Wasserstoffflasche klein
In use:=In Benutzung: In use:=In Benutzung:
Injector=Injektor
Insert destination node number(s)=Gebe Zielnummer(n) ein Insert destination node number(s)=Gebe Zielnummer(n) ein
Insert door/gate block number(s)=Gebe Tür-/Tornummer(n) ein Insert door/gate block number(s)=Gebe Tür-/Tornummer(n) ein
Intake=Stromaufnahme Intake=Stromaufnahme
Inventory,Configuration=Inventar,Konfiguration
Inverter=Wechselrichter Inverter=Wechselrichter
Leave Powder=Laub Pulver Leave Powder=Laub Pulver
Liquid Filler=Einfülltrichter Liquid Filler=Einfülltrichter
@ -109,7 +112,7 @@ More water expected (2 m deep)!=Mehr Wasser erwartet (2 m tief)
Nacelle is missing=Die Gondel fehlt Nacelle is missing=Die Gondel fehlt
Needle Powder=Nadel Pulver Needle Powder=Nadel Pulver
Network Data=Netzwerkdaten Network Data=Netzwerkdaten
Never completely empty the slots@nwith the pusher to keep the items assignment=Slots mit dem Schieber nie ganz@nleeren, um die Item-Zuordnung beizubehalten Never completely empty the slots@nwith the pusher to keep the item assignment=Speicherplätze mit dem Schieber nie ganz@nleeren, um die Item-Zuordnung beizubehalten
No network or active generator available!=Kein Stromnetz oder aktiver Generator verfügbar No network or active generator available!=Kein Stromnetz oder aktiver Generator verfügbar
No plan available=Kein Plan verfügar No plan available=Kein Plan verfügar
No power grid or running generator!=Kein Stromnetz oder Generator verfügbar! No power grid or running generator!=Kein Stromnetz oder Generator verfügbar!
@ -367,7 +370,7 @@ Tube Wall Entry=Tube Wanddurchbruch
Turned on:=Eingeschaltet: Turned on:=Eingeschaltet:
Type=Typ Type=Typ
Unlock=Entsperren Unlock=Entsperren
Unlock connected chest@nif all slots are below 2000=Nachfolgende Kiste entsperren,@nsofern alle Slots <= 2000 Unlock connected chest@nif all slots are below 2000=Nachfolgende Kiste entsperren,@nsofern alle Speicherplätze <= 2000
Update=Update Update=Update
Usmium Nuggets=Usmium Nuggets Usmium Nuggets=Usmium Nuggets
Usmium Powder=Usmium Pulver Usmium Powder=Usmium Pulver
@ -394,6 +397,7 @@ accept=akzeptieren
added=hinzugefügt wird added=hinzugefügt wird
added or removed=hinzugefügt oder entfernt wird added or removed=hinzugefügt oder entfernt wird
area is protected=Bereich ist geschützt area is protected=Bereich ist geschützt
blocking mode=Blockiert
commands like: help=Kommandos wie: help commands like: help=Kommandos wie: help
connected with=verbunden mit connected with=verbunden mit
depth=Tiefe depth=Tiefe
@ -422,9 +426,9 @@ reactor defect or no power=Reaktor defekt oder kein Strom
reactor has no power=Reaktor hat keinen Strom reactor has no power=Reaktor hat keinen Strom
removed=entfernt removed=entfernt
repaired=repariert repaired=repariert
right to left=von rechts nach links
stopped=gestoppt stopped=gestoppt
storage empty?=Speicher leer? storage empty?=Speicher leer?
water temperature=Wassertemperatur water temperature=Wassertemperatur
wrong storage diameter=Falscher Wärmespeicher-Durchmesser wrong storage diameter=Falscher Wärmespeicher-Durchmesser
##### not used anymore ##### ##### not used anymore #####
TA4 Wall Pipe=TA4 Wandröhre

View File

@ -31,6 +31,7 @@ Biome=
Block configured items for open ports= Block configured items for open ports=
Build derrick= Build derrick=
Compressed Gravel= Compressed Gravel=
Configure up to 8 items @nto be pushed by the injector=
Consum. 1= Consum. 1=
Consum. 2= Consum. 2=
Current power:= Current power:=
@ -46,6 +47,7 @@ Ele Power Source=
Electricity= Electricity=
Electrolyzer= Electrolyzer=
Electronic Fab= Electronic Fab=
Empty the slots always @nfrom right to left=
Energy storage= Energy storage=
Energy stored:= Energy stored:=
Enter= Enter=
@ -57,7 +59,6 @@ Firebox=
Flint and Iron= Flint and Iron=
Flowing Oil= Flowing Oil=
Flywheel= Flywheel=
Force order of filter items=
Fuel Cell= Fuel Cell=
Fuel Menu= Fuel Menu=
Fuel cell= Fuel cell=
@ -79,9 +80,11 @@ Hole size=
Hydrogen Cylinder Large= Hydrogen Cylinder Large=
Hydrogen Cylinder Small= Hydrogen Cylinder Small=
In use:= In use:=
Injector=
Insert destination node number(s)= Insert destination node number(s)=
Insert door/gate block number(s)= Insert door/gate block number(s)=
Intake= Intake=
Inventory,Configuration=
Inverter= Inverter=
Leave Powder= Leave Powder=
Liquid Filler= Liquid Filler=
@ -107,7 +110,7 @@ More water expected (2 m deep)!=
Nacelle is missing= Nacelle is missing=
Needle Powder= Needle Powder=
Network Data= Network Data=
Never completely empty the slots@nwith the pusher to keep the items assignment= Never completely empty the slots@nwith the pusher to keep the item assignment=
No network or active generator available!= No network or active generator available!=
No plan available= No plan available=
No power grid or running generator!= No power grid or running generator!=
@ -392,6 +395,7 @@ accept=
added= added=
added or removed= added or removed=
area is protected= area is protected=
blocking mode=
commands like: help= commands like: help=
connected with= connected with=
depth= depth=
@ -420,6 +424,7 @@ reactor defect or no power=
reactor has no power= reactor has no power=
removed= removed=
repaired= repaired=
right to left=
stopped= stopped=
storage empty?= storage empty?=
water temperature= water temperature=

View File

@ -36,7 +36,7 @@ local function read_number(itemstack, user, pointed_thing)
local number = techage.get_node_number(pos) local number = techage.get_node_number(pos)
if number then if number then
local numbers = minetest.deserialize(user:get_attribute("techage_prog_numbers")) or {} local numbers = minetest.deserialize(user:get_attribute("techage_prog_numbers")) or {}
numbers[number] = true techage.add_to_set(numbers, number)
user:set_attribute("techage_prog_numbers", minetest.serialize(numbers)) user:set_attribute("techage_prog_numbers", minetest.serialize(numbers))
minetest.chat_send_player(user:get_player_name(), S("[TechAge Programmer] number").." "..number.." read") minetest.chat_send_player(user:get_player_name(), S("[TechAge Programmer] number").." "..number.." read")
else else
@ -59,7 +59,7 @@ local function program_numbers(itemstack, placer, pointed_thing)
minetest.chat_send_player(player_name, S("[TechAge Programmer] foreign or unknown node!")) minetest.chat_send_player(player_name, S("[TechAge Programmer] foreign or unknown node!"))
return itemstack return itemstack
end end
local text = join_to_string(numbers) local text = table.concat(numbers, " ")
local ndef = minetest.registered_nodes[minetest.get_node(pos).name] local ndef = minetest.registered_nodes[minetest.get_node(pos).name]
if ndef and ndef.techage_set_numbers then if ndef and ndef.techage_set_numbers then
local res = ndef.techage_set_numbers(pos, text, player_name) local res = ndef.techage_set_numbers(pos, text, player_name)

View File

@ -513,6 +513,8 @@ Der TA4 Schieber besitzt zwei zusätzliche Kommandos für den Lua Controller:
Die Funktion entspricht der von TA3. Die Kiste kann aber mehr Inhalt aufnehmen. Die Funktion entspricht der von TA3. Die Kiste kann aber mehr Inhalt aufnehmen.
Zusätzlich besitzt die TA4 Kiste ein Schatteninventar zur Konfiguration. Hier können bestimmte Speicherplätze mit einem Item vorbelegt werden. Vorbelegte Speicherplätze werden beim Füllen nur mit diesen Items belegt. Zum Leeren eines vorbelegten Speicherplatzes wird ein TA4 Schieber oder TA4 Injektor mit entsprechender Konfiguration benötigt.
[ta4_chest|image] [ta4_chest|image]
### TA4 8x2000 Kiste / TA4 8x2000 Chest ### TA4 8x2000 Kiste / TA4 8x2000 Chest
@ -542,14 +544,14 @@ Der Kiste besitzt ein zusätzliches Kommandos für den Lua Controller:
Beispiel 1: `$read_data(CHEST, "count")` --> Summe der Items über alle 8 Speicher Beispiel 1: `$read_data(CHEST, "count")` --> Summe der Items über alle 8 Speicher
Beispiel 2: `$read_data(CHEST, "count", 2)` --> Anzahl der Items in Speicher 2 (zweiter von links) Beispiel 2: `$read_data(CHEST, "count", 2)` --> Anzahl der Items in Speicher 2 (zweiter von links)
[ta4_chest|image] [ta4_8x2000_chest|image]
### TA4 Verteiler / Distributor ### TA4 Verteiler / Distributor
Die Funktion entspricht der von TA2. Die Funktion entspricht der von TA2.
Die Verarbeitungsleistung beträgt 36 Items alle 4 s. Die Verarbeitungsleistung beträgt 24 Items alle 4 s.
[ta4_distributor|image] [ta4_distributor|image]
@ -574,4 +576,21 @@ Die Funktion entspricht weitgehend der von TA2.
Zusätzlich kann die Lochgröße zwischen 3x3 und 11x11 Blöcken eingestellt werden. Zusätzlich kann die Lochgröße zwischen 3x3 und 11x11 Blöcken eingestellt werden.
Die maximale Tiefe beträgt 80 Meter. Der Steinbrecher benötigt 14 ku Strom. Die maximale Tiefe beträgt 80 Meter. Der Steinbrecher benötigt 14 ku Strom.
[ta4_quarry|image] [ta4_quarry|image]
### TA4 Elektronikfabrik / Electronic Fab
Die Funktion entspricht der von TA2, nur werden hier verschiedene Chips produziert.
Die Verarbeitungsleistung beträgt ein Chip alle 6 s. Der Block benötigt hierfür 12 ku Strom.
[ta4_electronicfab|image]
### TA4 Injektor / Injector
Der Injektor ist ein TA4 Schieber mit speziellen Eigenschaften. Er besitzt ein Menü zur Konfiguration. Hier können bis zu 8 Items konfiguriert werden. Er entnimmt nur diese Items einer Kiste (TA4 Kiste oder TA4 8x2000 Kiste) um sie an Maschinen mit Rezepturen weiterzugeben (Autocrafter, Industrieofen und Elektronikfabrik).
Beim Weitergeben wird in der Zielmaschine pro Item nur eine Position im Inventar genutzt. Sind bspw. nur die ersten drei Einträge im Injektor konfiguriert, so werden auch nur die ersten drei Speicherplätze im Inventar der Maschine belegt. Damit wir ein Überlauf im Inventar der Maschine verhindert.
Die Verarbeitungsleistung beträgt bis zu 8 Items alle 3 Sekunden.
[ta4_injector|image]

View File

@ -173,4 +173,6 @@
- [TA4 Verteiler / Distributor](./manual_ta4_DE.md#ta4-verteiler--distributor) - [TA4 Verteiler / Distributor](./manual_ta4_DE.md#ta4-verteiler--distributor)
- [TA4 Kiessieb / Gravel Sieve](./manual_ta4_DE.md#ta4-kiessieb--gravel-sieve) - [TA4 Kiessieb / Gravel Sieve](./manual_ta4_DE.md#ta4-kiessieb--gravel-sieve)
- [TA4 Mühle / Grinder](./manual_ta4_DE.md#ta4-mühle--grinder) - [TA4 Mühle / Grinder](./manual_ta4_DE.md#ta4-mühle--grinder)
- [TA4 Steinbrecher / Quarry](./manual_ta4_DE.md#ta4-steinbrecher--quarry) - [TA4 Steinbrecher / Quarry](./manual_ta4_DE.md#ta4-steinbrecher--quarry)
- [TA4 Elektronikfabrik / Electronic Fab](./manual_ta4_DE.md#ta4-elektronikfabrik--electronic-fab)
- [TA4 Injektor / Injector](./manual_ta4_DE.md#ta4-injektor--injector)

View File

@ -86,7 +86,8 @@ local function trigger_network(pos, outdir, Cable)
networks.build_network(pos, outdir, Cable, netID) networks.build_network(pos, outdir, Cable, netID)
elseif not networks.get_network(Cable.tube_type, netID) then elseif not networks.get_network(Cable.tube_type, netID) then
--print("build_network !!!!!!!!!!!!!!!!!!!!") --print("build_network !!!!!!!!!!!!!!!!!!!!")
delete_netID(pos, outdir, Cable) netID = determine_netID(pos, outdir, Cable)
store_netID(pos, outdir, netID, Cable)
networks.build_network(pos, outdir, Cable, netID) networks.build_network(pos, outdir, Cable, netID)
end end
end end
@ -169,6 +170,7 @@ function techage.power.consumer_alive(pos, Cable, cycle_time)
local nvm = techage.get_nvm(pos) local nvm = techage.get_nvm(pos)
local def = nvm[Cable.tube_type] -- power related network data local def = nvm[Cable.tube_type] -- power related network data
if def then if def then
-- if network is deleted (cable removed/placed) rebuild it to prevent flickering lights
if not def["netID"] or not networks.get_network(Cable.tube_type, def["netID"]) then if not def["netID"] or not networks.get_network(Cable.tube_type, def["netID"]) then
build_network_consumer(pos, Cable) build_network_consumer(pos, Cable)
end end

View File

@ -20,6 +20,16 @@ local networks = techage.networks
local Cable = techage.ElectricCable local Cable = techage.ElectricCable
local power = techage.power local power = techage.power
local function can_dig(pos, digger)
if M(pos):get_string("owner") == digger:get_player_name() then
return true
end
if minetest.check_player_privs(digger:get_player_name(), "powerline") then
return true
end
return false
end
-- legacy node -- legacy node
minetest.register_node("techage:power_line", { minetest.register_node("techage:power_line", {
description = S("TA Power Line"), description = S("TA Power Line"),
@ -33,6 +43,7 @@ minetest.register_node("techage:power_line", {
return false return false
end, end,
can_dig = can_dig,
after_dig_node = function(pos, oldnode, oldmetadata, digger) after_dig_node = function(pos, oldnode, oldmetadata, digger)
if oldmetadata and oldmetadata.fields and oldmetadata.fields.tl2_param2 then if oldmetadata and oldmetadata.fields and oldmetadata.fields.tl2_param2 then
oldnode.param2 = oldmetadata.fields.tl2_param2 oldnode.param2 = oldmetadata.fields.tl2_param2
@ -74,6 +85,7 @@ minetest.register_node("techage:power_lineS", {
return false return false
end, end,
can_dig = can_dig,
after_dig_node = function(pos, oldnode, oldmetadata, digger) after_dig_node = function(pos, oldnode, oldmetadata, digger)
if oldmetadata and oldmetadata.fields and oldmetadata.fields.tl2_param2 then if oldmetadata and oldmetadata.fields and oldmetadata.fields.tl2_param2 then
oldnode.param2 = oldmetadata.fields.tl2_param2 oldnode.param2 = oldmetadata.fields.tl2_param2
@ -121,6 +133,7 @@ minetest.register_node("techage:power_lineA", {
return false return false
end, end,
can_dig = can_dig,
after_dig_node = function(pos, oldnode, oldmetadata, digger) after_dig_node = function(pos, oldnode, oldmetadata, digger)
if oldmetadata and oldmetadata.fields and oldmetadata.fields.tl2_param2 then if oldmetadata and oldmetadata.fields and oldmetadata.fields.tl2_param2 then
oldnode.param2 = oldmetadata.fields.tl2_param2 oldnode.param2 = oldmetadata.fields.tl2_param2
@ -199,16 +212,7 @@ minetest.register_node("techage:power_pole2", {
end end
return false return false
end, end,
can_dig = function(pos, digger) can_dig = can_dig,
local meta = minetest.get_meta(pos)
if meta:get_string("owner") == digger:get_player_name() then
return true
end
if minetest.check_player_privs(digger:get_player_name(), "powerline") then
return true
end
return false
end,
after_dig_node = function(pos, oldnode, oldmetadata, digger) after_dig_node = function(pos, oldnode, oldmetadata, digger)
if oldmetadata and oldmetadata.fields and oldmetadata.fields.tl2_param2 then if oldmetadata and oldmetadata.fields and oldmetadata.fields.tl2_param2 then
oldnode.param2 = oldmetadata.fields.tl2_param2 oldnode.param2 = oldmetadata.fields.tl2_param2
@ -305,16 +309,7 @@ minetest.register_node("techage:power_pole_conn", {
after_dig_node = function(pos, oldnode, oldmetadata, digger) after_dig_node = function(pos, oldnode, oldmetadata, digger)
Cable:after_dig_node(pos) Cable:after_dig_node(pos)
end, end,
can_dig = function(pos, digger) can_dig = can_dig,
local meta = minetest.get_meta(pos)
if meta:get_string("owner") == digger:get_player_name() then
return true
end
if minetest.check_player_privs(digger:get_player_name(), "powerline") then
return true
end
return false
end,
networks = { networks = {
ele1 = { ele1 = {
sides = networks.AllSides, -- connection sides for cables sides = networks.AllSides, -- connection sides for cables
@ -350,6 +345,7 @@ minetest.register_node("techage:power_pole3", {
{ -4/32, -16/32, -4/32, 4/32, 16/32, 4/32}, { -4/32, -16/32, -4/32, 4/32, 16/32, 4/32},
}, },
}, },
can_dig = can_dig,
on_rotate = screwdriver.disallow, -- important! on_rotate = screwdriver.disallow, -- important!
paramtype = "light", paramtype = "light",
sunlight_propagates = true, sunlight_propagates = true,

Binary file not shown.

Before

Width:  |  Height:  |  Size: 302 B

After

Width:  |  Height:  |  Size: 303 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 290 B

After

Width:  |  Height:  |  Size: 290 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 237 B

After

Width:  |  Height:  |  Size: 204 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 273 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 473 B