Thread: Help with CT.lua
-
August 11th, 2020, 22:27 #1
Help with CT.lua
I've run into a problem with adding functionality to the CT.lua file. I'm hoping I'm just being stupid and someone can help me out.
I've have a new template_ct.xml file that contains the following code
Code:<template name="list_ctbox_host" merge="join"> <windowlist name="list"> <anchored to="contentanchor"> <top anchor="bottom" relation="relative" offset="5" /> <left offset="-30" /> <right offset="10" /> <bottom parent="" offset="-55" /> </anchored> <datasource>.list</datasource> <class>ct_entry</class> <empty font="list-empty-ct" textres="ct_emptylist" /> <script file="ct/scripts/new_ct.lua" /> </windowlist> </template>
This all works fine, as currently I have just copied the entiretly of the old ct.lua file into my new one and added in my new functions.
I thought I could use 'super.onInit()' to call the original onInit function (as well as doing it for most of the other original functions in the ct.lua file also), but this throws an error 'attempt to index global 'super' ( a nil value).
So my question is :
Is it possible to use the 'super' functionality in ct.lua, and if so what am I doing wrong?
Cheers, Steve.
-
August 11th, 2020, 23:23 #2
Supreme Deity
- Join Date
- Mar 2007
- Posts
- 20,564
Templates don't support merge attribute; so you are overriding based on that code.
You would need to copy the original template and script, then modify to fit your needs; or possibly use some sort of stepped template (original redefined as list_ctbox_host_step; and new list_ctbox_host inherits).
Regards,
JPG
-
August 11th, 2020, 23:38 #3
Thanks Moon Wizard, I guess I'll leave my code 'as is' then with the copied contents of the original file.
Cheers, Steve.
-
November 19th, 2020, 17:45 #4Free(Forums/Forge) Extension(FGU 5E):
Paid (Forge) Extension(FGU 5E):
-
November 19th, 2020, 20:45 #5
As this is code that runs in a control (windowlist), any extensions or layered rulesets that change the code will be layering on top of the original code. You can access the original code by using the super variable - you may need to write some code to cycle through all the layers of super variables until you find the highest level instance - in case there are multiple extensions overriding it.
Access a function the next level up by using super.<function name> - but check for "super" first - e.g. to check for a higher level onInit() function use something like: if super and super.onInit then ...
Do a search for super. in any layered ruleset to see some examples.
Some info on script block scope and the super variable here: https://fantasygroundsunity.atlassia...pt-Block-ScopePrivate Messages: My inbox is forever filling up with PMs. Please don't send me PMs unless they are actually private/personal messages. General FG questions should be asked in the forums - don't be afraid, the FG community don't bite and you're giving everyone the chance to respond and learn!
-
November 19th, 2020, 20:53 #6
Used super before and that was what I tried before looking up why it did not work - as you can see from this post I glommed onto - he had same issue where super is nil. Evidently when the .lua is referenced in a template it does not have super. All mine were nil - like this guys - and I was looking for a way not to stomp all the code.
If you are saying its automagically layered on top even though the super is not present - can I just add in the code I need overriden or new in the ct.lua reference I've given the template code and leave the rest blank? See original post here to see what I'm talking about.Free(Forums/Forge) Extension(FGU 5E):
Paid (Forge) Extension(FGU 5E):
-
November 19th, 2020, 21:05 #7
I don't have free time to get into the guts of this.
And looking at the 5E code, there's a comment above the windowlist template where ct.lua is used saying "<!-- NOTE: Redefine list box template to make sure that new ct.lua script used -->" Whereas some other rulesets don't don't use a template, they use a control directly in the XML - so you can override the code directly.
I have no idea about the details of what you're actually trying to do and, like I say, I don't have time to get dragged into this. You may need to look into what MW mentions in post #2 above.Private Messages: My inbox is forever filling up with PMs. Please don't send me PMs unless they are actually private/personal messages. General FG questions should be asked in the forums - don't be afraid, the FG community don't bite and you're giving everyone the chance to respond and learn!
-
November 19th, 2020, 21:13 #8Free(Forums/Forge) Extension(FGU 5E):
Paid (Forge) Extension(FGU 5E):
-
November 19th, 2020, 21:43 #9
The CT was a PITA to play with, probably 'cos of my lack of knowledge of all things FG and LUA related
Although I think there is a timer addition to the combat tracker that will work still alongside my legendary assistant extension (when I get round to adjusting some bounds), maybe looking into that may help @Silentruin?
Cheers, Steve.
-
November 19th, 2020, 22:47 #10
I don't have any trouble doing the code - its my ever present desire to minimize the footprint (stomping on other extensions) that I worry about For now my plan is to just get it working then if I put it up in DMsG will have to have horrific warnings about the compatibility issues because the way 5E references those .lua files through a template makes only one option available if you have to modify them. STOMP THEM ALL. Which I'm not a fan of - but we will see if there is not some magic or something someone knows about. My bet - is unlikely
Free(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