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.lua
was 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.lua
gmod_wire_egp/lib/init.lua
EGP
a subtable ofE2Lib
to avoid global pollution.EGP
still exists for backwards compatibility and will be removed once everything is done.EGP.HookPostInit
function as a simple postinit handlergmod_wire_egp/lib/egplib/objectcontrol.lua
objects.lua
objects
). Numerical indices track IDs while string keys track object names. Greatly simplifies getter logic.EGP.GetObjectByID
EGPObject
base and metatable.IsValid
metatable method.EGPObject
type.EGP
for future use.baseObj.EditObject
when they should be calling their ownself.EditObject
to initialize instead.baseObj.Set
to callSetObject
if a position key is foundbaseObj
initialization to a single table initializerNULL_EGPOBJECT
to be anEGPObject
object instead of its own specialized metatableEGP.IsEGPObject
EGP.NewObject
to fit new APIEGP.InheritObject
EGP.EditObject
EGP.HasObject
EGP.SetOrder
EGP.PerformReorder
EGP.PerformReorder_Ex
EGP.CreateObject
->EGP.Create
Entity, string|integer, table
tostring|integer, table, Entity
gmod_wire_expression2/core/egpfunctions.lua
EGP.HasObject
with localized versionEGP.CreateObject
with updated, localized versionself.player
argumentEGP.EditObject
with EGP Object methodgmod_wire_expression2/core/egpobjects.lua
EGPObject.IsValid
for validity checkingEGP.HasObject
with localized versionEGP.CreateObject
with updated, localized versionself.player
argumentEGP.EditObject
with EGP Object methodremove
e2functions to not change metatableAll other changes were too small/insignificant and mostly involve changing/replacing usage of a few functions.