-
May 13th, 2021, 02:39 #1
Functions from image.lua disappearing
I override a few functions in image.lua in my token height extension (https://www.fantasygrounds.com/forum...ight-Indicator). Everything typically works just fine, but a couple of users have found that the functions that I don't override "disappear" at some point into their session (even when not changing maps). By "disappear", I mean a call in my extension to getGridSide() starts becoming a nil value and a call to onDrop() outside of my extension becomes a nil value.
Not sure if this is relevant, but a few builds ago I changed the overriding in extension.xml from
Code:<windowclass name="imagewindow" merge="join"> <sheetdata> <image_record name="image"> <script file="campaign/scripts/image.lua" /> </image_record> </sheetdata> </windowclass>
Code:<template name="image_record_step"> <imagecontrol name="image" merge="join"> <script file="campaign/scripts/image.lua" /> </imagecontrol> </template>
-
May 13th, 2021, 04:32 #2
Supreme Deity
- Join Date
- Mar 2007
- Posts
- 20,541
Not sure what is going on; but a couple thoughts.
* Templates do not support merging; so if you re-specify a template, you are overriding completely.
* "image.lua" in CoreRPG is only referenced by template; so overriding that template would prevent the base script from being loaded.
Regards,
JPG
-
May 14th, 2021, 03:50 #3
Thanks. I can switch back to the original. Any idea why making the map full screen or sending to back would cause image.lua to no longer being overridden?
-
May 14th, 2021, 11:55 #4
because each of those have different windowclass names: imagebackpanel and imagefullpanel need to get your changes as well. before I changed from imagewindow to the template override, I had started to do that but the template approach seemed smarter. this is a really important lesson to have learned though and explains some other things I have seen.
Last edited by bmos; May 14th, 2021 at 12:00.
bmos' extensions
he/them
-
May 14th, 2021, 16:43 #5
Thanks. I'll add those two in.
Actually, one question on that before I confuse things more.
Would I replace imagewindow with imagebackpanel or image with imagebackpanel?
So
Code:<windowclass name="imagewindow" merge="join"> <sheetdata> <image_record name="image"> <script file="campaign/scripts/image.lua" /> </image_record> </sheetdata> </windowclass> <windowclass name="imagebackpanel" merge="join"> <sheetdata> <image_record name="image"> <script file="campaign/scripts/image.lua" /> </image_record> </sheetdata> </windowclass> <windowclass name="imagefullpanel" merge="join"> <sheetdata> <image_record name="image"> <script file="campaign/scripts/image.lua" /> </image_record> </sheetdata> </windowclass>
Code:<windowclass name="imagewindow" merge="join"> <sheetdata> <image_record name="image"> <script file="campaign/scripts/image.lua" /> </image_record> <image_record name="imagebackpanel"> <script file="campaign/scripts/image.lua" /> </image_record> <image_record name="imagefullpanel"> <script file="campaign/scripts/image.lua" /> </image_record> </sheetdata> </windowclass>
Last edited by GKEnialb; May 14th, 2021 at 16:53.
-
May 15th, 2021, 03:30 #6
The first one should work.
Too bad templates don't allow merges; at first glance it was a much cleaner approach.
If you want to keep extension.xml from looking too busy, you could move those windowclass changes into an xml file.bmos' extensions
he/them
-
May 15th, 2021, 17:29 #7
Hmmm. That didn't work. When loading the 5E ruleset, an error is thrown on line 14 on image.lua: "attempt to call field 'onCursorModeChanged' (a nil value)" -- must be in that ruleset as there is no 'onCursorModeChanged' call made in my image.lua.
On another bizarre thing, apparently when the functions disappeared in the previous version, it wasn't just the image functions - "Debug" disappeared as well.
-
May 15th, 2021, 18:00 #8
perhaps this?
Code:<windowclass name="imagewindow" merge="join"> <script file="campaign/scripts/image.lua" /> </windowclass> <windowclass name="imagebackpanel" merge="join"> <script file="campaign/scripts/image.lua" /> </windowclass> <windowclass name="imagefullpanel" merge="join"> <script file="campaign/scripts/image.lua" /> </windowclass>
EDIT: looks like I'm wrong. Basically the format should be whatever you had before I suggested the template approach (but you should duplicate it for the other windowclasses as well).Last edited by bmos; May 15th, 2021 at 19:01.
bmos' extensions
he/them
-
May 15th, 2021, 18:12 #9
Supreme Deity
- Join Date
- Mar 2007
- Posts
- 20,541
You have to use the sheetdata tag when merging controls on a windowclass.
Regards,
JPG
-
May 16th, 2021, 02:02 #10
Thanks. Should this have worked, then?
Code:<windowclass name="imagewindow" merge="join"> <sheetdata> <image_record name="image"> <script file="campaign/scripts/image.lua" /> </image_record> </sheetdata> </windowclass> <windowclass name="imagebackpanel" merge="join"> <sheetdata> <image_record name="image"> <script file="campaign/scripts/image.lua" /> </image_record> </sheetdata> </windowclass> <windowclass name="imagefullpanel" merge="join"> <sheetdata> <image_record name="image"> <script file="campaign/scripts/image.lua" /> </image_record> </sheetdata> </windowclass>
Thread Information
Users Browsing this Thread
There are currently 1 users browsing this thread. (0 members and 1 guests)
Bookmarks