Rewrite to EGPLib objectcontrol.lua
#3038
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Tidies up things and adds comments everywhere for good measure. Part one of an eventual refactor of EGP library entirely. (Is it really a refactor with this many API changes?)
Although I renamed the file, GH will not tolerate it, so sorry, I just felt like
objectcontrol.luawas an outdated name. I can't be the only one, right? You can observe 0d75e21 for most of the diff, or view the diff on your own. For your convenience, I've exported the diff for you here. If you see a problem, check the later commits in case they're fixed.Certain method calls were changed to function calls preceded with
nil. This was just an oversight thinking certain functions were not methods, and now it just serves as a memory aid that they're not actual methods.Asking for testers
Noteworthy changes by file:
gmod_wire_expression2/core/e2lib.luagmod_wire_egp/lib/init.luaEGPa subtable ofE2Libto avoid global pollution.EGPstill exists for backwards compatibility and will be removed once everything is done.EGP.HookPostInitfunction as a simple postinit handlergmod_wire_egp/lib/egplib/objectcontrol.luaobjects.luaobjects). Numerical indices track IDs while string keys track object names. Greatly simplifies getter logic.EGP.GetObjectByIDEGPObjectbase and metatable.IsValidmetatable method.EGPObjecttype.EGPfor future use.baseObj.EditObjectwhen they should be calling their ownself.EditObjectto initialize instead.baseObj.Setto callSetObjectif a position key is foundbaseObjinitialization to a single table initializerNULL_EGPOBJECTto be anEGPObjectobject instead of its own specialized metatableEGP.IsEGPObjectEGP.NewObjectto fit new APIEGP.InheritObjectEGP.EditObjectEGP.HasObjectEGP.SetOrderEGP.PerformReorderEGP.PerformReorder_ExEGP.CreateObject->EGP.CreateEntity, string|integer, tabletostring|integer, table, Entitygmod_wire_expression2/core/egpfunctions.luaEGP.HasObjectwith localized versionEGP.CreateObjectwith updated, localized versionself.playerargumentEGP.EditObjectwith EGP Object methodgmod_wire_expression2/core/egpobjects.luaEGPObject.IsValidfor validity checkingEGP.HasObjectwith localized versionEGP.CreateObjectwith updated, localized versionself.playerargumentEGP.EditObjectwith EGP Object methodremovee2functions to not change metatableAll other changes were too small/insignificant and mostly involve changing/replacing usage of a few functions.