Counter Strike : Global Offensive Source Code
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

12 lines
260 B

  1. -- make global variables readonly
  2. local f=function (t,i) error("cannot redefine global variable `"..i.."'",2) end
  3. local g={}
  4. local G=getfenv()
  5. setmetatable(g,{__index=G,__newindex=f})
  6. setfenv(1,g)
  7. -- an example
  8. rawset(g,"x",3)
  9. x=2
  10. y=1 -- cannot redefine `y'