TA4 chest and pusher changed and redone
This commit is contained in:
parent
78d0f3dccd
commit
28eb8e0487
@ -193,8 +193,9 @@ minetest.register_node("techage:chest_ta4", {
|
||||
allow_metadata_inventory_take = allow_metadata_inventory_take,
|
||||
|
||||
paramtype2 = "facedir",
|
||||
groups = {choppy=2, cracky=2, crumbly=2},
|
||||
groups = {choppy=2, cracky=2, crumbly=2, not_in_creative_inventory=1},
|
||||
is_ground_content = false,
|
||||
drop = "techage:ta4_chest",
|
||||
sounds = default.node_sound_wood_defaults(),
|
||||
})
|
||||
|
||||
@ -238,8 +239,8 @@ minetest.register_craft({
|
||||
recipe = {"techage:chest_ta2", "default:chest"}
|
||||
})
|
||||
|
||||
minetest.register_craft({
|
||||
type = "shapeless",
|
||||
output = "techage:chest_ta4",
|
||||
recipe = {"techage:chest_ta3", "default:chest"}
|
||||
})
|
||||
--minetest.register_craft({
|
||||
-- type = "shapeless",
|
||||
-- output = "techage:chest_ta4",
|
||||
-- recipe = {"techage:chest_ta3", "default:chest"}
|
||||
--})
|
||||
|
@ -9,7 +9,7 @@
|
||||
See LICENSE.txt for more information
|
||||
|
||||
TA2/TA3/TA4 Pusher
|
||||
Simple node for push/pull operation of StackItems from chests or other
|
||||
Nodes for push/pull operation of StackItems from chests or other
|
||||
inventory/server nodes to tubes or other inventory/server nodes.
|
||||
|
||||
+--------+
|
||||
@ -33,10 +33,53 @@ local STANDBY_TICKS = 5
|
||||
local COUNTDOWN_TICKS = 5
|
||||
local CYCLE_TIME = 2
|
||||
|
||||
local function ta4_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("Pusher")).."]"..
|
||||
techage.question_mark_help(8, S("Optionally configure\nthe pusher with one item"))..
|
||||
"list[context;main;3.5,1;1,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;main]"..
|
||||
"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 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 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 items = techage.pull_items(pos, pull_dir, crd.num_items)
|
||||
local items = techage.pull_items(pos, pull_dir, nvm.item_count or crd.num_items, nvm.item_name)
|
||||
if items ~= nil then
|
||||
if techage.push_items(pos, push_dir, items) ~= true then
|
||||
-- place item back
|
||||
@ -44,7 +87,13 @@ local function pushing(pos, crd, meta, nvm)
|
||||
crd.State:blocked(pos, nvm)
|
||||
return
|
||||
end
|
||||
if nvm.item_count then -- remote job?
|
||||
nvm.item_count = nil
|
||||
nvm.item_name = nil
|
||||
crd.State:stop(pos, nvm)
|
||||
else
|
||||
crd.State:keep_running(pos, nvm, COUNTDOWN_TICKS)
|
||||
end
|
||||
return
|
||||
end
|
||||
crd.State:idle(pos, nvm)
|
||||
@ -58,6 +107,7 @@ local function keep_running(pos, elapsed)
|
||||
end
|
||||
|
||||
local function on_rightclick(pos, node, clicker)
|
||||
if CRD(pos).stage ~= 4 then -- Not TA4 node?
|
||||
local nvm = techage.get_nvm(pos)
|
||||
if not minetest.is_protected(pos, clicker:get_player_name()) then
|
||||
if CRD(pos).State:get_state(nvm) == techage.STOPPED then
|
||||
@ -67,6 +117,45 @@ local function on_rightclick(pos, node, clicker)
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
local function on_receive_fields(pos, formname, fields, player)
|
||||
if CRD(pos).stage == 4 then -- TA4 node?
|
||||
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", ta4_formspec(CRD(pos).State, pos, nvm))
|
||||
end
|
||||
end
|
||||
|
||||
local function can_start(pos, nvm, state)
|
||||
if CRD(pos).stage == 4 then -- TA4 node?
|
||||
local inv = M(pos):get_inventory()
|
||||
local name = inv:get_stack("main", 1):get_name()
|
||||
if name ~= "" then
|
||||
nvm.item_name = name
|
||||
else
|
||||
nvm.item_name = nil
|
||||
end
|
||||
else
|
||||
nvm.item_name = nil
|
||||
end
|
||||
return true
|
||||
end
|
||||
|
||||
local function config_item(pos, payload)
|
||||
local name, count = unpack(payload:split(" "))
|
||||
if name and (minetest.registered_nodes[name] or minetest.registered_items[name]
|
||||
or minetest.registered_craftitems[name]) then
|
||||
count = tonumber(count) or 1
|
||||
local inv = M(pos):get_inventory()
|
||||
inv:set_stack("main", 1, {name = name, count = 1})
|
||||
return count
|
||||
end
|
||||
return 0
|
||||
end
|
||||
|
||||
local tiles = {}
|
||||
-- '#' will be replaced by the stage number
|
||||
@ -115,7 +204,21 @@ local tubing = {
|
||||
is_pusher = true, -- is a pulling/pushing node
|
||||
|
||||
on_recv_message = function(pos, src, topic, payload)
|
||||
if topic == "pull" then
|
||||
local nvm = techage.get_nvm(pos)
|
||||
CRD(pos).State:stop(pos, nvm)
|
||||
nvm.item_count = math.min(config_item(pos, payload), 12)
|
||||
CRD(pos).State:start(pos, nvm)
|
||||
return true
|
||||
elseif topic == "config" then
|
||||
local nvm = techage.get_nvm(pos)
|
||||
CRD(pos).State:stop(pos, nvm)
|
||||
config_item(pos, payload)
|
||||
CRD(pos).State:start(pos, nvm)
|
||||
return true
|
||||
else
|
||||
return CRD(pos).State:on_receive_message(pos, topic, payload)
|
||||
end
|
||||
end,
|
||||
}
|
||||
|
||||
@ -123,22 +226,33 @@ local node_name_ta2, node_name_ta3, node_name_ta4 =
|
||||
techage.register_consumer("pusher", S("Pusher"), tiles, {
|
||||
cycle_time = CYCLE_TIME,
|
||||
standby_ticks = STANDBY_TICKS,
|
||||
formspec = ta4_formspec,
|
||||
tubing = tubing,
|
||||
can_start = can_start,
|
||||
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))
|
||||
if CRD(pos).stage == 4 then -- TA4 node?
|
||||
local inv = M(pos):get_inventory()
|
||||
inv:set_size('main', 1)
|
||||
local nvm = techage.get_nvm(pos)
|
||||
M(pos):set_string("formspec", ta4_formspec(CRD(pos).State, pos, nvm))
|
||||
end
|
||||
end,
|
||||
|
||||
allow_metadata_inventory_put = allow_metadata_inventory_put,
|
||||
allow_metadata_inventory_take = allow_metadata_inventory_take,
|
||||
on_rightclick = on_rightclick,
|
||||
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,18},
|
||||
num_items = {0,2,6,12},
|
||||
})
|
||||
|
||||
minetest.register_craft({
|
||||
|
355
basic_machines/ta4_chest.lua
Normal file
355
basic_machines/ta4_chest.lua
Normal file
@ -0,0 +1,355 @@
|
||||
--[[
|
||||
|
||||
TechAge
|
||||
=======
|
||||
|
||||
Copyright (C) 2020 Joachim Stolberg
|
||||
|
||||
GPL v3
|
||||
See LICENSE.txt for more information
|
||||
|
||||
TA4 Protected Chest
|
||||
|
||||
]]--
|
||||
|
||||
-- for lazy programmers
|
||||
local M = minetest.get_meta
|
||||
local S = techage.S
|
||||
|
||||
local DESCRIPTION = S("TA4 Protected Chest")
|
||||
local STACK_SIZE = 2000
|
||||
|
||||
local function gen_inv(nvm)
|
||||
nvm.inventory = {}
|
||||
for i = 1,8 do
|
||||
nvm.inventory[i] = {name = "", count = 0}
|
||||
end
|
||||
end
|
||||
|
||||
local function get_stack(nvm, idx)
|
||||
nvm.inventory = nvm.inventory or {}
|
||||
if nvm.inventory[idx] then
|
||||
return nvm.inventory[idx]
|
||||
end
|
||||
nvm.inventory[idx] = {name = "", count = 0}
|
||||
return nvm.inventory[idx]
|
||||
end
|
||||
|
||||
local function get_count(nvm, idx)
|
||||
if idx and idx > 0 then
|
||||
nvm.inventory = nvm.inventory or {}
|
||||
if nvm.inventory[idx] then
|
||||
return nvm.inventory[idx].count or 0
|
||||
else
|
||||
return 0
|
||||
end
|
||||
else
|
||||
local count = 0
|
||||
for _,item in ipairs(nvm.inventory or {}) do
|
||||
count = count + item.count or 0
|
||||
end
|
||||
return count
|
||||
end
|
||||
end
|
||||
|
||||
local function inv_empty(nvm)
|
||||
for _,item in ipairs(nvm.inventory or {}) do
|
||||
if item.count and item.count > 0 then
|
||||
return false
|
||||
end
|
||||
end
|
||||
return true
|
||||
end
|
||||
|
||||
local function inv_state(nvm)
|
||||
local num = 0
|
||||
for _,item in ipairs(nvm.inventory or {}) do
|
||||
if item.count and item.count > 0 then
|
||||
num = num + 1
|
||||
end
|
||||
end
|
||||
if num == 0 then return "empty" end
|
||||
if num == 8 then return "full" end
|
||||
return "loaded"
|
||||
end
|
||||
|
||||
-- Sort the items into the nvm inventory
|
||||
-- If the nvm inventry is full, the items are stored in the main inventory
|
||||
-- If the main inventory is also full, false is returned
|
||||
local function sort_in(inv, nvm, stack)
|
||||
if inv:room_for_item("main", stack) then -- for the case the nvm-inventory is full
|
||||
for _,item in ipairs(nvm.inventory or {}) do
|
||||
if item.name and (item.name == "" or item.name == stack:get_name()) then
|
||||
local count = math.min(stack:get_count(), STACK_SIZE - item.count)
|
||||
item.count = item.count + count
|
||||
item.name = stack:get_name()
|
||||
stack:set_count(stack:get_count() - count)
|
||||
if stack:get_count() == 0 then
|
||||
return true
|
||||
end
|
||||
end
|
||||
end
|
||||
inv:add_item("main", stack)
|
||||
return true
|
||||
end
|
||||
return false
|
||||
end
|
||||
|
||||
local function get_item(nvm, item_name, count)
|
||||
local stack = {count = 0}
|
||||
for _,item in ipairs(nvm.inventory or {}) do
|
||||
if (item_name == nil and stack.name == nil) or item.name == item_name then
|
||||
local num = math.min(item.count, count - stack.count)
|
||||
item.count = item.count - num
|
||||
stack.count = stack.count + num
|
||||
if item.name ~= "" then
|
||||
stack.name = item.name
|
||||
end
|
||||
if item.count == 0 then
|
||||
item.name = "" -- empty
|
||||
end
|
||||
if stack.count == count then
|
||||
return ItemStack(stack)
|
||||
end
|
||||
end
|
||||
end
|
||||
if stack.count > 0 then
|
||||
return ItemStack(stack)
|
||||
end
|
||||
end
|
||||
|
||||
local function formspec_container(x, y, nvm, inv)
|
||||
local tbl = {"container["..x..","..y.."]"}
|
||||
for i = 1,8 do
|
||||
local xpos = i - 1
|
||||
tbl[#tbl+1] = "box["..xpos..",0;0.8,0.9;#808080]"
|
||||
local stack = get_stack(nvm, i)
|
||||
if stack.name ~= "" then
|
||||
local itemname = stack.name.." "..stack.count
|
||||
--tbl[#tbl+1] = "item_image["..xpos..",1;1,1;"..itemname.."]"
|
||||
tbl[#tbl+1] = techage.item_image(xpos, 0, itemname)
|
||||
end
|
||||
if inv:get_stack("main", i):get_count() == 0 then
|
||||
tbl[#tbl+1] = "image_button["..xpos..",1;1,1;techage_form_get_arrow.png;get"..i..";]"
|
||||
else
|
||||
tbl[#tbl+1] = "image_button["..xpos..",1;1,1;techage_form_add_arrow.png;add"..i..";]"
|
||||
end
|
||||
end
|
||||
tbl[#tbl+1] = "list[context;main;0,2;8,1;]"
|
||||
tbl[#tbl+1] = "container_end[]"
|
||||
return table.concat(tbl, "")
|
||||
end
|
||||
|
||||
local function formspec(pos)
|
||||
local nvm = techage.get_nvm(pos)
|
||||
local inv = M(pos):get_inventory()
|
||||
return "size[8,7.2]"..
|
||||
default.gui_bg..
|
||||
default.gui_bg_img..
|
||||
default.gui_slots..
|
||||
formspec_container(0, 0, nvm, inv)..
|
||||
"list[current_player;main;0,3.5;8,4;]"..
|
||||
"listring[context;main]"..
|
||||
"listring[current_player;main]"
|
||||
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
|
||||
return stack:get_count()
|
||||
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
|
||||
return stack:get_count()
|
||||
end
|
||||
|
||||
local function 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
|
||||
return count
|
||||
end
|
||||
|
||||
local function on_metadata_inventory_put(pos, listname, index, stack, player)
|
||||
M(pos):set_string("formspec", formspec(pos))
|
||||
techage.set_activeformspec(pos, player)
|
||||
end
|
||||
|
||||
local function on_metadata_inventory_move(pos, from_list, from_index, to_list, to_index, count, player)
|
||||
M(pos):set_string("formspec", formspec(pos))
|
||||
techage.set_activeformspec(pos, player)
|
||||
end
|
||||
|
||||
local function on_metadata_inventory_take(pos, listname, index, stack, player)
|
||||
M(pos):set_string("formspec", formspec(pos))
|
||||
techage.set_activeformspec(pos, player)
|
||||
end
|
||||
|
||||
local function on_rightclick(pos, node, clicker)
|
||||
M(pos):set_string("formspec", formspec(pos))
|
||||
techage.set_activeformspec(pos, clicker)
|
||||
end
|
||||
|
||||
-- take items from chest
|
||||
local function move_from_nvm_to_inv(pos, idx)
|
||||
local nvm = techage.get_nvm(pos)
|
||||
local inv = M(pos):get_inventory()
|
||||
local inv_stack = inv:get_stack("main", idx)
|
||||
local nvm_stack = get_stack(nvm, idx)
|
||||
|
||||
if nvm_stack.count > 0 and inv_stack:get_count() == 0 then
|
||||
local count = math.min(nvm_stack.count, 99)
|
||||
nvm_stack.count = nvm_stack.count - count
|
||||
inv:set_stack("main", idx, {name = nvm_stack.name, count = count})
|
||||
if nvm_stack.count == 0 then
|
||||
nvm_stack.name = ""
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
-- add items to chest
|
||||
local function move_from_inv_to_nvm(pos, idx)
|
||||
local nvm = techage.get_nvm(pos)
|
||||
local inv = M(pos):get_inventory()
|
||||
local inv_stack = inv:get_stack("main", idx)
|
||||
local nvm_stack = get_stack(nvm, idx)
|
||||
|
||||
if inv_stack:get_count() > 0 then
|
||||
if nvm_stack.count == 0 or nvm_stack.name == inv_stack:get_name() then
|
||||
local count = math.min(inv_stack:get_count(), STACK_SIZE - nvm_stack.count)
|
||||
nvm_stack.count = nvm_stack.count + count
|
||||
nvm_stack.name = inv_stack:get_name()
|
||||
inv_stack:set_count(inv_stack:get_count() - count)
|
||||
inv:set_stack("main", idx, inv_stack)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
local function on_receive_fields(pos, formname, fields, player)
|
||||
if minetest.is_protected(pos, player:get_player_name()) then
|
||||
return
|
||||
end
|
||||
|
||||
for i = 1,8 do
|
||||
if fields["get"..i] ~= nil then
|
||||
move_from_nvm_to_inv(pos, i)
|
||||
break
|
||||
elseif fields["add"..i] ~= nil then
|
||||
move_from_inv_to_nvm(pos, i)
|
||||
break
|
||||
end
|
||||
end
|
||||
M(pos):set_string("formspec", formspec(pos))
|
||||
end
|
||||
|
||||
local function can_dig(pos, player)
|
||||
if minetest.is_protected(pos, player:get_player_name()) then
|
||||
return false
|
||||
end
|
||||
local inv = minetest.get_meta(pos):get_inventory()
|
||||
local nvm = techage.get_nvm(pos)
|
||||
return inv:is_empty("main") and inv_empty(nvm)
|
||||
end
|
||||
|
||||
local function after_dig_node(pos, oldnode, oldmetadata, digger)
|
||||
techage.remove_node(pos)
|
||||
end
|
||||
|
||||
minetest.register_node("techage:ta4_chest", {
|
||||
description = DESCRIPTION,
|
||||
tiles = {
|
||||
-- up, down, right, left, back, front
|
||||
"techage_filling_ta4.png^techage_frame_ta4.png",
|
||||
"techage_filling_ta4.png^techage_frame_ta4.png",
|
||||
"techage_filling_ta4.png^techage_frame_ta4.png^techage_appl_chest_back_ta4.png",
|
||||
"techage_filling_ta4.png^techage_frame_ta4.png^techage_appl_chest_back_ta4.png",
|
||||
"techage_filling_ta4.png^techage_frame_ta4.png^techage_appl_chest_back_ta4.png",
|
||||
"techage_filling_ta4.png^techage_frame_ta4.png^techage_appl_chest_front_ta4.png",
|
||||
},
|
||||
|
||||
on_construct = function(pos)
|
||||
local inv = M(pos):get_inventory()
|
||||
inv:set_size('main', 8)
|
||||
end,
|
||||
|
||||
after_place_node = function(pos, placer)
|
||||
local nvm = techage.get_nvm(pos)
|
||||
gen_inv(nvm)
|
||||
local number = techage.add_node(pos, "techage:ta4_chest")
|
||||
M(pos):set_string("owner", placer:get_player_name())
|
||||
M(pos):set_string("formspec", formspec(pos))
|
||||
M(pos):set_string("infotext", DESCRIPTION.." "..number)
|
||||
end,
|
||||
|
||||
techage_set_numbers = function(pos, numbers, player_name)
|
||||
return techage.logic.set_numbers(pos, numbers, player_name, DESCRIPTION)
|
||||
end,
|
||||
|
||||
on_rightclick = on_rightclick,
|
||||
on_receive_fields = on_receive_fields,
|
||||
can_dig = can_dig,
|
||||
after_dig_node = after_dig_node,
|
||||
allow_metadata_inventory_put = allow_metadata_inventory_put,
|
||||
allow_metadata_inventory_take = allow_metadata_inventory_take,
|
||||
|
||||
on_metadata_inventory_put = on_metadata_inventory_put,
|
||||
on_metadata_inventory_move = on_metadata_inventory_move,
|
||||
on_metadata_inventory_take = on_metadata_inventory_take,
|
||||
|
||||
paramtype2 = "facedir",
|
||||
groups = {choppy=2, cracky=2, crumbly=2},
|
||||
is_ground_content = false,
|
||||
sounds = default.node_sound_wood_defaults(),
|
||||
})
|
||||
|
||||
|
||||
techage.register_node({"techage:ta4_chest"}, {
|
||||
on_pull_item = function(pos, in_dir, num, item_name)
|
||||
local nvm = techage.get_nvm(pos)
|
||||
local res = get_item(nvm, item_name, num)
|
||||
if techage.is_activeformspec(pos) then
|
||||
M(pos):set_string("formspec", formspec(pos))
|
||||
end
|
||||
return res
|
||||
end,
|
||||
on_push_item = function(pos, in_dir, stack)
|
||||
local nvm = techage.get_nvm(pos)
|
||||
local inv = M(pos):get_inventory()
|
||||
local res = sort_in(inv, nvm, stack)
|
||||
if techage.is_activeformspec(pos) then
|
||||
M(pos):set_string("formspec", formspec(pos))
|
||||
end
|
||||
return res
|
||||
end,
|
||||
on_unpull_item = function(pos, in_dir, stack)
|
||||
local nvm = techage.get_nvm(pos)
|
||||
local inv = M(pos):get_inventory()
|
||||
local res = sort_in(inv, nvm, stack)
|
||||
if techage.is_activeformspec(pos) then
|
||||
M(pos):set_string("formspec", formspec(pos))
|
||||
end
|
||||
return res
|
||||
end,
|
||||
|
||||
on_recv_message = function(pos, src, topic, payload)
|
||||
if topic == "count" then
|
||||
local nvm = techage.get_nvm(pos)
|
||||
return get_count(nvm, tonumber(payload) or 0)
|
||||
elseif topic == "state" then
|
||||
local nvm = techage.get_nvm(pos)
|
||||
return inv_state(nvm)
|
||||
else
|
||||
return "unsupported"
|
||||
end
|
||||
end,
|
||||
})
|
||||
|
||||
minetest.register_craft({
|
||||
type = "shapeless",
|
||||
output = "techage:chest_ta4",
|
||||
recipe = {"techage:chest_ta3", "default:chest"}
|
||||
})
|
@ -283,7 +283,7 @@ end
|
||||
-- Param names: List of node names like {"techage:pusher_off", "techage:pusher_on"}
|
||||
-- Param node_definition: A table according to:
|
||||
-- {
|
||||
-- on_pull_item = func(pos, in_dir, num),
|
||||
-- on_pull_item = func(pos, in_dir, num, (opt.) item_name),
|
||||
-- on_push_item = func(pos, in_dir, item),
|
||||
-- on_unpull_item = func(pos, in_dir, item),
|
||||
-- on_recv_message = func(pos, src, topic, payload),
|
||||
@ -399,10 +399,10 @@ end
|
||||
-- Client side Push/Pull item functions
|
||||
-------------------------------------------------------------------
|
||||
|
||||
function techage.pull_items(pos, out_dir, num)
|
||||
function techage.pull_items(pos, out_dir, num, item_name)
|
||||
local npos, in_dir, name = get_dest_node(pos, out_dir)
|
||||
if npos and NodeDef[name] and NodeDef[name].on_pull_item then
|
||||
return NodeDef[name].on_pull_item(npos, in_dir, num)
|
||||
return NodeDef[name].on_pull_item(npos, in_dir, num, item_name)
|
||||
end
|
||||
end
|
||||
|
||||
|
@ -153,5 +153,6 @@ techage.Items = {
|
||||
ta4_gravelsieve = "techage:ta4_gravelsieve_pas",
|
||||
ta4_grinder = "techage:ta4_grinder_pas",
|
||||
ta4_detector = "techage:ta4_detector_off",
|
||||
ta4_chest = "techage:ta4_chest",
|
||||
--ta4_ "",
|
||||
}
|
||||
|
@ -160,6 +160,7 @@ techage.manual_DE.aTitel = {
|
||||
"3,TA4 Wasserpumpe / Water Pump",
|
||||
"3,TA4 Röhren / TA4 Tube",
|
||||
"3,TA4 Schieber / Pusher",
|
||||
"3,TA4 Kiste / Chest",
|
||||
"3,TA4 Verteiler / Distributor",
|
||||
"3,TA4 Kiessieb / Gravel Sieve",
|
||||
"3,TA4 Mühle / Grinder",
|
||||
@ -184,8 +185,7 @@ techage.manual_DE.aText = {
|
||||
"\n",
|
||||
"Diese Dokumentation ist sowohl \"ingame\" (Block Konstruktionsplan) als auch auf GitHub als MD-Files verfügbar.\n"..
|
||||
"\n"..
|
||||
" - Link: https://github.com/joe7575/techage/blob/master/manuals/toc_DE.md\n"..
|
||||
" - Short Link: https://tinyurl.com/y2lwl35h\n"..
|
||||
" - Link: https://github.com/joe7575/techage/wiki\n"..
|
||||
"\n"..
|
||||
"Die Konstruktionspläne (Diagramme) für den Aufbau der Maschinen sowie die Bilder sind aber nur ingame verfügbar.\n"..
|
||||
"\n"..
|
||||
@ -232,6 +232,7 @@ techage.manual_DE.aText = {
|
||||
" - 22.02.2020: Korrekturen und Kapitel zum Update\n"..
|
||||
" - 29.02.2020: ICTA Controller hinzugefügt und weitere Korrekturen\n"..
|
||||
" - 14.03.2020 Lua Controller hinzugefügt und weitere Korrekturen\n"..
|
||||
" - 22.03.2020 Weitere TA4 Blöcke hinzugefügt\n"..
|
||||
"\n",
|
||||
"In TA1 geht es darum\\, mit einfachen Werkzeugen und Gerätschaften ausreichend Erze zu schürfen und Holzkohle herzustellen\\, so dass damit TA2 Maschinen hergestellt und betrieben werden können.\n"..
|
||||
"\n"..
|
||||
@ -1274,8 +1275,21 @@ techage.manual_DE.aText = {
|
||||
"\n"..
|
||||
"\n"..
|
||||
"\n",
|
||||
"Die Funktion entspricht der von TA2.\n"..
|
||||
"Die Verarbeitungsleistung beträgt 18 Items alle 2 s.\n"..
|
||||
"Die Funktion entspricht grundsätzlich der von TA2/TA3. Zusätzlich kann aber über ein Menü konfiguriert werden\\, welche Gegenstände aus einer TA4 Kiste geholt und weiter transportiert werden sollen.\n"..
|
||||
"Die Verarbeitungsleistung beträgt 12 Items alle 2 s.\n"..
|
||||
"\n"..
|
||||
"Der TA4 Schieber besitzt zwei zusätzliche Kommandos für den Lua Controller:\n"..
|
||||
"\n"..
|
||||
" - 'config' dient zur Konfiguration des Schiebers\\, analog zum manuellen Konfiguration über das Menü.\nBeispiel: '$send_cmnd(PUSHER\\, \"config\"\\, \"default:dirt\")'\n"..
|
||||
" - 'pull' dient zum Absetzen eines Auftrags an den Schieber:\nBeispiel: '$send_cmnd(PUSHER\\, \"pull\"\\, \"default:dirt 8\")'\nAls Nummer sind Werte von 1 bis 12 zulässig. Danach geht der Schieber wieder in den 'stopped' Mode.\n"..
|
||||
"\n"..
|
||||
"\n"..
|
||||
"\n",
|
||||
"Die TA4 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"..
|
||||
"\n"..
|
||||
"Der TA4 Kiste besitzt ein zusätzliches Kommandos für den Lua Controller:\n"..
|
||||
"\n"..
|
||||
" - 'count' dient zur Anfrage\\, wie viele Items in der Kiste sind.\nBeispiel 1: '$read_data(CHEST\\, \"count\")' --> Summe der Items über alle 8 Speicher\nBeispiel 2: '$read_data(CHEST\\, \"count\"\\, 2)' --> Anzahl der Items in Speicher 2 (zweiter von links)\n"..
|
||||
"\n"..
|
||||
"\n"..
|
||||
"\n",
|
||||
@ -1456,6 +1470,7 @@ techage.manual_DE.aItemName = {
|
||||
"ta4_waterpump",
|
||||
"ta4_tube",
|
||||
"ta4_pusher",
|
||||
"ta4_chest",
|
||||
"ta4_distributor",
|
||||
"ta4_gravelsieve",
|
||||
"ta4_grinder",
|
||||
@ -1624,5 +1639,6 @@ techage.manual_DE.aPlanTable = {
|
||||
"",
|
||||
"",
|
||||
"",
|
||||
"",
|
||||
}
|
||||
|
||||
|
1
init.lua
1
init.lua
@ -106,6 +106,7 @@ else
|
||||
dofile(MP.."/basic_machines/electronic_fab.lua")
|
||||
dofile(MP.."/basic_machines/liquidsampler.lua")
|
||||
dofile(MP.."/basic_machines/quarry.lua")
|
||||
dofile(MP.."/basic_machines/ta4_chest.lua")
|
||||
|
||||
-- Liquids II
|
||||
dofile(MP.."/liquids/tank.lua")
|
||||
|
@ -112,6 +112,7 @@ Oil Pumpjack=Ölpumpe
|
||||
Oil Source=Erdöl
|
||||
Oil Tank=Öltank
|
||||
Oil amount=Ölmenge
|
||||
Optionally configure@nthe pusher with one item=Der Schieber kann optional@nmit einem Gegenstand@nkonfiguriert werden
|
||||
Outp=Ergeb.
|
||||
Plan=Plan
|
||||
Plastic Granules=Plastikgranulat
|
||||
|
@ -110,6 +110,7 @@ Oil Pumpjack=
|
||||
Oil Source=
|
||||
Oil Tank=
|
||||
Oil amount=
|
||||
Optionally configure@nthe pusher with one item=
|
||||
Outp=
|
||||
Plan=
|
||||
Plastic Granules=
|
||||
|
@ -39,14 +39,15 @@ techage.lua_ctlr.register_function("get_input", {
|
||||
})
|
||||
|
||||
techage.lua_ctlr.register_function("read_data", {
|
||||
cmnd = function(self, num, ident)
|
||||
cmnd = function(self, num, ident, add_data)
|
||||
num = tostring(num or "")
|
||||
return techage.send_single(self.meta.number, num, ident, nil)
|
||||
return techage.send_single(self.meta.number, num, ident, add_data)
|
||||
end,
|
||||
help = " $read_data(num, ident)\n"..
|
||||
help = " $read_data(num, ident, add_data)\n"..
|
||||
" Read any kind of data from another block.\n"..
|
||||
' "num" is the block number\n'..
|
||||
' "ident" specifies the data to be read\n'..
|
||||
' "add_data" is additional data (optional)\n'..
|
||||
' example: sts = $read_data("1234", "state")'
|
||||
})
|
||||
|
||||
@ -79,13 +80,13 @@ techage.lua_ctlr.register_action("send_cmnd", {
|
||||
num = tostring(num or "")
|
||||
cmnd = tostring(cmnd or "")
|
||||
if not_protected(self.meta.owner, num) then
|
||||
techage.send_single(self.meta.number, num, cmnd, data)
|
||||
return techage.send_single(self.meta.number, num, cmnd, data)
|
||||
end
|
||||
end,
|
||||
help = " $send_cmnd(num, cmnd, data)\n"..
|
||||
help = " $send_cmnd(num, cmnd, add_data)\n"..
|
||||
' Send a command to the device with number "num".\n'..
|
||||
' "cmnd" is the command as text string\n'..
|
||||
'"data" is additional data (optional)\n'..
|
||||
' "add_data" is additional data (optional)\n'..
|
||||
' example: $send_cmnd("1234", "on")'
|
||||
})
|
||||
|
||||
@ -180,5 +181,6 @@ techage.lua_ctlr.register_action("door", {
|
||||
" Hint: Use the Techage Programmer to\ndetermine the door position."
|
||||
})
|
||||
|
||||
|
||||
-- function not_protected(owner, number(s))
|
||||
techage.lua_ctlr.not_protected = not_protected
|
||||
|
@ -148,8 +148,11 @@ local function write_value(nvm, key, item)
|
||||
if nvm.data[key] then
|
||||
nvm.size = nvm.size - calc_size(nvm.data[key])
|
||||
end
|
||||
print(type(item))
|
||||
if type(item) == "table" then
|
||||
print("item1", dump(item))
|
||||
item = safer_lua.datastruct_to_table(item)
|
||||
print("item1", dump(item))
|
||||
end
|
||||
nvm.size = nvm.size + calc_size(item)
|
||||
nvm.data[key] = item
|
||||
|
@ -22,8 +22,7 @@ Regenerative Energiequellen wie Wind, Sonne und Biokraft helfen dir, das Ölzeit
|
||||
|
||||
Diese Dokumentation ist sowohl "ingame" (Block Konstruktionsplan) als auch auf GitHub als MD-Files verfügbar.
|
||||
|
||||
- Link: https://github.com/joe7575/techage/blob/master/manuals/toc_DE.md
|
||||
- Short Link: https://tinyurl.com/y2lwl35h
|
||||
- Link: https://github.com/joe7575/techage/wiki
|
||||
|
||||
Die Konstruktionspläne (Diagramme) für den Aufbau der Maschinen sowie die Bilder sind aber nur ingame verfügbar.
|
||||
|
||||
@ -93,4 +92,5 @@ Es wird zur Herstellung von Aluminium benötigt, was vor allem in TA4 Verwendung
|
||||
- 22.02.2020: Korrekturen und Kapitel zum Update
|
||||
- 29.02.2020: ICTA Controller hinzugefügt und weitere Korrekturen
|
||||
- 14.03.2020 Lua Controller hinzugefügt und weitere Korrekturen
|
||||
- 22.03.2020 Weitere TA4 Blöcke hinzugefügt
|
||||
|
||||
|
@ -449,11 +449,33 @@ TA4 hat auch seine eigenen Röhren im TA4 Design. Diese entsprechen den Standard
|
||||
|
||||
### TA4 Schieber / Pusher
|
||||
|
||||
Die Funktion entspricht der von TA2.
|
||||
Die Verarbeitungsleistung beträgt 18 Items alle 2 s.
|
||||
Die Funktion entspricht grundsätzlich der von TA2/TA3. Zusätzlich kann aber über ein Menü konfiguriert werden, welche Gegenstände aus einer TA4 Kiste geholt und weiter transportiert werden sollen.
|
||||
Die Verarbeitungsleistung beträgt 12 Items alle 2 s.
|
||||
|
||||
Der TA4 Schieber besitzt zwei zusätzliche Kommandos für den Lua Controller:
|
||||
|
||||
- `config` dient zur Konfiguration des Schiebers, analog zum manuellen Konfiguration über das Menü.
|
||||
Beispiel: `$send_cmnd(PUSHER, "config", "default:dirt")`
|
||||
- `pull` dient zum Absetzen eines Auftrags an den Schieber:
|
||||
Beispiel: `$send_cmnd(PUSHER, "pull", "default:dirt 8")`
|
||||
Als Nummer sind Werte von 1 bis 12 zulässig. Danach geht der Schieber wieder in den `stopped` Mode.
|
||||
|
||||
[ta4_pusher|image]
|
||||
|
||||
### TA4 Kiste / Chest
|
||||
|
||||
Die TA4 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.
|
||||
|
||||
Der TA4 Kiste besitzt ein zusätzliches Kommandos für den Lua Controller:
|
||||
|
||||
- `count` dient zur Anfrage, wie viele Items in der Kiste sind.
|
||||
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)
|
||||
|
||||
[ta4_chest|image]
|
||||
|
||||
|
||||
|
||||
### TA4 Verteiler / Distributor
|
||||
|
||||
Die Funktion entspricht der von TA2.
|
||||
|
@ -345,7 +345,10 @@ In addition to Lua standard function the Lua Controller provides the following f
|
||||
|
||||
### Techage Command Functions
|
||||
|
||||
* `$read_data(num, ident)` - Read any kind of data from another block with the given number _num_. _ident_ specifies the data to be read. The result is block dependent (see table below):
|
||||
* `$read_data(num, ident, add_data)` - Read any kind of data from another block with the given number _num_.
|
||||
_ident_ specifies the data to be read.
|
||||
_add_data_ is for additional data and normally not needed.
|
||||
The result is block dependent (see table below):
|
||||
|
||||
| ident | returned data | comment |
|
||||
| ----------- | ------------------------------------------------------------ | ------------------------------------------------------------ |
|
||||
@ -358,6 +361,7 @@ In addition to Lua standard function the Lua Controller provides the following f
|
||||
| "action" | player-name, action-string | only for Sensor Chests |
|
||||
| "stacks" | Array with up to 4 Stores with the inventory content (see example) | only for Sensor Chests |
|
||||
| "count" | number | Read the item counter of the TA4 Item Detector block |
|
||||
| "count" | number of items | Read the total amount of TA4 chest items. An optional number as `add_data` is used to address only on inventory slot (1..8, from left to right). |
|
||||
|
||||
|
||||
|
||||
@ -365,12 +369,14 @@ In addition to Lua standard function the Lua Controller provides the following f
|
||||
* `$send_cmnd(num, cmnd, data)` - Send a command to another block. _num_ is the number of the remote block, like "1234". _cmnd_ is the command, _data_ is additional data (see table below):
|
||||
|
||||
| cmnd | data | comment |
|
||||
| -------------------------------- | ----------- | ----------------------------------------------------- |
|
||||
| -------------------------------- | ------------ | ------------------------------------------------------------ |
|
||||
| "on", "off" | nil | turn a node on/off (machine, lamp,...) |
|
||||
| "red, "amber", "green", "off" | nil | set Signal Tower color |
|
||||
| "red", "green", "blue", "yellow" | "on", "off" | Enable/disable a Distributor filter slot. |
|
||||
| "text" | text string | Text to be used for the Sensor Chest menu |
|
||||
| "reset" | nil | Reset the item counter of the TA4 Item Detector block |
|
||||
| "pull" | item string | Start the TA4 pusher to pull/push items.<br /> Example: `default:dirt 8` |
|
||||
| "config" | item string | Configure the TA4 pusher.<br />Example: `wool:blue` |
|
||||
|
||||
|
||||
|
||||
|
@ -159,6 +159,7 @@
|
||||
- [TA4 Wasserpumpe / Water Pump](./manual_ta4_DE.md#ta4-wasserpumpe--water-pump)
|
||||
- [TA4 Röhren / TA4 Tube](./manual_ta4_DE.md#ta4-röhren--ta4-tube)
|
||||
- [TA4 Schieber / Pusher](./manual_ta4_DE.md#ta4-schieber--pusher)
|
||||
- [TA4 Kiste / Chest](./manual_ta4_DE.md#ta4-kiste--chest)
|
||||
- [TA4 Verteiler / Distributor](./manual_ta4_DE.md#ta4-verteiler--distributor)
|
||||
- [TA4 Kiessieb / Gravel Sieve](./manual_ta4_DE.md#ta4-kiessieb--gravel-sieve)
|
||||
- [TA4 Mühle / Grinder](./manual_ta4_DE.md#ta4-mühle--grinder)
|
BIN
textures/techage_form_add_arrow.png
Normal file
BIN
textures/techage_form_add_arrow.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 182 B |
BIN
textures/techage_form_get_arrow.png
Normal file
BIN
textures/techage_form_get_arrow.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 183 B |
Loading…
Reference in New Issue
Block a user