aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--builtin/client/register.lua1
-rw-r--r--builtin/game/item.lua4
-rw-r--r--builtin/game/register.lua14
3 files changed, 10 insertions, 9 deletions
diff --git a/builtin/client/register.lua b/builtin/client/register.lua
index 27a6b02d9..61db4a30b 100644
--- a/builtin/client/register.lua
+++ b/builtin/client/register.lua
@@ -1,4 +1,3 @@
-
core.callback_origins = {}
local getinfo = debug.getinfo
diff --git a/builtin/game/item.lua b/builtin/game/item.lua
index 439a71679..5543e9a3f 100644
--- a/builtin/game/item.lua
+++ b/builtin/game/item.lua
@@ -529,9 +529,7 @@ function core.node_dig(pos, node, digger)
-- Run script hook
for _, callback in ipairs(core.registered_on_dignodes) do
local origin = core.callback_origins[callback]
- if origin then
- core.set_last_run_mod(origin.mod)
- end
+ core.set_last_run_mod(origin.mod)
-- Copy pos and node because callback can modify them
local pos_copy = vector.new(pos)
diff --git a/builtin/game/register.lua b/builtin/game/register.lua
index 56e40c75c..0be107c36 100644
--- a/builtin/game/register.lua
+++ b/builtin/game/register.lua
@@ -403,8 +403,14 @@ function core.override_item(name, redefinition)
register_item_raw(item)
end
-
-core.callback_origins = {}
+do
+ local default = {mod = "??", name = "??"}
+ core.callback_origins = setmetatable({}, {
+ __index = function()
+ return default
+ end
+ })
+end
function core.run_callbacks(callbacks, mode, ...)
assert(type(callbacks) == "table")
@@ -419,9 +425,7 @@ function core.run_callbacks(callbacks, mode, ...)
local ret = nil
for i = 1, cb_len do
local origin = core.callback_origins[callbacks[i]]
- if origin then
- core.set_last_run_mod(origin.mod)
- end
+ core.set_last_run_mod(origin.mod)
local cb_ret = callbacks[i](...)
if mode == 0 and i == 1 then