привет игроки!
не знаю зачем но я написал константы.
они замораживают значение переменной.
код:
const={}
setmetatable(const,{__call=function(self,key) rawset(self,key,{rawget(_G,key)}) rawset(_G,key,nil) end})
setmetatable(_G,{__index=function(self,key) if const[key] then return const[key][1] else return rawget(self,key) end end,__newindex=function(self,key,value) if not const[key] then rawset(self,key,value) end end})
пример:
pi=math.pi
const "pi"
pi="error"
print(pi) --> 3.1415926535898
ещё один пример:
const "_"
_=123
print(_) --> nil