DICE PACKS BUNDLE
Page 1 of 2 12 Last
  1. #1
    GKEnialb's Avatar
    Join Date
    Jul 2017
    Location
    Castle Rock, CO
    Posts
    515

    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>
    to

    Code:
    		
    <template name="image_record_step">
       <imagecontrol name="image" merge="join">
          <script file="campaign/scripts/image.lua" />
       </imagecontrol>
    </template>
    I didn't have any such error reports before that switch or for a couple builds after it, but can't think of what else it would be. The change was made because making the map full screen/"sending to background" would revert to the original image.lua for some reason.

  2. #2
    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

  3. #3
    GKEnialb's Avatar
    Join Date
    Jul 2017
    Location
    Castle Rock, CO
    Posts
    515
    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?

  4. #4
    Quote Originally Posted by GKEnialb View Post
    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?
    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.

  5. #5
    GKEnialb's Avatar
    Join Date
    Jul 2017
    Location
    Castle Rock, CO
    Posts
    515
    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>
    or

    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>
    or something completely different? I can definitely see why the template idea was desirable.
    Last edited by GKEnialb; May 14th, 2021 at 16:53.

  6. #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.

  7. #7
    GKEnialb's Avatar
    Join Date
    Jul 2017
    Location
    Castle Rock, CO
    Posts
    515
    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.

  8. #8
    Quote Originally Posted by GKEnialb View Post
    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.
    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>
    I've seen global packages go missing before too, not sure why that happens. For me it's usually DB that is missing.

    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.

  9. #9
    You have to use the sheetdata tag when merging controls on a windowclass.

    Regards,
    JPG

  10. #10
    GKEnialb's Avatar
    Join Date
    Jul 2017
    Location
    Castle Rock, CO
    Posts
    515
    Quote Originally Posted by Moon Wizard View Post
    You have to use the sheetdata tag when merging controls on a windowclass.

    Regards,
    JPG
    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>
    That's what threw the exception...

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
5E Product Walkthrough Playlist

Log in

Log in