mirror of
https://github.com/minetest-mods/mesecons.git
synced 2024-11-13 05:40:32 +01:00
Exit with error if vports do not exist for any reason (#618)
Make sure node is registered before attempting to access the vports
This commit is contained in:
parent
0a4a88b1b9
commit
c4f9336a26
|
@ -470,7 +470,12 @@ local safe_globals = {
|
||||||
|
|
||||||
local function create_environment(pos, mem, event, itbl, send_warning)
|
local function create_environment(pos, mem, event, itbl, send_warning)
|
||||||
-- Gather variables for the environment
|
-- Gather variables for the environment
|
||||||
local vports = minetest.registered_nodes[minetest.get_node(pos).name].virtual_portstates
|
local node_def = minetest.registered_nodes[minetest.get_node(pos).name]
|
||||||
|
if not node_def then return end
|
||||||
|
|
||||||
|
local vports = node_def.virtual_portstates
|
||||||
|
if not vports then return end
|
||||||
|
|
||||||
local vports_copy = {}
|
local vports_copy = {}
|
||||||
for k, v in pairs(vports) do vports_copy[k] = v end
|
for k, v in pairs(vports) do vports_copy[k] = v end
|
||||||
local rports = get_real_port_states(pos)
|
local rports = get_real_port_states(pos)
|
||||||
|
@ -627,6 +632,7 @@ local function run_inner(pos, code, event)
|
||||||
-- Create environment
|
-- Create environment
|
||||||
local itbl = {}
|
local itbl = {}
|
||||||
local env = create_environment(pos, mem, event, itbl, send_warning)
|
local env = create_environment(pos, mem, event, itbl, send_warning)
|
||||||
|
if not env then return false, "Env does not exist. Controller has been moved?" end
|
||||||
|
|
||||||
local success, msg
|
local success, msg
|
||||||
-- Create the sandbox and execute code
|
-- Create the sandbox and execute code
|
||||||
|
|
Loading…
Reference in New Issue
Block a user