FG Spreadshirt Swag
  1. #1

    Overriding WindowClass instance attributes from LUA

    Hi,

    is it possible to change some attributes (e.g. title) of the Window instance from within LUA? Since the change should be dynamic, I do not want to create separate new window templates.

    Here is an example of what I am trying to do:

    Code:
    	<windowclass name="some_window_class" merge="join">
    		<script>
    			function onInit()
    				Debug.chat("  onInit() called");
    				
    				
    				------     I would like to change the title of this window instance (depending on some logic)
    				
    				
    			end
    		</script>
    	</windowclass>
    Thank you in advance

  2. #2
    Well, first, you need to call any base window onInit call. Then, it depends on the window class and templates/names being used for that ruleset.

    For most windows in the 5E ruleset (but not all), it could be as simple as:
    Code:
        function onInit()
            if super and super.onInit then
                super.onInit();
            end
            title.setValue("My Custom Window Title");
        end
    Regards,
    JPG

  3. #3
    Amazing, this works perfectly.

    However now I am stuck trying to access subwindow elements of the current window.

    EDIT: Figured it out myself: elements of subwindow can be accessed via in the case below "subwin.subwindow.element_name"

    Code:
    	<windowclass name="main_window_class">
    		<sheetdata>
    			<subwindow_record name="subwin">
    				<class>subwindow_class</class>
    				<activate />
    				<fastinit />
    			</subwindow_record>
    		</sheetdata>
    	</windowclass>
    	
    	<windowclass name="subwindow_class">
    		<sheetdata>
    			<header_column name="element_name">
    				<static textres="text_to_be_changed" />
    				<center />
    			</header_column>
    		</sheetdata>
    	</windowclass>
    Last edited by xelab; September 2nd, 2022 at 01:48.

  4. #4
    This may help with a lot of your recent questions...

    https://forge.fantasygrounds.com/shop/items/358/view

    Jason

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