firstly, i set a variable like go.property(“asteroid_table”,{})
and after i cannot use this as self.asteroid_table in my global functions
plz slove this
firstly, i set a variable like go.property(“asteroid_table”,{})
and after i cannot use this as self.asteroid_table in my global functions
plz slove this
Access self is only possible in the context of that script.
Script properties cannot be tables.
number, boolean, hash, msg.url, vmath.vector3, vmath.vector4, vmath.quaternion and resource
A better solution for you might be to make a Lua module which is the asteroid controller.
asteroid_manager.lua
local M = {}
M.asteroid_table = {}
function M.add_asteroid(asteroid)
table.insert(M.asteroid_table, asteroid)
...
end
return M
asteroid.script
local asteroid_manager = require("utils.asteroid_manager")
function init(self)
local asteroid = {size = 2, position=vmath.vector3(100,25,0)}
asteroid_manager.add_asteroid(asteroid)
...
end
...