In lua engines like pico8 you can swap between the global environment and any user defined ones. A basic setup in pico8 is:
_G = _ENV; _G.__index = _G --header
player={x=30};setmetatable(player,_G)
do
local _ENV=player
function update()
x+=1
end
function draw()
circ(x,63,8)
end
end
function _update() player:update() end
function _draw()cls(1) player:draw() end --displays circle moving right
I’m not having any luck translating this into solar2d. It’s not accepting the header line: _G = _ENV; _G.__index = _G
In solar2d it seems _G exists as the default environment name.
Whereas pico8 it’s _ENV. Swapping the names in the code above will move it past the header but the read of the code won’t work, it’ll recognize x as a nonexistant global.