Inheriting

  • What’s objective programming without over engineering class structures! If you have something like Entity_Base and Entity_NPC, then you can simply create a inheritance tree like so:
YOUScript::Userdata* udParent = ysi.RegisterUserdata("TestParent", 1000, 0, TestParentCTOR, nullptr);
udParent->RegisterFunction("a", a);
udParent->RegisterFunction("c", a);
YOUScript::Userdata* udChild = ysi.RegisterUserdata("TestChild", 1001, 0, TestChildCTOR, nullptr);
udChild->InheritFrom = udParent;
  • or: udChild->InheritFrom = ysi.GetRegisteredUserdata(1000); 1000 being the typeID, which refers to TestParent
udChild->RegisterFunction("b", b);
udChild->RegisterFunction("c", c);  - override c, because we don't want to call the base function a, but our own!
  • Now we have a object called TestChild with a, b and c methods and a TestParent with a and c in it as methods