-
July 31st, 2022, 19:05 #1
Character Wizard overrides of onInit
I have overriden character wizard charwizard.lua to override the onInit call and modify the collections it builds. Works as it always has. But now I find that unless I copy in every single function and header definitions - it will not work with the LVL UP button in the character sheet. This makes no sense to me. Why is LUA/FGU/whatever forcing me to do this? I've tried calling super things but unless I call the actual functions and define them all in my override they will seem to go off to some other version of the code.
Totally confused. For now I'm going to copy the entire charwizrd.lua and stamp my onInit stuff in it also - but this seems way overkill and unfriendly to manage just to get some onInit stuff working the character wizard - which always works. It's just when it comes at the same charwizard.lua that I don't override from the charsheet LVL UP button that it seems to go nuts. Unless I copy in and override all the code in that lua.
Would really like to not have to do this. Is there a way?Free(Forums/Forge) Extension(FGU 5E):
Paid (Forge) Extension(FGU 5E):
-
August 1st, 2022, 00:08 #2
Super only works in scripts attached to controls, not global scripts. Each global script runs in its own scope and knows nothing about other scopes. Super works with controls because FG performs the control overrides and can walk back up the chain. For global scripts there is no such relationship. You either override the entire thing, including the global name that function names are prefixed by, or you create a new global script and figure out a way to interact with the existing global script, either via function replacement or well-known callback registration mechanisms. I also don't think super works in a fully or partially overridden windowclass, but I might be wrong about that.
More information about scripting and the override mechanisms can be found in the Scripting page on the wiki, of which I'm sure you're already aware.
-
August 1st, 2022, 04:39 #3
That is very valuable - but depressing - information to hear. I suspected that was the case, as it seems more if something comes in from outside of the normal functionality where .lua is defined it requires every piece of logic/structure/etc. that it touches to be added into the override. I usually can work around it by limiting it to just a few things - but not this time.
Much appreciated for that information - as I never knew the reasoning behind why I've had to do that sort of thing in the past.Free(Forums/Forge) Extension(FGU 5E):
Paid (Forge) Extension(FGU 5E):
-
August 1st, 2022, 05:30 #4
It would be far simpler if everyone used named scripts and named script function calls...like CharacterWizard.collectRaces(), et.al. Then you could just override the functions as needed...but I don't think that would work in this particular case, because it sounds like you are adding to onInit rather than replacing specific functions? Anyways, my 2 coppers...
aka Laendra
(Discord: Laendra#9660)
Ultimate license (FGC/FGU)
Current Timezone : Central (CDT) (GMT -5)
OP: 3317036507 / 2369539
My opinions are my own and represent no entity other than myself
Extension Support Discord: https://discord.gg/gKgC7nGpZK
Extensions = risk to your gaming experience. If you haven't tested out the extensions in your campaign before your gaming session, turn them off. If you don't backup your campaigns regularly, you're doing it wrong.
-
August 1st, 2022, 17:38 #5Free(Forums/Forge) Extension(FGU 5E):
Paid (Forge) Extension(FGU 5E):
-
August 1st, 2022, 18:55 #6
I would agree with deer_buster that things would be easier if coders kept the code attached to windows and controls to a minimum, generally only those things that actually involve the UI, and moved as much ruleset logic as possible into named scripts. This is the equivalent of the well-known model-view-controller (MVC) method of code separation which has been around almost as long as UIs have been around. Also known as "separation of concerns". If you can make good general purpose functions in named scripts, then those can be called by multiple control scripts as needed. However, if you put ruleset logic into a control script, then it's likely that you will be duplicating that code somewhere down the line (in a similar control in a different windowclass) which turns into a maintenance headache.
-
August 1st, 2022, 19:21 #7My Forge creations: https://forge.fantasygrounds.com/crafter/9/view-profile
My GitHub: https://github.com/MeAndUnique
Buy me a coffee: https://ko-fi.com/meandunique
Discord: MeAndUnique#6805
-
August 1st, 2022, 23:31 #8Free(Forums/Forge) Extension(FGU 5E):
Paid (Forge) Extension(FGU 5E):
Thread Information
Users Browsing this Thread
There are currently 1 users browsing this thread. (0 members and 1 guests)
Bookmarks