Bolodefchoco_LUAXML

[Script] setConst

Sep 4th, 2017
190
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 0.59 KB | None | 0 0
  1. --Creator: Bolodefchoco
  2. --Made in: 04/09/2017
  3. --Last update: 04/09/2017
  4. --[[ Notes:
  5.     Does:
  6.         Cria variáveis constantes
  7.     Args:
  8.         var -> O nome da variável
  9.         val -> O valor da variável
  10.     Exemplo:
  11.         a = "test"
  12.         a = setConst("a",a)
  13. ]]--
  14.  
  15. do
  16.     local _C = {}
  17.     setConst = function(var,val)
  18.         if not _C[var] then
  19.             _C[var] = val
  20.         end
  21.         return nil
  22.     end
  23.     _G = setmetatable(_G,{
  24.         __newindex = function(l,i,v)
  25.             if _C[i] then
  26.                 rawset(l,i,nil)
  27.                 return _C[i]
  28.             else
  29.                 rawset(l,i,v)
  30.             end
  31.         end,
  32.         __index = function(l,i)
  33.             return _C[i] or rawget(l,i)
  34.         end
  35.     })
  36. end
Add Comment
Please, Sign In to add comment