I got for example:
Code: Select all
local p = game.players[1]
Code: Select all
local p = game.players[1]
p["my_local_variable"] = 123
Code: Select all
game.players[1].print(p.my_local_variable)
Code: Select all
local p = game.players[1]
Code: Select all
local p = game.players[1]
p["my_local_variable"] = 123
Code: Select all
game.players[1].print(p.my_local_variable)
Because those objects are not actually Lua objects, they are C++ objects exposed to the Lua engine. There are many things that are special about them, and this is one of them. Just store you data in a table indexed by the unique ID of the object - not the object itself - and accept the limitation.cogito123 wrote: ↑Wed Jul 17, 2019 6:24 pmNow, I can access properties such as 'force', 'name' and so on. My question is, why I can't assign more properties into this instance?
If my understanding is correct, this syntax is legal in Lua and I should be able to access this field as such:
[...]
This would help me save lines of code and lower the complexity, since I wouldn't be required to use external tables to keep state of players. Why isn't this possible?
Code: Select all
local p = setmetatable({},{__index=game.player})