Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Silence a warning on MT 5.4.x #33

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
33 changes: 18 additions & 15 deletions stations.lua
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,24 @@
crafting.register_type("inv")
crafting.register_type("furnace")

local player_inv_hashes = {}

local function check_for_changes()
for _, player in pairs(minetest.get_connected_players() or {}) do
if sfinv.get_or_create_context(player).page == "sfinv:crafting" then
local hash = crafting.calc_inventory_list_hash(player:get_inventory(), "main")
local old_hash = player_inv_hashes[player:get_player_name()]
if hash ~= old_hash then
sfinv.set_page(player, "sfinv:crafting")
end
end
end

minetest.after(1, check_for_changes)
end


if minetest.global_exists("sfinv") then
local player_inv_hashes = {}

local trash = minetest.create_detached_inventory("crafting_trash", {
-- Allow the stack to be placed and remove it in on_put()
Expand Down Expand Up @@ -51,20 +67,7 @@ if minetest.global_exists("sfinv") then
end
})

local function check_for_changes()
for _, player in pairs(minetest.get_connected_players() or {}) do
if sfinv.get_or_create_context(player).page == "sfinv:crafting" then
local hash = crafting.calc_inventory_list_hash(player:get_inventory(), "main")
local old_hash = player_inv_hashes[player:get_player_name()]
if hash ~= old_hash then
sfinv.set_page(player, "sfinv:crafting")
end
end
end

minetest.after(1, check_for_changes)
end
check_for_changes()
minetest.after(1, check_for_changes)
end

minetest.register_node("crafting:work_bench", {
Expand Down