built on 13/09/2020 13:24:06
This commit is contained in:
parent
323d160ccf
commit
553cedb06b
@ -116,4 +116,5 @@ History
|
||||
2020-06-14 v1.06 API changed and chat command added
|
||||
2020-06-27 v1.07 Route storage and cart command bugfixes
|
||||
2020-07-24 V1.08 Adapted to new techage ICTA style
|
||||
|
||||
2020-08-14 V1.09 Hopper support for digtron, protector:chest and default:furnace added
|
||||
|
||||
|
@ -1,3 +1,4 @@
|
||||
default
|
||||
carts
|
||||
screwdriver
|
||||
doc?
|
||||
|
@ -13,7 +13,7 @@
|
||||
minecart = {}
|
||||
|
||||
-- Version for compatibility checks, see readme.md/history
|
||||
minecart.version = 1.08
|
||||
minecart.version = 1.09
|
||||
|
||||
minecart.hopper_enabled = minetest.settings:get_bool("minecart_hopper_enabled") ~= false
|
||||
|
||||
@ -31,6 +31,7 @@ dofile(MP.."/protection.lua")
|
||||
|
||||
if minecart.hopper_enabled then
|
||||
dofile(MP.."/hopper.lua")
|
||||
dofile(MP.."/mods_support.lua")
|
||||
end
|
||||
dofile(MP.."/doc.lua")
|
||||
minetest.log("info", "[MOD] Minecart loaded")
|
||||
|
@ -147,6 +147,8 @@ function minecart.take_items(pos, param2, num)
|
||||
|
||||
if def and inv and def.take_listname and (not def.allow_take or def.allow_take(npos, nil, owner)) then
|
||||
return minecart.inv_take_items(inv, def.take_listname, num)
|
||||
elseif def and def.take_item then
|
||||
return def.take_item(npos, num, owner)
|
||||
else
|
||||
local ndef = minetest.registered_nodes[node.name]
|
||||
if ndef and ndef.minecart_hopper_takeitem then
|
||||
@ -166,6 +168,8 @@ function minecart.put_items(pos, param2, stack)
|
||||
if leftover:get_count() > 0 then
|
||||
return leftover
|
||||
end
|
||||
elseif def and def.put_item then
|
||||
return def.put_item(npos, stack, owner)
|
||||
elseif is_air_like(node.name) or check_cart_for_loading(npos) then
|
||||
minetest.add_item(npos, stack)
|
||||
else
|
||||
@ -191,8 +195,10 @@ function minecart.untake_items(pos, param2, stack)
|
||||
local def = RegisteredInventories[node.name]
|
||||
local inv = minetest.get_inventory({type="node", pos=npos})
|
||||
|
||||
if def then
|
||||
return inv and inv:add_item(def.put_listname, stack)
|
||||
if def and inv and def.put_listname then
|
||||
return inv:add_item(def.put_listname, stack)
|
||||
elseif def and def.untake_item then
|
||||
return def.untake_item(npos, stack)
|
||||
else
|
||||
local ndef = minetest.registered_nodes[node.name]
|
||||
if ndef and ndef.minecart_hopper_untakeitem then
|
||||
@ -230,6 +236,9 @@ function minecart.register_inventory(node_names, def)
|
||||
put_listname = def.put and def.put.listname,
|
||||
allow_take = def.take and def.take.allow_inventory_take,
|
||||
take_listname = def.take and def.take.listname,
|
||||
put_item = def.put and def.put.put_item,
|
||||
take_item = def.take and def.take.take_item,
|
||||
untake_item = def.take and def.take.untake_item,
|
||||
}
|
||||
end
|
||||
end
|
||||
@ -272,32 +281,6 @@ minetest.register_on_player_receive_fields(function(player, formname, fields)
|
||||
return false
|
||||
end)
|
||||
|
||||
minecart.register_inventory({"default:chest", "default:chest_open"}, {
|
||||
put = {
|
||||
listname = "main",
|
||||
},
|
||||
take = {
|
||||
listname = "main",
|
||||
},
|
||||
})
|
||||
|
||||
minecart.register_inventory({"default:chest_locked", "default:chest_locked_open"}, {
|
||||
put = {
|
||||
allow_inventory_put = function(pos, stack, player_name)
|
||||
local owner = M(pos):get_string("owner")
|
||||
return owner == player_name
|
||||
end,
|
||||
listname = "main",
|
||||
},
|
||||
take = {
|
||||
allow_inventory_take = function(pos, stack, player_name)
|
||||
local owner = M(pos):get_string("owner")
|
||||
return owner == player_name
|
||||
end,
|
||||
listname = "main",
|
||||
},
|
||||
})
|
||||
|
||||
minecart.register_inventory({"minecart:hopper"}, {
|
||||
put = {
|
||||
allow_inventory_put = function(pos, stack, player_name)
|
||||
|
131
minecart/mods_support.lua
Normal file
131
minecart/mods_support.lua
Normal file
@ -0,0 +1,131 @@
|
||||
--[[
|
||||
|
||||
Minecart
|
||||
========
|
||||
|
||||
Copyright (C) 2019-2020 Joachim Stolberg
|
||||
|
||||
MIT
|
||||
See license.txt for more information
|
||||
|
||||
Wrapper functions to get hopper support for other mods
|
||||
|
||||
]]--
|
||||
|
||||
-- for lazy programmers
|
||||
local M = minetest.get_meta
|
||||
|
||||
local CacheForFuelNodeNames = {}
|
||||
|
||||
local function is_fuel(stack)
|
||||
local name = stack:get_name()
|
||||
if CacheForFuelNodeNames[name] then
|
||||
return true
|
||||
end
|
||||
if minetest.get_craft_result({method="fuel", width=1, items={stack}}).time ~= 0 then
|
||||
CacheForFuelNodeNames[name] = true
|
||||
end
|
||||
return CacheForFuelNodeNames[name]
|
||||
end
|
||||
|
||||
------------------------------------------------------------------------------
|
||||
-- default
|
||||
------------------------------------------------------------------------------
|
||||
|
||||
minecart.register_inventory({"default:chest", "default:chest_open"}, {
|
||||
put = {
|
||||
listname = "main",
|
||||
},
|
||||
take = {
|
||||
listname = "main",
|
||||
},
|
||||
})
|
||||
|
||||
minecart.register_inventory({"default:chest_locked", "default:chest_locked_open"}, {
|
||||
put = {
|
||||
allow_inventory_put = function(pos, stack, player_name)
|
||||
local owner = M(pos):get_string("owner")
|
||||
return owner == player_name
|
||||
end,
|
||||
listname = "main",
|
||||
},
|
||||
take = {
|
||||
allow_inventory_take = function(pos, stack, player_name)
|
||||
local owner = M(pos):get_string("owner")
|
||||
return owner == player_name
|
||||
end,
|
||||
listname = "main",
|
||||
},
|
||||
})
|
||||
|
||||
minecart.register_inventory({"default:furnace", "default:furnace_active"}, {
|
||||
put = {
|
||||
-- distinguish between fuel and other items
|
||||
put_item = function(pos, stack, player_name)
|
||||
local inv = minetest.get_inventory({type="node", pos=pos})
|
||||
local listname = is_fuel(stack) and "fuel" or "src"
|
||||
local leftover = inv:add_item(listname, stack)
|
||||
minetest.get_node_timer(pos):start(1.0)
|
||||
if leftover:get_count() > 0 then
|
||||
return leftover
|
||||
end
|
||||
end,
|
||||
},
|
||||
take = {
|
||||
-- fuel can't be taken
|
||||
listname = "dst",
|
||||
},
|
||||
})
|
||||
|
||||
------------------------------------------------------------------------------
|
||||
-- digtron
|
||||
------------------------------------------------------------------------------
|
||||
|
||||
minecart.register_inventory({"digtron:inventory"}, {
|
||||
put = {
|
||||
listname = "main",
|
||||
},
|
||||
take = {
|
||||
listname = "main",
|
||||
},
|
||||
})
|
||||
|
||||
minecart.register_inventory({"digtron:fuelstore"}, {
|
||||
put = {
|
||||
listname = "fuel",
|
||||
},
|
||||
take = {
|
||||
listname = "fuel",
|
||||
},
|
||||
})
|
||||
|
||||
minecart.register_inventory({"digtron:combined_storage"}, {
|
||||
put = {
|
||||
-- distinguish between fuel and other items
|
||||
put_item = function(pos, stack, player_name)
|
||||
local inv = minetest.get_inventory({type="node", pos=pos})
|
||||
local listname = is_fuel(stack) and "fuel" or "main"
|
||||
local leftover = inv:add_item(listname, stack)
|
||||
if leftover:get_count() > 0 then
|
||||
return leftover
|
||||
end
|
||||
end,
|
||||
},
|
||||
take = {
|
||||
-- fuel can't be taken
|
||||
listname = "main",
|
||||
},
|
||||
})
|
||||
|
||||
------------------------------------------------------------------------------
|
||||
-- protector
|
||||
------------------------------------------------------------------------------
|
||||
|
||||
minecart.register_inventory({"protector:chest"}, {
|
||||
put = {
|
||||
listname = "main",
|
||||
},
|
||||
take = {
|
||||
listname = "main",
|
||||
},
|
||||
})
|
@ -32,18 +32,11 @@ function signs_bot.register_flower(name)
|
||||
end
|
||||
|
||||
minetest.after(1, function()
|
||||
for name,_ in pairs(minetest.registered_decorations) do
|
||||
if type(name) == "string" then
|
||||
for _,def in pairs(minetest.registered_decorations) do
|
||||
local name = def.decoration
|
||||
if name and type(name) == "string" then
|
||||
local mod = string.split(name, ":")[1]
|
||||
if mod == "flowers" then
|
||||
signs_bot.register_flower(name)
|
||||
end
|
||||
end
|
||||
end
|
||||
for name,ndef in pairs(minetest.registered_nodes) do
|
||||
if type(name) == "string" then
|
||||
local mod = string.split(name, ":")[1]
|
||||
if mod == "flowers" then
|
||||
if mod == "flowers" or mod == "bakedclay" then -- Bakedclay also registers flowers as decoration.
|
||||
signs_bot.register_flower(name)
|
||||
end
|
||||
end
|
||||
|
@ -147,12 +147,13 @@ end
|
||||
|
||||
register_command("repeat", 1,
|
||||
function(base_pos, mem, cnt)
|
||||
mem.Stack[#mem.Stack + 1] = cnt
|
||||
mem.Stack[#mem.Stack + 1] = tonumber(cnt)
|
||||
mem.Stack[#mem.Stack + 1] = mem.pc + 1
|
||||
return api.DONE
|
||||
end,
|
||||
function(cnt)
|
||||
return cnt and cnt > 0 and cnt < 1000
|
||||
cnt = tonumber(cnt) or 0
|
||||
return cnt > 0 and cnt < 1000
|
||||
end
|
||||
)
|
||||
|
||||
|
@ -9,7 +9,8 @@ if minetest.get_modpath("techage") then
|
||||
local Cable = techage.ElectricCable
|
||||
local power = techage.power
|
||||
|
||||
signs_bot.register_inventory({"techage:chest_ta2", "techage:chest_ta3", "techage:chest_ta4"}, {
|
||||
signs_bot.register_inventory({"techage:chest_ta2", "techage:chest_ta3", "techage:chest_ta4",
|
||||
"techage:ta3_silo", "techage:ta4_silo"}, {
|
||||
allow_inventory_put = function(pos, stack, player_name)
|
||||
return not minetest.is_protected(pos, player_name)
|
||||
end,
|
||||
@ -61,7 +62,7 @@ if minetest.get_modpath("techage") then
|
||||
and minetest.registered_nodes[node.name].on_ignite then
|
||||
minetest.registered_nodes[node.name].on_ignite(pos)
|
||||
end
|
||||
return true
|
||||
return signs_bot.DONE
|
||||
end,
|
||||
})
|
||||
|
||||
|
@ -77,6 +77,21 @@ Available worlds will be converted to 'lsqlite3', but there is no way back, so:
|
||||
|
||||
### History
|
||||
|
||||
**2020-09-13 V0.23**
|
||||
- Pull request #26: Digtron Battery: Fix duplication bug (from Thomas-S)
|
||||
- Improve ta4 sensor box
|
||||
- Firebox: Add check for free space when placing the node
|
||||
- Lua controller: Add 'get_gametime' function
|
||||
- Pull request #27: Liquid Tanks: Add protection support (from Thomas-S)
|
||||
- Fix pump issue (silo source items can disappear)
|
||||
- Pull request #28: Quarry: Improve digging behaviour (from Thomas-S)
|
||||
- Pull request #28: Battery: Store battery load as metadata (from Thomas-S)
|
||||
- Pull request #29: Distributor: Keep item metadata (from Thomas-S)
|
||||
|
||||
**2020-08-08 V0.22**
|
||||
- Pull request #25: Growlight: Improve flower registration (from Thomas-S)
|
||||
- Add tube support for digtron chests and protector:chest
|
||||
|
||||
**2020-08-08 V0.21**
|
||||
- Pull request #18: Add a simple Digtron battery (from Thomas-S)
|
||||
- Pull request #23: Lua Controller: Fix $item_description() documentation and translation (from Thomas-S)
|
||||
|
@ -233,6 +233,7 @@ function techage.register_consumer(base_name, inv_name, tiles, tNode, validState
|
||||
on_rightclick = tNode.on_rightclick,
|
||||
after_place_node = after_place_node,
|
||||
after_dig_node = after_dig_node,
|
||||
preserve_metadata = tNode.preserve_metadata,
|
||||
tubelib2_on_update2 = tubelib2_on_update2,
|
||||
allow_metadata_inventory_put = tNode.allow_metadata_inventory_put,
|
||||
allow_metadata_inventory_move = tNode.allow_metadata_inventory_move,
|
||||
|
@ -215,7 +215,7 @@ local function tubelib2_on_update2(pos, outdir, tlib2, node)
|
||||
end
|
||||
end
|
||||
|
||||
local function push_item(pos, filter, item_name, num_items, nvm)
|
||||
local function push_item(pos, filter, itemstack, num_items, nvm)
|
||||
local idx = 1
|
||||
local num_pushed = 0
|
||||
local num_ports = #filter
|
||||
@ -226,7 +226,7 @@ local function push_item(pos, filter, item_name, num_items, nvm)
|
||||
num_of_trials = num_of_trials + 1
|
||||
local push_dir = filter[randidx[idx]]
|
||||
local num_to_push = math.min(amount, num_items - num_pushed)
|
||||
if techage.push_items(pos, push_dir, ItemStack(item_name.." "..num_to_push)) then
|
||||
if techage.push_items(pos, push_dir, itemstack:peek_item(num_to_push)) then
|
||||
num_pushed = num_pushed + num_to_push
|
||||
nvm.port_counter[push_dir] = (nvm.port_counter[push_dir] or 0) + num_to_push
|
||||
end
|
||||
@ -255,18 +255,19 @@ local function distributing(pos, inv, crd, nvm)
|
||||
local item_name = stack:get_name()
|
||||
local num_items = stack:get_count()
|
||||
local num_to_push = math.min((nvm.num_items or crd.num_items) - sum_num_pushed, num_items)
|
||||
local stack_to_push = stack:peek_item(num_to_push)
|
||||
num_pushed = 0
|
||||
|
||||
if item_filter[item_name] then
|
||||
-- Push items based on filter
|
||||
num_pushed = push_item(pos, item_filter[item_name], item_name, num_to_push, nvm)
|
||||
num_pushed = push_item(pos, item_filter[item_name], stack_to_push, num_to_push, nvm)
|
||||
elseif blocking_mode and #open_ports > 0 then
|
||||
-- Push items based on open ports
|
||||
num_pushed = push_item(pos, open_ports, item_name, num_to_push, nvm)
|
||||
num_pushed = push_item(pos, open_ports, stack_to_push, num_to_push, nvm)
|
||||
end
|
||||
if not blocking_mode and num_pushed == 0 and #open_ports > 0 then
|
||||
-- Push items based on open ports
|
||||
num_pushed = push_item(pos, open_ports, item_name, num_to_push, nvm)
|
||||
num_pushed = push_item(pos, open_ports, stack_to_push, num_to_push, nvm)
|
||||
end
|
||||
|
||||
sum_num_pushed = sum_num_pushed + num_pushed
|
||||
|
@ -1,16 +1,14 @@
|
||||
--[[
|
||||
|
||||
Tube Library
|
||||
============
|
||||
TechAge
|
||||
=======
|
||||
|
||||
Copyright (C) 2017 Joachim Stolberg
|
||||
Copyright (C) 2019-2020 Joachim Stolberg
|
||||
|
||||
GPL v3
|
||||
See LICENSE.txt for more information
|
||||
|
||||
legacy_nodes.lua:
|
||||
|
||||
Tubelib support for chests and furnace
|
||||
Tube support for default chests and furnace
|
||||
|
||||
]]--
|
||||
|
||||
|
117
techage/basic_machines/mods_support.lua
Normal file
117
techage/basic_machines/mods_support.lua
Normal file
@ -0,0 +1,117 @@
|
||||
--[[
|
||||
|
||||
TechAge
|
||||
=======
|
||||
|
||||
Copyright (C) 2019-2020 Joachim Stolberg
|
||||
|
||||
GPL v3
|
||||
See LICENSE.txt for more information
|
||||
|
||||
Tube support for digtron and protector chests
|
||||
|
||||
]]--
|
||||
|
||||
|
||||
-- for lazy programmers
|
||||
local M = minetest.get_meta
|
||||
|
||||
local CacheForFuelNodeNames = {}
|
||||
|
||||
local function is_fuel(stack)
|
||||
local name = stack:get_name()
|
||||
if CacheForFuelNodeNames[name] then
|
||||
return true
|
||||
end
|
||||
if minetest.get_craft_result({method="fuel", width=1, items={stack}}).time ~= 0 then
|
||||
CacheForFuelNodeNames[name] = true
|
||||
end
|
||||
return CacheForFuelNodeNames[name]
|
||||
end
|
||||
|
||||
------------------------------------------------------------------------------
|
||||
-- digtron
|
||||
------------------------------------------------------------------------------
|
||||
|
||||
techage.register_node({"digtron:inventory"}, {
|
||||
on_pull_item = function(pos, in_dir, num)
|
||||
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,
|
||||
})
|
||||
|
||||
techage.register_node({"digtron:fuelstore"}, {
|
||||
on_pull_item = function(pos, in_dir, num)
|
||||
local meta = minetest.get_meta(pos)
|
||||
local inv = meta:get_inventory()
|
||||
return techage.get_items(pos, inv, "fuel", 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, "fuel", 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, "fuel", stack)
|
||||
end,
|
||||
})
|
||||
|
||||
techage.register_node({"digtron:combined_storage"}, {
|
||||
on_pull_item = function(pos, in_dir, num)
|
||||
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, side, stack)
|
||||
local meta = minetest.get_meta(pos)
|
||||
local inv = meta:get_inventory()
|
||||
minetest.get_node_timer(pos):start(1.0)
|
||||
if is_fuel(stack) then
|
||||
return techage.put_items(inv, "fuel", stack)
|
||||
else
|
||||
return techage.put_items(inv, "main", stack)
|
||||
end
|
||||
end,
|
||||
on_unpull_item = function(pos, side, stack)
|
||||
local meta = minetest.get_meta(pos)
|
||||
local inv = meta:get_inventory()
|
||||
return techage.put_items(inv, "main", stack)
|
||||
end,
|
||||
})
|
||||
|
||||
------------------------------------------------------------------------------
|
||||
-- protector
|
||||
------------------------------------------------------------------------------
|
||||
|
||||
techage.register_node({"protector:chest"}, {
|
||||
on_pull_item = function(pos, in_dir, num)
|
||||
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,
|
||||
})
|
||||
|
||||
|
@ -157,23 +157,6 @@ local function mark_area(pos1, pos2, owner)
|
||||
pos1.y = pos1.y - 0.2
|
||||
end
|
||||
|
||||
local function peek_node(qpos)
|
||||
local node = techage.get_node_lvm(qpos)
|
||||
local ndef = minetest.registered_nodes[node.name]
|
||||
if techage.can_node_dig(node, ndef) then
|
||||
return techage.dropped_node(node, ndef)
|
||||
end
|
||||
end
|
||||
|
||||
local function add_to_inv(pos, item_name)
|
||||
local inv = M(pos):get_inventory()
|
||||
if inv:room_for_item("main", item_name) then
|
||||
inv:add_item("main", item_name)
|
||||
return true
|
||||
end
|
||||
return false
|
||||
end
|
||||
|
||||
local function quarry_task(pos, crd, nvm)
|
||||
nvm.start_level = nvm.start_level or 0
|
||||
nvm.quarry_depth = nvm.quarry_depth or 1
|
||||
@ -182,6 +165,30 @@ local function quarry_task(pos, crd, nvm)
|
||||
local y_last = y_first - nvm.quarry_depth + 1
|
||||
local facedir = minetest.get_node(pos).param2
|
||||
local owner = M(pos):get_string("owner")
|
||||
local fake_player = techage.Fake_player:new()
|
||||
fake_player.get_pos = function (...)
|
||||
return pos
|
||||
end
|
||||
fake_player.get_inventory = function(...)
|
||||
return M(pos):get_inventory()
|
||||
end
|
||||
|
||||
local add_to_inv = function(itemstacks)
|
||||
local at_least_one_added = false
|
||||
local inv = M(pos):get_inventory()
|
||||
if #itemstacks == 0 then
|
||||
return true
|
||||
end
|
||||
for _,stack in ipairs(itemstacks) do
|
||||
if inv:room_for_item("main", stack) then
|
||||
inv:add_item("main", stack)
|
||||
at_least_one_added = true
|
||||
elseif at_least_one_added then
|
||||
minetest.add_item({x=pos.x,y=pos.y+1,z=pos.z}, stack)
|
||||
end
|
||||
end
|
||||
return at_least_one_added
|
||||
end
|
||||
|
||||
local pos1, pos2 = get_corner_positions(pos, facedir, nvm.hole_diameter)
|
||||
nvm.level = 1
|
||||
@ -203,14 +210,13 @@ local function quarry_task(pos, crd, nvm)
|
||||
for zoffs = 1, nvm.hole_diameter do
|
||||
for xoffs = 1, nvm.hole_diameter do
|
||||
local qpos = get_quarry_pos(pos1, xoffs, zoffs)
|
||||
local item_name = peek_node(qpos)
|
||||
if item_name then
|
||||
if add_to_inv(pos, item_name) then
|
||||
minetest.remove_node(qpos)
|
||||
crd.State:keep_running(pos, nvm, COUNTDOWN_TICKS)
|
||||
else
|
||||
crd.State:blocked(pos, nvm, S("inventory full"))
|
||||
end
|
||||
local dig_state = techage.dig_like_player(qpos, fake_player, add_to_inv)
|
||||
|
||||
if dig_state == techage.dig_states.INV_FULL then
|
||||
crd.State:blocked(pos, nvm, S("inventory full"))
|
||||
coroutine.yield()
|
||||
elseif dig_state == techage.dig_states.DUG then
|
||||
crd.State:keep_running(pos, nvm, COUNTDOWN_TICKS)
|
||||
coroutine.yield()
|
||||
end
|
||||
end
|
||||
@ -229,7 +235,10 @@ local function keep_running(pos, elapsed)
|
||||
|
||||
local nvm = techage.get_nvm(pos)
|
||||
local crd = CRD(pos)
|
||||
coroutine.resume(mem.co, pos, crd, nvm)
|
||||
local _, err = coroutine.resume(mem.co, pos, crd, nvm)
|
||||
if err then
|
||||
minetest.log("error", "[TA4 Quarry Coroutine Error]" .. err)
|
||||
end
|
||||
|
||||
if techage.is_activeformspec(pos) then
|
||||
M(pos):set_string("formspec", formspec(crd.State, pos, nvm))
|
||||
|
@ -81,7 +81,7 @@ local function check_space(pos, param2, AssemblyPlan, player_name)
|
||||
|
||||
local node = techage.get_node_lvm(pos1)
|
||||
local ndef = minetest.registered_nodes[node.name]
|
||||
if not ndef or ndef.walkable and node.name ~= node_name then
|
||||
if not ndef or not ndef.buildable_to and node.name ~= node_name then
|
||||
minetest.chat_send_player(player_name, S("[TA] Not enough space!"))
|
||||
return false
|
||||
end
|
||||
|
118
techage/basis/fake_player.lua
Normal file
118
techage/basis/fake_player.lua
Normal file
@ -0,0 +1,118 @@
|
||||
--[[
|
||||
|
||||
TechAge
|
||||
=======
|
||||
|
||||
Copyright (C) 2019-2020 Joachim Stolberg
|
||||
Copyright (C) 2020 Thomas S.
|
||||
|
||||
GPL v3
|
||||
See LICENSE.txt for more information
|
||||
|
||||
Fake Player
|
||||
|
||||
]]--
|
||||
|
||||
-- Map method names to their return values
|
||||
local methods = {
|
||||
get_pos = { x = 0, y = 0, z = 0 },
|
||||
set_pos = nil,
|
||||
moveto = nil,
|
||||
punch = nil,
|
||||
right_click = nil,
|
||||
get_hp = 20,
|
||||
set_hp = nil,
|
||||
get_inventory = nil,
|
||||
get_wield_list = "",
|
||||
get_wield_index = 0,
|
||||
get_wielded_item = ItemStack(),
|
||||
set_wielded_item = true,
|
||||
set_armor_groups = nil,
|
||||
get_armor_groups = {},
|
||||
set_animation = nil,
|
||||
get_animation = {},
|
||||
set_animation_frame_speed = nil,
|
||||
set_attach = nil,
|
||||
get_attach = nil,
|
||||
set_detach = nil,
|
||||
get_bone_position = {},
|
||||
set_properties = nil,
|
||||
get_properties = {},
|
||||
is_player = false,
|
||||
get_nametag_attributes = {},
|
||||
set_nametag_attributes = nil,
|
||||
get_player_name = "",
|
||||
get_player_velocity = nil,
|
||||
add_player_velocity = nil,
|
||||
get_look_dir = vector.new(0, 0, 1),
|
||||
get_look_vertical = 0,
|
||||
get_look_horizontal = 0,
|
||||
set_look_vertical = nil,
|
||||
set_look_horizontal = nil,
|
||||
get_look_pitch = 0,
|
||||
get_look_yaw = 0,
|
||||
set_look_pitch = nil,
|
||||
set_look_yaw = nil,
|
||||
get_breath = 10,
|
||||
set_breath = nil,
|
||||
set_fov = nil,
|
||||
get_fov = 0,
|
||||
set_attribute = nil,
|
||||
get_attribute = nil,
|
||||
get_meta = nil,
|
||||
set_inventory_formspec = nil,
|
||||
get_inventory_formspec = "",
|
||||
set_formspec_prepend = nil,
|
||||
get_formspec_prepend = "",
|
||||
get_player_control = {},
|
||||
get_player_control_bits = 0,
|
||||
set_physics_override = nil,
|
||||
get_physics_override = {},
|
||||
hud_add = 0,
|
||||
hud_remove = nil,
|
||||
hud_change = nil,
|
||||
hud_get = {},
|
||||
hud_set_flags = nil,
|
||||
hud_get_flags = {},
|
||||
hud_set_hotbar_itemcount = nil,
|
||||
hud_get_hotbar_itemcount = 8,
|
||||
hud_set_hotbar_image = nil,
|
||||
hud_get_hotbar_image = "",
|
||||
hud_set_hotbar_selected_image = nil,
|
||||
hud_get_hotbar_selected_image = "",
|
||||
set_sky = nil,
|
||||
get_sky = {},
|
||||
get_sky_color = {},
|
||||
set_sun = nil,
|
||||
get_sun = {},
|
||||
set_moon = nil,
|
||||
get_moon = {},
|
||||
set_stars = nil,
|
||||
get_stars = {},
|
||||
set_clouds = nil,
|
||||
get_clouds = {},
|
||||
override_day_night_ratio = nil,
|
||||
get_day_night_ratio = nil,
|
||||
set_local_animation = nil,
|
||||
get_local_animation = {},
|
||||
set_eye_offset = nil,
|
||||
get_eye_offset = {},
|
||||
send_mapblock = nil,
|
||||
}
|
||||
|
||||
techage.Fake_player = {}
|
||||
techage.Fake_player.__index = techage.Fake_player
|
||||
|
||||
function techage.Fake_player:new()
|
||||
local fake_player = {}
|
||||
setmetatable(fake_player, techage.Fake_player)
|
||||
return fake_player
|
||||
end
|
||||
|
||||
|
||||
for method_name, return_value in pairs(methods) do
|
||||
techage.Fake_player[method_name] = function(self, ...)
|
||||
return return_value
|
||||
end
|
||||
end
|
||||
|
@ -118,3 +118,34 @@ function techage.firebox.has_fuel(pos)
|
||||
local items = inv:get_stack("fuel", 1)
|
||||
return items:get_count() > 0
|
||||
end
|
||||
|
||||
function techage.firebox.is_free_position(pos, player_name)
|
||||
local pos2 = techage.get_pos(pos, 'F')
|
||||
if minetest.is_protected(pos2, player_name) then
|
||||
minetest.chat_send_player(player_name, S("[TA] Area is protected!"))
|
||||
return false
|
||||
end
|
||||
local node = techage.get_node_lvm(pos2)
|
||||
local ndef = minetest.registered_nodes[node.name]
|
||||
if not ndef or not ndef.buildable_to then
|
||||
minetest.chat_send_player(player_name, S("[TA] Not enough space!"))
|
||||
return false
|
||||
end
|
||||
return true
|
||||
end
|
||||
|
||||
function techage.firebox.set_firehole(pos, on)
|
||||
local param2 = techage.get_node_lvm(pos).param2
|
||||
local pos2 = techage.get_pos(pos, 'F')
|
||||
if on == true then
|
||||
minetest.swap_node(pos2, {name="techage:coalfirehole_on", param2 = param2})
|
||||
elseif on == false then
|
||||
minetest.swap_node(pos2, {name="techage:coalfirehole", param2 = param2})
|
||||
else
|
||||
local node = techage.get_node_lvm(pos2)
|
||||
if node.name == "techage:coalfirehole" or node.name == "techage:coalfirehole_on" then
|
||||
minetest.swap_node(pos2, {name="air"})
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
|
@ -140,7 +140,44 @@ function techage.can_node_dig(node, ndef)
|
||||
-- add it to the white list
|
||||
RegisteredNodesToBeDug[node.name] = true
|
||||
return true
|
||||
end
|
||||
end
|
||||
|
||||
techage.dig_states = {
|
||||
NOT_DIGGABLE = 1,
|
||||
INV_FULL = 2,
|
||||
DUG = 3
|
||||
}
|
||||
|
||||
-- Digs a node like a player would by utilizing a fake player object.
|
||||
-- add_to_inv(itemstacks) is a method that should try to add the dropped stacks to an appropriate inventory.
|
||||
-- The node will only be dug, if add_to_inv(itemstacks) returns true.
|
||||
function techage.dig_like_player(pos, fake_player, add_to_inv)
|
||||
local node = techage.get_node_lvm(pos)
|
||||
local ndef = minetest.registered_nodes[node.name]
|
||||
if not ndef or ndef.diggable == false or (ndef.can_dig and not ndef.can_dig(pos, fake_player)) then
|
||||
return techage.dig_states.NOT_DIGGABLE
|
||||
end
|
||||
local drop_as_strings = minetest.get_node_drops(node)
|
||||
local drop_as_stacks = {}
|
||||
for _,itemstring in ipairs(drop_as_strings) do
|
||||
drop_as_stacks[#drop_as_stacks+1] = ItemStack(itemstring)
|
||||
end
|
||||
local meta = M(pos)
|
||||
if ndef.preserve_metadata then
|
||||
ndef.preserve_metadata(pos, node, meta, drop_as_stacks)
|
||||
end
|
||||
|
||||
if add_to_inv(drop_as_stacks) then
|
||||
local oldmeta = meta:to_table()
|
||||
minetest.remove_node(pos)
|
||||
|
||||
if ndef.after_dig_node then
|
||||
ndef.after_dig_node(pos, node, oldmeta, fake_player)
|
||||
end
|
||||
return techage.dig_states.DUG
|
||||
end
|
||||
return techage.dig_states.INV_FULL
|
||||
end
|
||||
|
||||
local function handle_drop(drop)
|
||||
-- To keep it simple, return only the item with the lowest rarity
|
||||
|
@ -203,6 +203,10 @@ local function empty_on_punch(pos, nvm, full_container, item_count)
|
||||
end
|
||||
|
||||
function techage.liquid.on_punch(pos, node, puncher, pointed_thing)
|
||||
if minetest.is_protected(pos, puncher:get_player_name()) then
|
||||
return
|
||||
end
|
||||
|
||||
local nvm = techage.get_nvm(pos)
|
||||
local mem = techage.get_mem(pos)
|
||||
mem.blocking_time = mem.blocking_time or 0
|
||||
|
@ -90,7 +90,7 @@ minetest.register_node("techage:tubeS", {
|
||||
paramtype = "light",
|
||||
sunlight_propagates = true,
|
||||
is_ground_content = false,
|
||||
groups = {choppy=2, cracky=3, stone=1},
|
||||
groups = {choppy=2, cracky=3},
|
||||
sounds = default.node_sound_wood_defaults(),
|
||||
})
|
||||
|
||||
@ -130,7 +130,7 @@ minetest.register_node("techage:tubeA", {
|
||||
paramtype = "light",
|
||||
sunlight_propagates = true,
|
||||
is_ground_content = false,
|
||||
groups = {choppy=2, cracky=3, stone=1, not_in_creative_inventory=1},
|
||||
groups = {choppy=2, cracky=3, not_in_creative_inventory=1},
|
||||
sounds = default.node_sound_wood_defaults(),
|
||||
drop = "techage:tubeS",
|
||||
})
|
||||
|
@ -57,7 +57,7 @@ minetest.register_node("techage:ta4_tubeS", {
|
||||
paramtype = "light",
|
||||
sunlight_propagates = true,
|
||||
is_ground_content = false,
|
||||
groups = {choppy=2, cracky=3, stone=1},
|
||||
groups = {choppy=2, cracky=3},
|
||||
sounds = default.node_sound_wood_defaults(),
|
||||
})
|
||||
|
||||
@ -97,7 +97,7 @@ minetest.register_node("techage:ta4_tubeA", {
|
||||
paramtype = "light",
|
||||
sunlight_propagates = true,
|
||||
is_ground_content = false,
|
||||
groups = {choppy=2, cracky=3, stone=1, not_in_creative_inventory=1},
|
||||
groups = {choppy=2, cracky=3, not_in_creative_inventory=1},
|
||||
sounds = default.node_sound_wood_defaults(),
|
||||
drop = "techage:ta4_tubeS",
|
||||
})
|
||||
|
@ -22,18 +22,6 @@ local firebox = techage.firebox
|
||||
local CYCLE_TIME = 2
|
||||
local BURN_CYCLE_FACTOR = 0.5
|
||||
|
||||
local function firehole(pos, on)
|
||||
local param2 = techage.get_node_lvm(pos).param2
|
||||
local pos2 = techage.get_pos(pos, 'F')
|
||||
if on == true then
|
||||
minetest.swap_node(pos2, {name="techage:coalfirehole_on", param2 = param2})
|
||||
elseif on == false then
|
||||
minetest.swap_node(pos2, {name="techage:coalfirehole", param2 = param2})
|
||||
else
|
||||
minetest.swap_node(pos2, {name="air"})
|
||||
end
|
||||
end
|
||||
|
||||
local function node_timer(pos, elapsed)
|
||||
local nvm = techage.get_nvm(pos)
|
||||
local power = techage.transfer(
|
||||
@ -52,7 +40,7 @@ local function node_timer(pos, elapsed)
|
||||
nvm.burn_cycles_total = nvm.burn_cycles
|
||||
else
|
||||
nvm.running = false
|
||||
firehole(pos, false)
|
||||
firebox.set_firehole(pos, false)
|
||||
M(pos):set_string("formspec", firebox.formspec(nvm))
|
||||
return false
|
||||
end
|
||||
@ -67,7 +55,7 @@ local function start_firebox(pos, nvm)
|
||||
if not nvm.running then
|
||||
nvm.running = true
|
||||
node_timer(pos, 0)
|
||||
firehole(pos, true)
|
||||
firebox.set_firehole(pos, true)
|
||||
minetest.get_node_timer(pos):start(CYCLE_TIME)
|
||||
end
|
||||
end
|
||||
@ -96,20 +84,25 @@ minetest.register_node("techage:coalfirebox", {
|
||||
allow_metadata_inventory_take = firebox.allow_metadata_inventory_take,
|
||||
on_rightclick = firebox.on_rightclick,
|
||||
|
||||
on_construct = function(pos)
|
||||
techage.add_node(pos, "techage:coalfirebox")
|
||||
local nvm = techage.get_nvm(pos)
|
||||
nvm.running = false
|
||||
nvm.burn_cycles = 0
|
||||
local meta = M(pos)
|
||||
meta:set_string("formspec", firebox.formspec(nvm))
|
||||
local inv = meta:get_inventory()
|
||||
inv:set_size('fuel', 1)
|
||||
firehole(pos, false)
|
||||
after_place_node = function(pos, placer)
|
||||
if firebox.is_free_position(pos, placer:get_player_name()) then
|
||||
techage.add_node(pos, "techage:coalfirebox")
|
||||
local nvm = techage.get_nvm(pos)
|
||||
nvm.running = false
|
||||
nvm.burn_cycles = 0
|
||||
local meta = M(pos)
|
||||
meta:set_string("formspec", firebox.formspec(nvm))
|
||||
local inv = meta:get_inventory()
|
||||
inv:set_size('fuel', 1)
|
||||
firebox.set_firehole(pos, false)
|
||||
else
|
||||
minetest.remove_node(pos)
|
||||
return true
|
||||
end
|
||||
end,
|
||||
|
||||
on_destruct = function(pos)
|
||||
firehole(pos, nil)
|
||||
firebox.set_firehole(pos, nil)
|
||||
end,
|
||||
|
||||
on_metadata_inventory_put = function(pos, listname, index, stack, player)
|
||||
|
@ -25,18 +25,6 @@ local liquid = techage.liquid
|
||||
local CYCLE_TIME = 2
|
||||
local BURN_CYCLE_FACTOR = 0.5
|
||||
|
||||
local function firehole(pos, on)
|
||||
local param2 = techage.get_node_lvm(pos).param2
|
||||
local pos2 = techage.get_pos(pos, 'F')
|
||||
if on == true then
|
||||
minetest.swap_node(pos2, {name="techage:coalfirehole_on", param2 = param2})
|
||||
elseif on == false then
|
||||
minetest.swap_node(pos2, {name="techage:coalfirehole", param2 = param2})
|
||||
else
|
||||
minetest.swap_node(pos2, {name="air"})
|
||||
end
|
||||
end
|
||||
|
||||
local function node_timer(pos, elapsed)
|
||||
local nvm = techage.get_nvm(pos)
|
||||
local power = techage.transfer(
|
||||
@ -55,7 +43,7 @@ local function node_timer(pos, elapsed)
|
||||
nvm.burn_cycles_total = nvm.burn_cycles
|
||||
else
|
||||
nvm.running = false
|
||||
firehole(pos, false)
|
||||
firebox.set_firehole(pos, false)
|
||||
M(pos):set_string("formspec", fuel.formspec(nvm))
|
||||
return false
|
||||
end
|
||||
@ -70,7 +58,7 @@ local function start_firebox(pos, nvm)
|
||||
if not nvm.running and fuel.has_fuel(nvm) then
|
||||
nvm.running = true
|
||||
node_timer(pos, 0)
|
||||
firehole(pos, true)
|
||||
firebox.set_firehole(pos, true)
|
||||
minetest.get_node_timer(pos):start(CYCLE_TIME)
|
||||
end
|
||||
end
|
||||
@ -98,21 +86,26 @@ minetest.register_node("techage:oilfirebox", {
|
||||
on_rightclick = fuel.on_rightclick,
|
||||
on_receive_fields = fuel.on_receive_fields,
|
||||
|
||||
on_construct = function(pos)
|
||||
techage.add_node(pos, "techage:oilfirebox")
|
||||
local nvm = techage.get_nvm(pos)
|
||||
nvm.running = false
|
||||
nvm.burn_cycles = 0
|
||||
nvm.liquid = {}
|
||||
nvm.liquid.amount = 0
|
||||
local meta = M(pos)
|
||||
meta:set_string("formspec", fuel.formspec(nvm))
|
||||
local inv = meta:get_inventory()
|
||||
firehole(pos, false)
|
||||
after_place_node = function(pos, placer)
|
||||
if firebox.is_free_position(pos, placer:get_player_name()) then
|
||||
techage.add_node(pos, "techage:oilfirebox")
|
||||
local nvm = techage.get_nvm(pos)
|
||||
nvm.running = false
|
||||
nvm.burn_cycles = 0
|
||||
nvm.liquid = {}
|
||||
nvm.liquid.amount = 0
|
||||
local meta = M(pos)
|
||||
meta:set_string("formspec", fuel.formspec(nvm))
|
||||
local inv = meta:get_inventory()
|
||||
firebox.set_firehole(pos, false)
|
||||
else
|
||||
minetest.remove_node(pos)
|
||||
return true
|
||||
end
|
||||
end,
|
||||
|
||||
|
||||
on_destruct = function(pos)
|
||||
firehole(pos, nil)
|
||||
firebox.set_firehole(pos, nil)
|
||||
end,
|
||||
|
||||
on_punch = function(pos, node, puncher, pointed_thing)
|
||||
|
@ -140,27 +140,21 @@ techage.register_consumer("digtron_battery", S("Digtron Battery"), { act = tiles
|
||||
end
|
||||
end
|
||||
end,
|
||||
after_dig_node = function(pos, oldnode, oldmetadata, digger)
|
||||
local node = ItemStack(oldnode.name)
|
||||
if oldmetadata.inventory then
|
||||
local total = count_coal(oldmetadata)
|
||||
local meta = node:get_meta()
|
||||
preserve_metadata = function(pos, oldnode, oldmetadata, drops)
|
||||
local metadata = M(pos):to_table()
|
||||
if metadata.inventory then
|
||||
local total = count_coal(metadata)
|
||||
local meta = drops[1]:get_meta()
|
||||
meta:set_int("coal", total)
|
||||
local text = S("Digtron Battery").." ("..math.floor(total/TOTAL_MAX * 100).." %)"
|
||||
meta:set_string("description", text)
|
||||
end
|
||||
local inv = minetest.get_inventory({type="player", name=digger:get_player_name()})
|
||||
local left_over = inv:add_item("main", node)
|
||||
if left_over:get_count() > 0 then
|
||||
minetest.add_item(pos, node)
|
||||
end
|
||||
end,
|
||||
on_rightclick = function(pos, node, clicker)
|
||||
techage.set_activeformspec(pos, clicker)
|
||||
local nvm = techage.get_nvm(pos)
|
||||
M(pos):set_string("formspec", formspec(CRD(pos).State, pos, nvm))
|
||||
end,
|
||||
drop = "",
|
||||
node_timer = keep_running,
|
||||
on_receive_fields = on_receive_fields,
|
||||
allow_metadata_inventory_put = allow_metadata_inventory_put,
|
||||
|
@ -1340,7 +1340,16 @@ techage.manual_DE.aText = {
|
||||
"\n"..
|
||||
"\n"..
|
||||
"\n",
|
||||
"Die TA4 Sensor Kiste dient zum Aufbau von Automatischen Lagern oder Verkaufsautomaten. Sie hat erweitere Kommandos zur Fernsteuerung.\n"..
|
||||
"Die TA4 Sensor Kiste dient zum Aufbau von Automatischen Lagern oder Verkaufsautomaten in Verbindung mit dem Lua Controller.\n"..
|
||||
"Wird etwas in die Kiste gelegt\\, oder entnommen\\, oder eine der Tasten \"F1\"/\"F2\" gedrückt\\, so wird ein Event-Signal an den Lua Controller gesendet.\n"..
|
||||
"Die Sensor Kiste unterstützt folgende Kommandos:\n"..
|
||||
"\n"..
|
||||
" - Über 'state = $read_data(<num>\\, \"state\")' kann der Status der Kiste abgefragt werden. Mögliche Antworten sind: \"empty\"\\, \"loaded\"\\, \"full\"\n"..
|
||||
" - Über 'name\\, action = $read_data(<num>\\, \"action\")' kann die letzte Spieleraktion abgefragt werden. 'name' ist der Spielername\\, Als 'action' wird zurückgeliefert: \"put\"\\, \"take\"\\, \"f1\"\\, \"f2\".\n"..
|
||||
" - Über 'stacks = $read_data(<num>\\, \"stacks\")' kann der Inhalt der Kiste ausgelesen werden. Siehe dazu: https://github.com/joe7575/techage/blob/master/manuals/ta4_lua_controller_EN.md#sensor-chest\n"..
|
||||
" - Über '$send_cmnd(<num>\\, \"text\"\\, \"press both buttons andnput something into the chest\")' kann der Text im Menü der Sensor Kiste gesetzt werden.\n"..
|
||||
"\n"..
|
||||
"Über die Checkbox \"Erlaube öffentlichen Zugriff\" kann eingestellt werden\\, ob die Kiste von jedem genutzt werden darf\\, oder nur von Spielern die hier Zugriffsrechte haben.\n"..
|
||||
"\n"..
|
||||
"\n"..
|
||||
"\n",
|
||||
|
@ -1331,7 +1331,16 @@ techage.manual_EN.aText = {
|
||||
"\n"..
|
||||
"\n"..
|
||||
"\n",
|
||||
"The TA4 sensor box is used to set up automatic warehouses or vending machines. It has additional commands for remote control.\n"..
|
||||
"The TA4 sensor box is used to set up automatic warehouses or vending machines in conjunction with the Lua controller.\n"..
|
||||
"If something is put into the box or removed\\, or one of the \"F1\" / \"F2\" keys is pressed\\, an event signal is sent to the Lua controller.\n"..
|
||||
"The sensor box supports the following commands:\n"..
|
||||
"\n"..
|
||||
" - The status of the box can be queried via 'state = $read_data(<num>\\, \"state\")'. Possible answers are: \"empty\"\\, \"loaded\"\\, \"full\"\n"..
|
||||
" - The last player action can be queried via 'name\\, action = $read_data(<num>\\, \"action\")'. 'name' is the player name. One of the following is returned as 'action': \"put\"\\, \"take\"\\, \"f1\"\\, \"f2\".\n"..
|
||||
" - The contents of the box can be read out via 'stacks = $read_data(<num>\\, \"stacks\")'. See: https://github.com/joe7575/techage/blob/master/manuals/ta4_lua_controller_EN.md#sensor-chest\n"..
|
||||
" - Via '$send_cmnd(<num>\\, \"text\"\\, \"press both buttons andnput something into the chest\")' the text can be set in the menu of the sensor box.\n"..
|
||||
"\n"..
|
||||
"The checkbox \"Allow public chest access\" can be used to set whether the box can be used by everyone or only by players who have access/protection rights here.\n"..
|
||||
"\n"..
|
||||
"\n"..
|
||||
"\n",
|
||||
@ -1417,8 +1426,8 @@ techage.manual_EN.aText = {
|
||||
"\n"..
|
||||
"The TA4 pusher has two additional commands for the Lua controller:\n"..
|
||||
"\n"..
|
||||
" - 'config' is used to configure the pusher\\, analogous to manual configuration via the menu.\nExample: '$ send_cmnd(1234\\, \"config\"\\, \"default: dirt\")'\n"..
|
||||
" - 'pull' is used to send an order to the pusher:\nExample: '$ send_cmnd(1234\\, \"pull\"\\, \"default: dirt 8\")'\nValues from 1 to 12 are permitted as numbers. Then the pusher goes back to 'stopped' mode and sends an\" off \"command back to the transmitter of the\" pull \"command.\n"..
|
||||
" - 'config' is used to configure the pusher\\, analogous to manual configuration via the menu.\nExample: '$send_cmnd(1234\\, \"config\"\\, \"default: dirt\")'\n"..
|
||||
" - 'pull' is used to send an order to the pusher:\nExample: '$send_cmnd(1234\\, \"pull\"\\, \"default: dirt 8\")'\nValues from 1 to 12 are permitted as numbers. Then the pusher goes back to 'stopped' mode and sends an\" off \"command back to the transmitter of the\" pull \"command.\n"..
|
||||
"\n"..
|
||||
"\n"..
|
||||
"\n",
|
||||
@ -1449,7 +1458,7 @@ techage.manual_EN.aText = {
|
||||
"\n"..
|
||||
"The chest has an additional command for the Lua controller:\n"..
|
||||
"\n"..
|
||||
" - 'count' is used to request how many items are in the chest.\nExample 1: '$ read_data(CHEST\\, \"count\")' -> Sum of items across all 8 stores\nExample 2: '$ read_data(CHEST\\, \"count\"\\, 2)' -> number of items in store 2 (second from left)\n"..
|
||||
" - 'count' is used to request how many items are in the chest.\nExample 1: '$read_data(CHEST\\, \"count\")' -> Sum of items across all 8 stores\nExample 2: '$read_data(CHEST\\, \"count\"\\, 2)' -> number of items in store 2 (second from left)\n"..
|
||||
"\n"..
|
||||
"\n"..
|
||||
"\n",
|
||||
|
@ -15,7 +15,6 @@
|
||||
-- for lazy programmers
|
||||
local M = minetest.get_meta
|
||||
local S = techage.S
|
||||
local logic = techage.logic
|
||||
local BATTERY_CAPACITY = 10000000
|
||||
|
||||
local function calc_percent(content)
|
||||
@ -36,73 +35,69 @@ local function on_timer(pos, elapsed)
|
||||
return true
|
||||
end
|
||||
|
||||
local function register_battery(ext, percent, nici)
|
||||
minetest.register_node("techage:ta4_battery"..ext, {
|
||||
description = S("Battery").." "..ext,
|
||||
inventory_image = 'techage_battery_inventory.png',
|
||||
wield_image = 'techage_battery_inventory.png',
|
||||
tiles = {
|
||||
-- up, down, right, left, back, front
|
||||
"techage_smartline.png",
|
||||
"techage_smartline.png",
|
||||
"techage_smartline.png",
|
||||
"techage_smartline.png",
|
||||
"techage_smartline.png",
|
||||
"techage_smartline.png^techage_battery_green.png",
|
||||
},
|
||||
minetest.register_alias("techage:ta4_battery75", "techage:ta4_battery")
|
||||
minetest.register_alias("techage:ta4_battery50", "techage:ta4_battery")
|
||||
minetest.register_alias("techage:ta4_battery25", "techage:ta4_battery")
|
||||
|
||||
drawtype = "nodebox",
|
||||
node_box = {
|
||||
type = "fixed",
|
||||
fixed = {
|
||||
{ -6/32, -6/32, 14/32, 6/32, 6/32, 16/32},
|
||||
},
|
||||
minetest.register_node("techage:ta4_battery", {
|
||||
description = S("Battery"),
|
||||
inventory_image = 'techage_battery_inventory.png',
|
||||
wield_image = 'techage_battery_inventory.png',
|
||||
tiles = {
|
||||
-- up, down, right, left, back, front
|
||||
"techage_smartline.png",
|
||||
"techage_smartline.png",
|
||||
"techage_smartline.png",
|
||||
"techage_smartline.png",
|
||||
"techage_smartline.png",
|
||||
"techage_smartline.png^techage_battery_green.png",
|
||||
},
|
||||
|
||||
drawtype = "nodebox",
|
||||
node_box = {
|
||||
type = "fixed",
|
||||
fixed = {
|
||||
{ -6/32, -6/32, 14/32, 6/32, 6/32, 16/32},
|
||||
},
|
||||
|
||||
after_place_node = function(pos, placer)
|
||||
local meta = minetest.get_meta(pos)
|
||||
meta:set_int("content", BATTERY_CAPACITY * percent)
|
||||
local node = minetest.get_node(pos)
|
||||
node.name = "techage:ta4_battery"
|
||||
minetest.swap_node(pos, node)
|
||||
on_timer(pos, 1)
|
||||
minetest.get_node_timer(pos):start(30)
|
||||
end,
|
||||
|
||||
on_timer = on_timer,
|
||||
|
||||
after_dig_node = function(pos, oldnode, oldmetadata, digger)
|
||||
local percent = calc_percent(tonumber(oldmetadata.fields.content))
|
||||
local stack
|
||||
if percent > 95 then
|
||||
stack = ItemStack("techage:ta4_battery")
|
||||
elseif percent > 75 then
|
||||
stack = ItemStack("techage:ta4_battery75")
|
||||
elseif percent > 50 then
|
||||
stack = ItemStack("techage:ta4_battery50")
|
||||
elseif percent > 25 then
|
||||
stack = ItemStack("techage:ta4_battery25")
|
||||
else
|
||||
return
|
||||
},
|
||||
|
||||
after_place_node = function(pos, placer, itemstack)
|
||||
local content = BATTERY_CAPACITY
|
||||
if itemstack then
|
||||
local stack_meta = itemstack:get_meta()
|
||||
if stack_meta then
|
||||
-- This ensures that dug batteries of the old system are considered full.
|
||||
local string_content = stack_meta:get_string("content")
|
||||
if string_content ~= "" then
|
||||
-- Batteries dug in the new system are handled correctly.
|
||||
content = techage.in_range(stack_meta:get_int("content"), 0, BATTERY_CAPACITY)
|
||||
end
|
||||
end
|
||||
local inv = minetest.get_inventory({type="player", name=digger:get_player_name()})
|
||||
inv:add_item("main", stack)
|
||||
end,
|
||||
end
|
||||
M(pos):set_int("content", content)
|
||||
on_timer(pos, 1)
|
||||
minetest.get_node_timer(pos):start(30)
|
||||
end,
|
||||
|
||||
paramtype = "light",
|
||||
sunlight_propagates = true,
|
||||
paramtype2 = "facedir",
|
||||
groups = {choppy=1, cracky=1, crumbly=1, not_in_creative_inventory=nici},
|
||||
drop = "",
|
||||
is_ground_content = false,
|
||||
sounds = default.node_sound_stone_defaults(),
|
||||
})
|
||||
end
|
||||
on_timer = on_timer,
|
||||
|
||||
register_battery("", 1.0, 0)
|
||||
register_battery("75", 0.75, 1)
|
||||
register_battery("50", 0.5, 1)
|
||||
register_battery("25", 0.25, 1)
|
||||
preserve_metadata = function(pos, oldnode, oldmetadata, drops)
|
||||
local content = M(pos):get_int("content")
|
||||
|
||||
local meta = drops[1]:get_meta()
|
||||
meta:set_int("content", content)
|
||||
local percent = calc_percent(content)
|
||||
local text = S("Digtron Battery").." ("..percent.." %)"
|
||||
meta:set_string("description", text)
|
||||
end,
|
||||
|
||||
paramtype = "light",
|
||||
sunlight_propagates = true,
|
||||
paramtype2 = "facedir",
|
||||
groups = {choppy=1, cracky=1, crumbly=1},
|
||||
is_ground_content = false,
|
||||
sounds = default.node_sound_stone_defaults(),
|
||||
})
|
||||
|
||||
minetest.register_node("techage:ta4_battery_empty", {
|
||||
description = S("Battery"),
|
||||
@ -159,8 +154,7 @@ else
|
||||
})
|
||||
end
|
||||
|
||||
techage.register_node({"techage:ta4_battery", "techage:ta4_battery25",
|
||||
"techage:ta4_battery50", "techage:ta4_battery75"},
|
||||
techage.register_node({"techage:ta4_battery"},
|
||||
{
|
||||
on_node_load = function(pos)
|
||||
minetest.get_node_timer(pos):start(30)
|
||||
|
@ -13,7 +13,7 @@
|
||||
techage = {}
|
||||
|
||||
-- Version for compatibility checks, see readme.md/history
|
||||
techage.version = 0.21
|
||||
techage.version = 0.23
|
||||
|
||||
if minetest.global_exists("tubelib") then
|
||||
minetest.log("error", "[techage] Techage can't be used together with the mod tubelib!")
|
||||
@ -66,6 +66,7 @@ end
|
||||
-- Basis features
|
||||
local MP = minetest.get_modpath("techage")
|
||||
dofile(MP.."/basis/lib.lua") -- helper functions
|
||||
dofile(MP.."/basis/fake_player.lua") -- dummy player object
|
||||
dofile(MP.."/basis/node_store.lua")
|
||||
dofile(MP.."/basis/gravel_lib.lua") -- ore probability
|
||||
dofile(MP.."/basis/node_states.lua") -- state model
|
||||
@ -144,6 +145,7 @@ dofile(MP.."/basic_machines/consumer.lua") -- consumer base model
|
||||
dofile(MP.."/basic_machines/source.lua")
|
||||
dofile(MP.."/basic_machines/pusher.lua")
|
||||
dofile(MP.."/basic_machines/legacy_nodes.lua")
|
||||
dofile(MP.."/basic_machines/mods_support.lua")
|
||||
dofile(MP.."/basic_machines/grinder.lua")
|
||||
dofile(MP.."/basic_machines/distributor.lua")
|
||||
dofile(MP.."/basic_machines/gravelsieve.lua")
|
||||
|
@ -17,6 +17,7 @@ local S = techage.S
|
||||
minetest.register_craftitem("techage:hydrogen", {
|
||||
description = S("TA4 Hydrogen"),
|
||||
inventory_image = "techage_hydrogen_inv.png",
|
||||
groups = {ta_liquid = 1},
|
||||
})
|
||||
|
||||
minetest.register_craftitem("techage:cylinder_small_hydrogen", {
|
||||
|
@ -17,6 +17,7 @@ local S = techage.S
|
||||
minetest.register_craftitem("techage:lye", {
|
||||
description = S("Lye"),
|
||||
inventory_image = "techage_liquid2_inv.png^[colorize:#7fd44c:120^techage_liquid1_inv.png",
|
||||
groups = {ta_liquid = 1},
|
||||
})
|
||||
|
||||
minetest.register_craftitem("techage:barrel_lye", {
|
||||
|
@ -58,7 +58,7 @@ minetest.register_node("techage:oil_source", {
|
||||
liquid_range = 10,
|
||||
liquid_renewable = false,
|
||||
post_effect_color = {a = 200, r = 1, g = 1, b = 1},
|
||||
groups = {liquid = 5},
|
||||
groups = {liquid = 5, ta_liquid = 1},
|
||||
})
|
||||
|
||||
minetest.register_node("techage:oil_flowing", {
|
||||
|
@ -18,26 +18,31 @@ local S = techage.S
|
||||
minetest.register_craftitem("techage:bitumen", {
|
||||
description = S("TA3 Bitumen"),
|
||||
inventory_image = "techage_liquid2_inv.png^[colorize:#000000",
|
||||
groups = {ta_liquid = 1},
|
||||
})
|
||||
|
||||
minetest.register_craftitem("techage:fueloil", {
|
||||
description = S("TA3 Fuel Oil"),
|
||||
inventory_image = "techage_liquid2_inv.png^[colorize:#7E5D0A:180^techage_liquid1_inv.png",
|
||||
groups = {ta_liquid = 1},
|
||||
})
|
||||
|
||||
minetest.register_craftitem("techage:naphtha", {
|
||||
description = S("TA3 Naphtha"),
|
||||
inventory_image = "techage_liquid2_inv.png^[colorize:#AAA820:180^techage_liquid1_inv.png",
|
||||
groups = {ta_liquid = 1},
|
||||
})
|
||||
|
||||
minetest.register_craftitem("techage:gasoline", {
|
||||
description = S("TA3 Gasoline"),
|
||||
inventory_image = "techage_liquid2_inv.png^[colorize:#EEFC52:180^techage_liquid1_inv.png",
|
||||
groups = {ta_liquid = 1},
|
||||
})
|
||||
|
||||
minetest.register_craftitem("techage:gas", {
|
||||
description = S("TA3 Propane"),
|
||||
inventory_image = "techage_gas_inv.png",
|
||||
groups = {ta_liquid = 1},
|
||||
})
|
||||
|
||||
minetest.register_craftitem("techage:ta3_cylinder_small_gas", {
|
||||
|
@ -138,10 +138,11 @@ function techage.register_plant(name)
|
||||
end
|
||||
|
||||
minetest.after(1, function()
|
||||
for name,_ in pairs(minetest.registered_decorations) do
|
||||
if type(name) == "string" then
|
||||
for _,def in pairs(minetest.registered_decorations) do
|
||||
local name = def.decoration
|
||||
if name and type(name) == "string" then
|
||||
local mod = string.split(name, ":")[1]
|
||||
if mod == "flowers" then
|
||||
if mod == "flowers" or mod == "bakedclay" then -- Bakedclay also registers flowers as decoration.
|
||||
techage.register_flower(name)
|
||||
end
|
||||
end
|
||||
@ -149,12 +150,8 @@ minetest.after(1, function()
|
||||
for name,ndef in pairs(minetest.registered_nodes) do
|
||||
if type(name) == "string" then
|
||||
local mod = string.split(name, ":")[1]
|
||||
if mod == "farming" then
|
||||
if ndef.on_timer then -- probably a plant that still needs to grow
|
||||
techage.register_plant(name)
|
||||
end
|
||||
elseif mod == "flowers" then
|
||||
techage.register_flower(name)
|
||||
if mod == "farming" and ndef.on_timer then -- probably a plant that still needs to grow
|
||||
techage.register_plant(name)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
@ -162,6 +162,17 @@ function liquid.take(pos, outdir, name, amount, player_name)
|
||||
return taken, item_name
|
||||
end
|
||||
|
||||
function liquid.untake(pos, outdir, name, amount, player_name)
|
||||
for _,item in ipairs(get_network_table(pos, outdir, "tank")) do
|
||||
local liquid = LQD(item.pos)
|
||||
if liquid and liquid.untake then
|
||||
amount = liquid.untake(item.pos, item.indir, name, amount)
|
||||
if not amount or amount == 0 then break end
|
||||
end
|
||||
end
|
||||
return amount or 0
|
||||
end
|
||||
|
||||
--
|
||||
-- Server local functions
|
||||
--
|
||||
|
@ -70,7 +70,7 @@ local function pumping(pos, nvm, state, capa)
|
||||
if taken > 0 then
|
||||
local leftover = liquid.put(pos, outdir, name, taken, starter)
|
||||
if leftover and leftover == taken then
|
||||
liquid.put(pos, Flip[outdir], name, leftover)
|
||||
liquid.untake(pos, Flip[outdir], name, leftover)
|
||||
state:blocked(pos, nvm)
|
||||
return
|
||||
end
|
||||
|
@ -26,9 +26,10 @@ local function allow_metadata_inventory_put(pos, listname, index, stack, player)
|
||||
if minetest.is_protected(pos, player:get_player_name()) then
|
||||
return 0
|
||||
end
|
||||
-- check if it is powder
|
||||
local ndef = minetest.registered_craftitems[stack:get_name()] or {}
|
||||
if ndef.groups and ndef.groups.powder == 1 then
|
||||
-- check if it is powder or techage liquid item (migration function)
|
||||
local ndef = minetest.registered_craftitems[stack:get_name()] or
|
||||
minetest.registered_items[stack:get_name()] or {}
|
||||
if ndef.groups and (ndef.groups.powder == 1 or ndef.groups.ta_liquid == 1) then
|
||||
local nvm = techage.get_nvm(pos)
|
||||
nvm.item_name = nil
|
||||
local inv = minetest.get_meta(pos):get_inventory()
|
||||
@ -125,6 +126,15 @@ local tLiquid = {
|
||||
end
|
||||
return 0
|
||||
end,
|
||||
untake = function(pos, indir, name, amount)
|
||||
local inv = M(pos):get_inventory()
|
||||
local stack = ItemStack(name.." "..amount)
|
||||
if inv:room_for_item("main", stack) then
|
||||
inv:add_item("main", stack)
|
||||
return 0
|
||||
end
|
||||
return amount
|
||||
end,
|
||||
}
|
||||
|
||||
local tNetworks = {
|
||||
|
@ -67,6 +67,15 @@ local function put_liquid(pos, indir, name, amount)
|
||||
return amount
|
||||
end
|
||||
|
||||
local function untake_liquid(pos, indir, name, amount)
|
||||
local leftover = liquid.srv_put(pos, indir, name, amount)
|
||||
if techage.is_activeformspec(pos) then
|
||||
local nvm = techage.get_nvm(pos)
|
||||
M(pos):set_string("formspec", liquid.formspec(pos, nvm))
|
||||
end
|
||||
return leftover
|
||||
end
|
||||
|
||||
local networks_def = {
|
||||
pipe2 = {
|
||||
sides = techage.networks.AllSides, -- Pipe connection sides
|
||||
@ -110,6 +119,7 @@ minetest.register_node("techage:ta3_tank", {
|
||||
peek = liquid.srv_peek,
|
||||
put = put_liquid,
|
||||
take = take_liquid,
|
||||
untake = untake_liquid,
|
||||
},
|
||||
networks = networks_def,
|
||||
on_rightclick = on_rightclick,
|
||||
@ -168,6 +178,7 @@ minetest.register_node("techage:oiltank", {
|
||||
peek = liquid.srv_peek,
|
||||
put = put_liquid,
|
||||
take = take_liquid,
|
||||
untake = untake_liquid,
|
||||
},
|
||||
networks = networks_def,
|
||||
on_rightclick = on_rightclick,
|
||||
@ -216,6 +227,7 @@ minetest.register_node("techage:ta4_tank", {
|
||||
peek = liquid.srv_peek,
|
||||
put = put_liquid,
|
||||
take = take_liquid,
|
||||
untake = untake_liquid,
|
||||
},
|
||||
networks = networks_def,
|
||||
on_rightclick = on_rightclick,
|
||||
|
@ -1,10 +1,10 @@
|
||||
# textdomain: techage
|
||||
|
||||
ku is needed!)= ku wird benötigt!)
|
||||
#### TA3 Terminal ####@n@nSend commands to your machines@nand output text messages from your@nmachines to the Terminal.@n@nCommand syntax:@n cmd <num> <cmnd>@n@nexample: cmd 181 on@n<num> is the number of the node to which the command is sent@n'on' is the command to turn machines/nodes on@nFurther commands can be retrieved by clicking on@nmachines/nodes with the Techage Info Tool.@n@nLocal commands:@n- clear @= clear screen@n- help @= this message@n- pub @= switch to public use@n- priv @= switch to private use@nTo program a user button with a command:@n set <button-num> <button-text> <command>@ne.g. 'set 1 ON cmd 123 on'@n=
|
||||
Accu Box=Akkublock
|
||||
Active:=Aktiv:
|
||||
All nodes:=Alle Blöcke:
|
||||
Allow public chest access=Erlaube öffentlichen Zugriff
|
||||
Allow to dig/place Techage power lines nearby power poles=Erlaubt TODO
|
||||
Aluminum=Aluminium
|
||||
Area already loaded or max. number of Forceload Blocks reached!=Bereich bereits geladen oder maximale Anzahl von Forceload Blöcken erreicht!
|
||||
@ -429,6 +429,7 @@ inlet/pipe error=Einlass/Röhrenfehler
|
||||
inventory full=Inventar ist voll
|
||||
item output blocked=Ausgang blockiert
|
||||
keep assignment=Zuordnung beibehalten
|
||||
ku is needed=ku wird benötigt
|
||||
light=Licht
|
||||
loaded=geladen
|
||||
needs power=benötigt Strom
|
||||
@ -453,3 +454,4 @@ water temperature=Wassertemperatur
|
||||
wrong catalyst=falscher Katalysator
|
||||
wrong storage diameter=Falscher Wärmespeicher-Durchmesser
|
||||
##### not used anymore #####
|
||||
|
||||
|
@ -1,8 +1,8 @@
|
||||
ku is needed!)=
|
||||
#### TA3 Terminal ####@n@nSend commands to your machines@nand output text messages from your@nmachines to the Terminal.@n@nCommand syntax:@n cmd <num> <cmnd>@n@nexample: cmd 181 on@n<num> is the number of the node to which the command is sent@n'on' is the command to turn machines/nodes on@nFurther commands can be retrieved by clicking on@nmachines/nodes with the Techage Info Tool.@n@nLocal commands:@n- clear @= clear screen@n- help @= this message@n- pub @= switch to public use@n- priv @= switch to private use@nTo program a user button with a command:@n set <button-num> <button-text> <command>@ne.g. 'set 1 ON cmd 123 on'@n=
|
||||
Accu Box=
|
||||
Active:=
|
||||
All nodes:=
|
||||
Allow public chest access=
|
||||
Allow to dig/place Techage power lines nearby power poles=
|
||||
Aluminum=
|
||||
Area already loaded or max. number of Forceload Blocks reached!=
|
||||
@ -427,6 +427,7 @@ inlet/pipe error=
|
||||
inventory full=
|
||||
item output blocked=
|
||||
keep assignment=
|
||||
ku is needed=
|
||||
light=
|
||||
loaded=
|
||||
needs power=
|
||||
|
@ -120,10 +120,18 @@ techage.lua_ctlr.register_function("get_ms_time", {
|
||||
cmnd = function(self)
|
||||
return math.floor(minetest.get_us_time() / 1000)
|
||||
end,
|
||||
help = "$get_ms_time()\n"..
|
||||
help = " ms = $get_ms_time()\n"..
|
||||
" returns time with millisecond precision."
|
||||
})
|
||||
|
||||
techage.lua_ctlr.register_function("get_gametime", {
|
||||
cmnd = function(self)
|
||||
return minetest.get_gametime()
|
||||
end,
|
||||
help = " t = $get_gametime()\n"..
|
||||
" returns the time, in seconds, since the world was created."
|
||||
})
|
||||
|
||||
techage.lua_ctlr.register_function("position", {
|
||||
cmnd = function(self, number)
|
||||
local info = techage.get_node_info(number)
|
||||
@ -132,7 +140,7 @@ techage.lua_ctlr.register_function("position", {
|
||||
end
|
||||
return "(-,-,-)"
|
||||
end,
|
||||
help = "$position(number)\n"..
|
||||
help = " pos = $position(number)\n"..
|
||||
" returns the position '(x,y,z)' of the device\n with given number."
|
||||
})
|
||||
|
||||
@ -144,7 +152,7 @@ techage.lua_ctlr.register_action("battery", {
|
||||
local val = (BATTERY_CAPA - math.min(batmeta:get_int("content") or 0, BATTERY_CAPA))
|
||||
return 100 - math.floor((val * 100.0 / BATTERY_CAPA))
|
||||
end,
|
||||
help = " $battery()\n"..
|
||||
help = " lvl = $battery()\n"..
|
||||
" Get charge level of battery connected to Controller.\n"..
|
||||
" Function returns percent number (0-100) where 100 means full.\n"..
|
||||
" example: battery_percent = $battery()"
|
||||
|
@ -63,7 +63,7 @@ local function get_stacks(pos)
|
||||
end
|
||||
|
||||
local function allow_metadata_inventory_put(pos, listname, index, stack, player)
|
||||
if minetest.is_protected(pos, player:get_player_name()) then
|
||||
if M(pos):get_string("public") ~= "true" and minetest.is_protected(pos, player:get_player_name()) then
|
||||
return 0
|
||||
end
|
||||
store_action(pos, player, "put")
|
||||
@ -72,7 +72,7 @@ local function allow_metadata_inventory_put(pos, listname, index, stack, player)
|
||||
end
|
||||
|
||||
local function allow_metadata_inventory_take(pos, listname, index, stack, player)
|
||||
if minetest.is_protected(pos, player:get_player_name()) then
|
||||
if M(pos):get_string("public") ~= "true" and minetest.is_protected(pos, player:get_player_name()) then
|
||||
return 0
|
||||
end
|
||||
store_action(pos, player, "take")
|
||||
@ -93,12 +93,13 @@ local function after_dig_node(pos, oldnode, oldmetadata, digger)
|
||||
end
|
||||
|
||||
local function formspec1()
|
||||
return "size[6,4]"..
|
||||
return "size[5.5,4]"..
|
||||
default.gui_bg..
|
||||
default.gui_bg_img..
|
||||
default.gui_slots..
|
||||
"field[0.5,1;5,1;number;TA4 Lua Controller number:;]" ..
|
||||
"button_exit[1.5,2.5;2,1;exit;Save]"
|
||||
"checkbox[0.5,1.8;public;"..S("Allow public chest access")..";false]"..
|
||||
"button_exit[1.7,2.8;2,1;exit;Save]"
|
||||
end
|
||||
|
||||
local function formspec2(pos)
|
||||
@ -147,7 +148,15 @@ minetest.register_node("techage:ta4_sensor_chest", {
|
||||
on_receive_fields = function(pos, formname, fields, player)
|
||||
local meta = M(pos)
|
||||
local nvm = techage.get_nvm(pos)
|
||||
if fields.number and fields.number ~= "" then
|
||||
|
||||
if meta:get_string("public") ~= "true" and minetest.is_protected(pos, player:get_player_name()) then
|
||||
return 0
|
||||
end
|
||||
|
||||
if fields.public then
|
||||
meta:set_string("public", fields.public)
|
||||
end
|
||||
if fields.quit == "true" and fields.number and fields.number ~= "" then
|
||||
local owner = meta:get_string("owner")
|
||||
if techage.check_numbers(fields.number, owner) then
|
||||
meta:set_string("number", fields.number)
|
||||
|
@ -386,7 +386,17 @@ Der Server dient zur zentralen Speicherung von Daten von mehreren Lua Controller
|
||||
|
||||
### TA4 Sensor Kiste/Chest
|
||||
|
||||
Die TA4 Sensor Kiste dient zum Aufbau von Automatischen Lagern oder Verkaufsautomaten. Sie hat erweitere Kommandos zur Fernsteuerung.
|
||||
Die TA4 Sensor Kiste dient zum Aufbau von Automatischen Lagern oder Verkaufsautomaten in Verbindung mit dem Lua Controller.
|
||||
Wird etwas in die Kiste gelegt, oder entnommen, oder eine der Tasten "F1"/"F2" gedrückt, so wird ein Event-Signal an den Lua Controller gesendet.
|
||||
Die Sensor Kiste unterstützt folgende Kommandos:
|
||||
|
||||
- Über `state = $read_data(<num>, "state")` kann der Status der Kiste abgefragt werden. Mögliche Antworten sind: "empty", "loaded", "full"
|
||||
- Über `name, action = $read_data(<num>, "action")` kann die letzte Spieleraktion abgefragt werden. `name` ist der Spielername, Als `action` wird zurückgeliefert: "put", "take", "f1", "f2".
|
||||
- Über `stacks = $read_data(<num>, "stacks")` kann der Inhalt der Kiste ausgelesen werden. Siehe dazu: https://github.com/joe7575/techage/blob/master/manuals/ta4_lua_controller_EN.md#sensor-chest
|
||||
- Über `$send_cmnd(<num>, "text", "press both buttons and\nput something into the chest")` kann der Text im Menü der Sensor Kiste gesetzt werden.
|
||||
|
||||
Über die Checkbox "Erlaube öffentlichen Zugriff" kann eingestellt werden, ob die Kiste von jedem genutzt werden darf, oder nur von Spielern die hier Zugriffsrechte haben.
|
||||
|
||||
|
||||
[ta4_sensor_chest|image]
|
||||
|
||||
@ -602,4 +612,4 @@ Beim Weitergeben wird in der Zielmaschine pro Item nur eine Position im Inventar
|
||||
|
||||
Die Verarbeitungsleistung beträgt bis zu 8 Items alle 3 Sekunden.
|
||||
|
||||
[ta4_injector|image]
|
||||
[ta4_injector|image]
|
||||
|
@ -388,7 +388,16 @@ The server is used for the central storage of data from several Lua controllers.
|
||||
|
||||
### TA4 Sensor Box / Chest
|
||||
|
||||
The TA4 sensor box is used to set up automatic warehouses or vending machines. It has additional commands for remote control.
|
||||
The TA4 sensor box is used to set up automatic warehouses or vending machines in conjunction with the Lua controller.
|
||||
If something is put into the box or removed, or one of the "F1" / "F2" keys is pressed, an event signal is sent to the Lua controller.
|
||||
The sensor box supports the following commands:
|
||||
|
||||
- The status of the box can be queried via `state = $read_data(<num>, "state")`. Possible answers are: "empty", "loaded", "full"
|
||||
- The last player action can be queried via `name, action = $read_data(<num>, "action")`. `name` is the player name. One of the following is returned as `action`: "put", "take", "f1", "f2".
|
||||
- The contents of the box can be read out via `stacks = $read_data(<num>, "stacks")`. See: https://github.com/joe7575/techage/blob/master/manuals/ta4_lua_controller_EN.md#sensor-chest
|
||||
- Via `$send_cmnd(<num>, "text", "press both buttons and\nput something into the chest")` the text can be set in the menu of the sensor box.
|
||||
|
||||
The checkbox "Allow public chest access" can be used to set whether the box can be used by everyone or only by players who have access/protection rights here.
|
||||
|
||||
[ta4_sensor_chest|image]
|
||||
|
||||
@ -513,9 +522,9 @@ The processing power is 12 items every 2 s, if TA4 tubes are used on both sides.
|
||||
The TA4 pusher has two additional commands for the Lua controller:
|
||||
|
||||
- `config` is used to configure the pusher, analogous to manual configuration via the menu.
|
||||
Example: `$ send_cmnd(1234, "config", "default: dirt")`
|
||||
Example: `$send_cmnd(1234, "config", "default: dirt")`
|
||||
- `pull` is used to send an order to the pusher:
|
||||
Example: `$ send_cmnd(1234, "pull", "default: dirt 8")`
|
||||
Example: `$send_cmnd(1234, "pull", "default: dirt 8")`
|
||||
Values from 1 to 12 are permitted as numbers. Then the pusher goes back to `stopped` mode and sends an" off "command back to the transmitter of the" pull "command.
|
||||
|
||||
[ta4_pusher|image]
|
||||
@ -552,8 +561,8 @@ The chest can only be used by players who can build at this location, i.e. who h
|
||||
The chest has an additional command for the Lua controller:
|
||||
|
||||
- `count` is used to request how many items are in the chest.
|
||||
Example 1: `$ read_data(CHEST, "count")` -> Sum of items across all 8 stores
|
||||
Example 2: `$ read_data(CHEST, "count", 2)` -> number of items in store 2 (second from left)
|
||||
Example 1: `$read_data(CHEST, "count")` -> Sum of items across all 8 stores
|
||||
Example 2: `$read_data(CHEST, "count", 2)` -> number of items in store 2 (second from left)
|
||||
|
||||
[ta4_8x2000_chest|image]
|
||||
|
||||
|
@ -330,7 +330,8 @@ In addition to Lua standard function the Lua Controller provides the following f
|
||||
E.g.: `$print("Hello "..name)`
|
||||
- `$loopcycle(seconds)` - This function allows to change the call frequency of the controller loop() function, witch is per default one second. For more info, see "Cyclic Task"
|
||||
- `$events(bool)` - Enable/disable event handling. For more info, see "Events"
|
||||
- `$get_ms_time()` - Returns time with millisecond precision
|
||||
- `$get_ms_time()` - Returns the time with millisecond precision
|
||||
- `get_gametime()` - Returns the time, in seconds, since the world was created
|
||||
- `$time_as_str()` - Read the time of day (ingame) as text string in 24h format, like "18:45"
|
||||
- `$time_as_num()` - Read the time of day (ingame) as integer number in 24h format, like 1845
|
||||
- `$get_input(num)` - Read an input value provided by an external block with the given number _num_. The block has to be configured with the number of the controller to be able to send status messages (on/off commands) to the controller. _num_ is the number of the remote block, like "1234".
|
||||
|
Binary file not shown.
@ -193,7 +193,7 @@ local function get_state(netw)
|
||||
if #(netw.gen1 or {}) + #(netw.gen2 or {}) == 0 then
|
||||
state = S("No power grid or running generator!")
|
||||
elseif needed > (netw.available1 or 0) then
|
||||
state = S("Probably too many consumers (")..needed..S(" ku is needed!)")
|
||||
state = S("Probably too many consumers (")..needed.." "..S("ku is needed").."!)"
|
||||
elseif (netw.num_nodes or 0) < techage.networks.MAX_NUM_NODES then
|
||||
state = S("Number of power grid blocks")..": "..(netw.num_nodes or 0)..", "..S("Max. needed power")..": "..needed.. " ku"
|
||||
else
|
||||
|
@ -120,19 +120,15 @@ local function get_capa(itemstack)
|
||||
return 0
|
||||
end
|
||||
|
||||
local function set_capa(pos, oldnode, digger, capa)
|
||||
local node = ItemStack(oldnode.name)
|
||||
local meta = node:get_meta()
|
||||
local function set_capa(pos, oldnode, oldmetadata, drops)
|
||||
local nvm = techage.get_nvm(pos)
|
||||
local capa = nvm.capa
|
||||
local meta = drops[1]:get_meta()
|
||||
capa = techage.power.percent(PWR_CAPA, capa)
|
||||
capa = (math.floor((capa or 0) / 5)) * 5
|
||||
meta:set_int("capa", capa)
|
||||
local text = S("TA3 Accu Box").." ("..capa.." %)"
|
||||
meta:set_string("description", text)
|
||||
local inv = minetest.get_inventory({type="player", name=digger:get_player_name()})
|
||||
local left_over = inv:add_item("main", node)
|
||||
if left_over:get_count() > 0 then
|
||||
minetest.add_item(pos, node)
|
||||
end
|
||||
end
|
||||
|
||||
local function after_place_node(pos, placer, itemstack)
|
||||
@ -149,9 +145,7 @@ local function after_place_node(pos, placer, itemstack)
|
||||
end
|
||||
|
||||
local function after_dig_node(pos, oldnode, oldmetadata, digger)
|
||||
local nvm = techage.get_nvm(pos)
|
||||
Cable:after_dig_node(pos)
|
||||
set_capa(pos, oldnode, digger, nvm.capa)
|
||||
techage.del_mem(pos)
|
||||
end
|
||||
|
||||
@ -188,13 +182,12 @@ minetest.register_node("techage:ta3_akku", {
|
||||
after_dig_node = after_dig_node,
|
||||
tubelib2_on_update2 = tubelib2_on_update2,
|
||||
networks = net_def,
|
||||
|
||||
drop = "", -- don't remove, item will be added via 'set_capa'
|
||||
paramtype2 = "facedir",
|
||||
groups = {cracky=2, crumbly=2, choppy=2},
|
||||
on_rotate = screwdriver.disallow,
|
||||
is_ground_content = false,
|
||||
sounds = default.node_sound_wood_defaults(),
|
||||
preserve_metadata = set_capa,
|
||||
})
|
||||
|
||||
Cable:add_secondary_node_names({"techage:ta3_akku"})
|
||||
|
@ -281,8 +281,8 @@ minetest.register_node("towercrane:mast_ctrl_off", {
|
||||
-- switch the crane ON
|
||||
on_rightclick = function (pos, node, clicker)
|
||||
if is_my_crane(pos, clicker) and not is_operator(clicker) then
|
||||
start_crane(pos, clicker)
|
||||
if set_operator_privs(clicker, pos) then
|
||||
start_crane(pos, clicker)
|
||||
local pos1, pos2 = calc_construction_area(pos)
|
||||
-- control player every second
|
||||
minetest.after(1, control_player, pos, pos1, pos2, clicker:get_player_name())
|
||||
|
Loading…
Reference in New Issue
Block a user