Closed clyfordv closed 3 weeks ago
Great initiative 👍
Would it be interesting to add the remaining callbacks, but have them be empty? If anything else it would serve as documentation.
Yes that sounds like a splendid idea.
One interesting problem is that you can no longer hook these functions 'the usual way'. You'd also need to overwrite the definition in OnCommandIssuedCallback
in order for the hook it to work.
One solution to that is to put them in a separate file. What are your thoughts on this?
The hook would need to (with the current setup) look something like:
oldOnGuardIssued = OnGuardIssued
OnCommandIssuedCallback.OnGuardIssued = function(command)
$NEW_LOGIC
oldOnGuardIssued(command)
end
?
To me it isn't terribly different from hooking a class. I'm on the fence about putting it in a separate file for readability reasons, but the above doesn't seem so bad to me. We could also add a comment to the callback table indicating the proper hook format.
You're right; maybe I am a bit too anxious about it. Could you add a bit of documentation on how to hook these functions? Then we can merge this in.
Issues:
OnCommandIssued
is a long list of if else statements--aside from being generally unorganized it makes modifying the logic for different commands more difficult for modders.Changes:
OnCommandIssued
sections into callback functions, and access those functions with a table keyed with the command type ('Repair', 'Reclaim', 'Attack' etc.).Notes: