Log In  

hi! when i use lua i usually use a library that prevents me from accidentally using/setting globals that aren't already defined, in order to cut down on typos. i've collected a small whitelist of globals that need to be available for picotron. i noticed in terminal.lua there's a comment saying it's not supposed to set any globals, so i thought i'd report them in case they should be fixed.

here's what i have so far in my whitelist:

-- terminal.lua
cproj_draw
cproj_update
_
_is_terminal_command
k
res
-- gui.lua
drag_t

and here's the full script i'm using to protect globals in case it's helpful:

-- if you're using include(), include this after including everything else,
-- since most included modules will need to assign global variables on load

-- these globals are needed by picotron
_init = _init or false
_draw = _draw or false
_update = _update or false
-- these are used by the picotron terminal
cproj_draw = cproj_draw or false
cproj_update = cproj_update or false
_ = _ or false
_is_terminal_command = _is_terminal_command or false
k = k or false
res = res or false
-- gui needs these
drag_t = drag_t or false

local function unknown_variable (t, k)
  error (debug.traceback ('unknown variable ' .. tostring (k), 2))
end

setmetatable (_G, {
  __index = unknown_variable,
  __newindex = unknown_variable,
})

it's probably a good idea not to use it in finished carts because then changes to picotron might break them

P#147073 2024-04-21 17:21 ( Edited 2024-04-21 17:25)


[Please log in to post a comment]