Variable ProtectionΒΆ

  • Lets use the Math libary as example, the math libary is set, and you dont want people to override it with their own stuff. Simply doing this would be enough:
ysi.GetVar("Math")->ReadOnly = true;
  • Do note however, that this is an internal check in the table class. So if you would do this in c++ now
ysi.SetVar("Math", magic);
  • This would not work anymore, and will throw a YS error, which might mess up the callstack a bit.
  • However, if you do this
ysi.RemoveVar("Math");
ysi.SetVar("Math", magic);
  • This does work, because you first forcefully remove it out of the table. dont worry, this wont generate memory leaks on our side note: SetVar is a reference to this->Globals->Set, for a function the reference would be this->Locals->Set
  • This is usefull for when people are overriding things they should not override