70 lines
2.0 KiB
Lua
70 lines
2.0 KiB
Lua
--[[local formspec = --template for sparkinventory
|
|
"size[11.4,4]"..
|
|
"list[current_player;main;0,0;8,3;8]" ..
|
|
"list[current_player;main;0,3.2;8,1;]"..
|
|
"list[current_player;craft;8.5,0;3,3]" ..
|
|
"list[current_player;craftpreview;8.5,3.2;1,1]" ..
|
|
"listcolors[#fc059db0;#fc059dd0]"
|
|
]]--
|
|
minetest.register_on_joinplayer(
|
|
function(player)
|
|
minetest.after(0.01,function()
|
|
player:set_formspec_prepend("")
|
|
player:set_inventory_formspec(sparktech.add_inventory(0, 0, ""))
|
|
end)
|
|
end)
|
|
|
|
local spark_quick_put_machines = minetest.settings:get_bool("spark_quick_put_machines")
|
|
local spark_quick_put_storage = minetest.settings:get_bool("spark_quick_put_storage")
|
|
local spark_quick_put_default = minetest.settings:get_bool("spark_quick_put_default")
|
|
local spark_quick_put_overide = minetest.settings:get("spark_quick_put_overide")
|
|
|
|
local whitelist
|
|
if spark_quick_put_overide then
|
|
--overide here
|
|
whitelist = { "product" }
|
|
else
|
|
if spark_quick_put_machines then
|
|
whitelist = { "fuel", "product", "source" }
|
|
end
|
|
|
|
if spark_quick_put_storage then
|
|
if whitelist then
|
|
table.insert(whitelist, "main")
|
|
else
|
|
whitelist = { "main" }
|
|
end
|
|
end
|
|
|
|
if spark_quick_put_default then
|
|
if whitelist then
|
|
table.insert(whitelist, "src")
|
|
table.insert(whitelist, "dst")
|
|
end
|
|
end
|
|
end
|
|
|
|
local function quick_refuel(position, node, puncher, pointed)
|
|
local nodemeta = minetest.get_meta(position)
|
|
local noderef = minetest.registered_nodes[node.name]
|
|
if not noderef then return false end
|
|
local putfunc = noderef.allow_metadata_inventory_put
|
|
local itemstack = puncher:get_wielded_item()
|
|
local inventory = nodemeta:get_inventory()
|
|
if not inventory or not putfunc then return false end -- putfunc so grass doesnt crash the game
|
|
for list in pairs(whitelist) do
|
|
local transstack = putfunc(position, whitelist[list], nil, itemstack, puncher)
|
|
if transstack ~= 0 then
|
|
local leftover = inventory:add_item(whitelist[list], itemstack)
|
|
puncher:set_wielded_item(leftover)
|
|
return
|
|
end
|
|
end
|
|
end
|
|
|
|
|
|
if whitelist then
|
|
minetest.register_on_punchnode(quick_refuel)
|
|
end
|
|
|