techage_modpack/techage/basic_machines/mods_support.lua

132 lines
3.7 KiB
Lua
Raw Permalink Normal View History

2020-09-13 14:24:06 +03:00
--[[
TechAge
=======
Copyright (C) 2019-2020 Joachim Stolberg
2020-10-25 23:32:47 +03:00
AGPL v3
2020-09-13 14:24:06 +03:00
See LICENSE.txt for more information
2022-01-04 21:43:30 +03:00
2020-09-13 14:24:06 +03:00
Tube support for digtron and protector chests
2022-01-04 21:43:30 +03:00
2020-09-13 14:24:06 +03:00
]]--
-- for lazy programmers
local M = minetest.get_meta
local CacheForFuelNodeNames = {}
local function is_fuel(stack)
local name = stack:get_name()
2022-01-04 21:43:30 +03:00
if CacheForFuelNodeNames[name] then
2020-09-13 14:24:06 +03:00
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"}, {
2021-05-14 19:50:16 +03:00
on_inv_request = function(pos, in_dir, access_type)
local meta = minetest.get_meta(pos)
return meta:get_inventory(), "main"
end,
2020-09-13 14:24:06 +03:00
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,
2022-01-04 21:43:30 +03:00
})
2020-09-13 14:24:06 +03:00
techage.register_node({"digtron:fuelstore"}, {
2021-05-14 19:50:16 +03:00
on_inv_request = function(pos, in_dir, access_type)
local meta = minetest.get_meta(pos)
return meta:get_inventory(), "fuel"
end,
2020-09-13 14:24:06 +03:00
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,
2022-01-04 21:43:30 +03:00
})
2020-09-13 14:24:06 +03:00
techage.register_node({"digtron:combined_storage"}, {
2021-05-14 19:50:16 +03:00
on_inv_request = function(pos, in_dir, access_type)
local meta = minetest.get_meta(pos)
return meta:get_inventory(), "main"
end,
2020-09-13 14:24:06 +03:00
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,
2022-01-04 21:43:30 +03:00
})
2020-09-13 14:24:06 +03:00
------------------------------------------------------------------------------
-- protector
------------------------------------------------------------------------------
techage.register_node({"protector:chest"}, {
2021-05-14 19:50:16 +03:00
on_inv_request = function(pos, in_dir, access_type)
local meta = minetest.get_meta(pos)
return meta:get_inventory(), "main"
end,
2020-09-13 14:24:06 +03:00
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,
2022-01-04 21:43:30 +03:00
})