Quote
if sample==nil then sample={} end
sample.ads={}
sample.ads={}
And where can i download more example plugins for this language learning
Scripts
What first lines in examples stands for?
What first lines in examples stands for?
1

if sample==nil then sample={} end
sample.ads={}
if yazir==nil then yazir={} end
yazir.firstscript={}
yazir.firstscript.x=123
DC post, you can even do it like thisyazir=yazir or {}
VADemon: It's not reallocating, unless yazir is nil -- then it would just be allocating because it never existed in the first place.
Apache uwu: Indeed Lua wouldn't allocate the table to a new chunk of memory even if you wanted it to:x = string string.f = 5 print(x.f)
yazir = yazir or {}
yazir = nil
yazir = yazir or {}
yazir = nil
if yazir == nil then yazir = {} end
Pagyra: I agree. If I'm not wrong, Lua internal code loops through the tables and compares keys to get values. It's faster if you use more global tables and push stuff into them (functions, strings, numbers, tables, userdata, etc). It should increase the memory usage slightly. The benefit of this system is that you can use ANY type of value as a key for your table, incluiding another table.table[{}] = {}
1
