Thread: ct_entry.lua
-
June 4th, 2020, 18:41 #1
ct_entry.lua
I'm not seeing a reference to his file in the base.xml file.
I need to add to one of the functions in the ct_entry.lua file, what's the best/preferred way of doing this?
Cheers, Steve.
-
June 4th, 2020, 18:53 #2
If it's not referenced in the base.xml file then it isn't a global script. It will be a script that is assigned to a <script> entry within a control or windowclass XML. Do a find in files for that filename to see where.
Exactly what is the best way to do things depends on exactly what you're changing. You'll essentially need to have a "stub" of the windowclass (or control) that the script is assigned to (it may be multiple window classes or controls) to be able to add in a custom .lua file.
Here is an example where I'm adding to a script file in CoreRPG in the PFRGP2 ruleset:
Code:<!--Included so that the custom ref_groupedlist_groupitem.lua is used--> <windowclass name="reference_groupedlist_groupitem" merge="join"> <script file="ref/scripts/ref_groupedlist_groupitem.lua" /> </windowclass>
Here's an example of the override script from above. The original file in CoreRPG had 3 functions, but I'm only changing one. So I call the relevant super function from within the same function name (and arguments) within my new custom file:
Code:function setItemRecordType(sRecordType) if super and super.setItemRecordType then super.setItemRecordType(sRecordType); end end function setItemClass(sDisplayClass) if super and super.setItemClass then super.setItemClass(sDisplayClass); end end function setColumnInfo(aColumns, nDefaultColumnWidth) ... all of the custom code here, so no super call... end
So, in this script I'm overriding one function and keeping the original ones by calling them. The issue you may have in the long run is if the original script at some point adds extra functions or calls functions within it's own super scope.
Note: it's possible to have more than two levels if an extension modifies a windowclass/control script that is already layered on top of CoreRPG - you now have 3 layers! And each layer can access the previous one via super.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!
-
June 4th, 2020, 19:02 #3
OK, that looks like it could be a lot of work.
I'll take a little time and get my head around that.
All this 'cos I wanted to add some checkboxes to the combat tracker :P
Thanks for the info Trenloe.
Cheers, Steve.
-
June 4th, 2020, 19:19 #4
And just to make sure I have this right....
In 5e, ct_entry.lua is referenced in 2 files : ct_host.xml and ct_client.xml.
I would need to add in the reference to my new lua file with a merge="join" in 2 replacement files (one for ct_host, and one for ct_client)
Then use 'super' calls in my new ct_entry.lua file for functions I'm not changing, and re-write the functions I need to edit.
Hope that's the gist of it, and thanks again for your help.
Cheers, Steve.
-
June 4th, 2020, 19:34 #5
Yep, that's it.
If you're really clever, you could even call the super function of the function you're changing - and just include the code you need to change in your custom function - either before or after the super call. Sometimes it's not possible, but sometimes it is...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!
-
June 4th, 2020, 19:38 #6Oh thanks,
Just as I thought I had it straight in my head you come up with something else :P
Seriously though, thank you again. I'll buy you a pint next time I'm in Newcastle ^^
Cheers, Steve.Last edited by Stv; June 4th, 2020 at 19:40.
-
June 5th, 2020, 10:24 #7
Hi again Trenloe :P
I am once again in need of some assistance.
I've setup my extension to point to my new instance of ct_host.xml, which it does fine.
In my new version, if I just copy the entirety of the xml file into my new one everything works fine (as I'd expect it to).
But when I add the 'merge ="join"' to the windowclass definition strange things occur, like the small reaction button on the character sheet stops working.
Any idea why ?
Cheers, Steve.
-
June 5th, 2020, 10:43 #8
It could be a bubnch of things.
Please post your ct_host.xml and the ct_entry.lua file that you've created/modified.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!
-
June 5th, 2020, 11:00 #9
Test extension
I've attached all the files for brevity Trenloe, hope that's ok.
If you run this ext you'll see that the react button doesn't work.
But it will if you remove the merge="join" tag in the XML file.
Thanks for looking.
Cheers, Steve.
-
June 5th, 2020, 11:27 #10
Thanks for the extension, that helped a lot.
Like I mentioned in post #2 - if all you're doing is custom code in the attached <script> file, then you just need a "stub" windowclass to call the custom script file. My example code in post #2 is all you need.
In your example, new_ct_host.xml should just be:
Code:<root> <windowclass name="ct_entry" merge="join"> <script file="ct/scripts/new_ct_entry.lua" /> </windowclass> </root>
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!
Thread Information
Users Browsing this Thread
There are currently 1 users browsing this thread. (0 members and 1 guests)
Bookmarks