5E Product Walkthrough Playlist
Page 1 of 4 123 ... Last

Thread: getValue() help

  1. #1

    Join Date
    Apr 2008
    Location
    Virginia Beach
    Posts
    3,096

    getValue() help

    I have the following control definition (PF ruleset):

    Code:
    	<template name="button_export">
    		<button_text_sm>
    			<anchored to="buttonanchor" width="50">
    				<top />
    				<left anchor="right" relation="relative" offset="5" />
    			</anchored>
    			<state textres="export_button_templates" />
    <!--			<script file="export_table_generator.lua" />-->
    			<script>
    				function onButtonPress()
    					Debug.chat("value=",getValue());
    				end			
    			</script>
    		</button_text_sm>
    	</template>
    When I press the button in the window itself, I get the following console error:

    Script Error: [string "button_custom2"]:1: attempt to call global 'getValue' (a nil value)


    What am I missing?

  2. #2

  3. #3

    Join Date
    Apr 2008
    Location
    Virginia Beach
    Posts
    3,096
    damned, this is the script for the button I included the code for. That button uses a template that inherits directly from buttoncontrol. Here is an example of its use elsewhere in the CoreRPG 3.3.3 ruleset:

    Code:
    			<button_iedit name="list_iedit">
    				<anchored>
    					<left anchor="center" offset="-10" />
    					<bottom offset="-27" />
    				</anchored>
    				<gmvisibleonly />
    				<script>
    					function onValueChanged()
    						local bEdit = (getValue() == 1);
    						window.list_iimport.setVisible(bEdit);
    						window.list_iadd.setVisible(bEdit);
    						window.list.update();
    					end
    				</script>
    			</button_iedit>
    getValue is defined and should be in scope for anything that inherits from windowcontrol, which buttoncontrol does.

  4. #4

    Join Date
    Apr 2008
    Location
    Virginia Beach
    Posts
    3,096
    Trenloe or MW OR Celestian maybe? What am I doing wrong? Is there a compatibility setting or something that needs to be in my extension (there is a ruleset note to that effect but doesn’t discuss extensions in the documentation for getValue.
    Last edited by Bidmaron; November 5th, 2017 at 22:41.

  5. #5
    Not sure without seeing all templates used to build up the control. Maybe post a link to files, or PM/email?

    One clarification, getValue is not part of windowcontrol object. It is specifically part of stringcontrol, numbercontrol, buttoncontrol, windowreferencecontrol, and formattedtextcontrol. It does not exist in other window control types, such as genericcontrol or windowlist.

    Regards,
    JPG

  6. #6

    Join Date
    Apr 2008
    Location
    Virginia Beach
    Posts
    3,096
    MW, attached is my complete xml file for all my controls. I can from the onButtonPress access getName, but I cannot get to anything associated with buttonControl, which the template I am invoking on my control inherits from. That is why I was wondering whether there was a compatibility problem as the buttonControl docs seem to indicate (v3.0 compatibility or higher).

    Code:
    <?xml version="1.0" encoding="iso-8859-1"?>
    
    <!-- 
      Template and interface materials for generators.
    -->
    
    <root>
    	<!-- Icon resources -->
    	<icon name="button_generators" file="button_generators.png" />
    	<!-- General -->
    	<template name="button_generators">
    		<button_text_sm>
    			<anchored to="buttonanchor" width="80">
    				<top />
    				<left anchor="right" relation="relative" offset="5" />
    			</anchored>
    			<state textres="generator_button_templates" />
    			<script>
    				function onButtonPress()
    					Interface.openWindow("masterindex", "generators");
    				end
    			</script>
    		</button_text_sm>
    	</template>
    	<template name="button_import">
    		<button_text_sm>
    			<anchored to="buttonanchor" width="50">
    				<top />
    				<left anchor="right" relation="relative" offset="5" />
    			</anchored>
    			<state textres="import_button_templates" />
    			<script file="import_table_generator.lua" />
    		</button_text_sm>
    	</template>
    	<template name="button_export">
    		<button_text_sm>
    			<anchored to="buttonanchor" width="50">
    				<top />
    				<left anchor="right" relation="relative" offset="5" />
    			</anchored>
    			<state textres="export_button_templates" />
    <!--			<script file="export_table_generator.lua" />-->
    			<script>
    				function onButtonPress()
    				Debug.chat("in onButtonPress");
    					Debug.chat("name=",getName());
    				end			
    			</script>
    		</button_text_sm>
    	</template>
    	<template name="line_button_export">
    		<buttoncontrol>
    			<anchored to="rightanchor">
    				<top />
    				<right anchor="left" relation="absolute" offset="-5" />
    			</anchored>
    			<anchored width="20" height="20" />
    				<icon normal="button_export" pressed="button_export_down" />
    				<tooltip textres="tabselect_tooltip_export" />
    				<script>
    					function onButtonPress()
    						TableManager.exportTabGen(window.getDatabaseNode());
    					end
    				</script>
    		</buttoncontrol>
    	</template>
    	<!-- Window Declarations -->
    	<windowclass name="generator">
    		<frame>recordsheet</frame>
    		<placement>
    			<size width="400" height="400" />
    		</placement>
    		<sizelimits>
    			<minimum width="400" height="400" />
    			<dynamic />
    		</sizelimits>
    		<minimize>minimized_utility</minimize>
    		<nodelete />
    		<playercontrol />
    		<sharable />
    		<tooltip field="name" />
    		<script>
    			function onLockChanged()
    				if header.subwindow then
    					header.subwindow.update();
    				end
    				if main.subwindow then
    					main.subwindow.update();
    				end
    
    				local bReadOnly = WindowManager.getReadOnlyState(getDatabaseNode());
    				notes.setReadOnly(bReadOnly);
    			end
    		</script>
    		<sheetdata>
    			<sub_record_header name="header">
    				<class>table_header</class>
    			</sub_record_header>
    
    			<frame_record_content_tabbed name="contentframe" />
    
    			<subwindow_record name="main">
    				<class>table_main</class>
    				<script>
    					function onDrop(x, y, draginfo)
    						return subwindow.onDrop(x, y, draginfo);
    					end
    				</script>
    			</subwindow_record>
    			<ft_record name="notes">
    				<anchored to="contentframe">
    					<top />
    					<left offset="10" />
    					<right />
    					<bottom />
    				</anchored>
    				<empty textres="ft_empty" hidereadonly="true" />
    				<invisible />
    			</ft_record>
    
    			<scrollbar_record>
    				<target>main</target>
    			</scrollbar_record>
    			<scrollbar_record>
    				<target>notes</target>
    			</scrollbar_record>
    
    			<tabs_recordsheet>
    				<tab>
    					<icon>tab_main</icon>
    					<subwindow>main</subwindow>
    				</tab>
    				<tab>
    					<icon>tab_notes</icon>
    					<subwindow>notes</subwindow>
    				</tab>
    			</tabs_recordsheet>
    			
    			<resize_recordsheet />
    			<close_recordsheet />
    		</sheetdata>
    	</windowclass>
    
    </root>
    The control where I cannot use getValue is buttonExport. Note the version above uses getName, which works, but getValue does not. Note that button_text_sm inherits directly from buttonControl, which SHOULD provide getValue.

  7. #7

    Join Date
    Apr 2008
    Location
    Virginia Beach
    Posts
    3,096
    Also, note that the example I show from a built-in edit button clearly has getValue working, so something is amiss, and I cannot find anything on a compatibility flag, if that is the problem.

  8. #8
    Looking at the button_export template, I don't see anything that stands out. (as long as button_text_sm template is not being overriden) Also, any scripts that have a getValue function will override the default getValue control function.

    Can you send me an example extension where this is not working?
    It will be the easiest way for me to dissect the issue.

    Thanks,
    JPG

  9. #9

    Join Date
    Apr 2007
    Location
    Mississippi, USA
    Posts
    1,097
    You might try:

    self.getValue();
    super.getValue();

    https://www.fantasygrounds.com/wiki/...pt_Block_Scope
    Last edited by lokiare; November 6th, 2017 at 11:49. Reason: Added link

  10. #10

    Join Date
    Apr 2008
    Location
    Virginia Beach
    Posts
    3,096
    Thanks, Iocaire, but what I am trying to convey is that this isn't an inheritance/override issue. This is an issue where calls to built-in stuff is not working. I think it may have something to do with the documentation for these calls (note what is in red), and that there is some kind of compatibility flag I need to set but cannot figure out how to do that.

    Code:
    getValue
    
    
    function getValue( )
    Note: Only available for rulesets with compatibility mode v3.0 or higher.
    
    Retrieves the value of the control.
    
    Return values
    
    (number)
    The value contained in the control
    MW, that is not what is going on. Please see my complete extension attached.

    Steps to recreate the problem:
    1. Start up FG with only this extension loaded in a CoreRPG-based campaign.
    2. Click the Tables sidebar icon.
    3. Click the Generators button at top. This opens the Generators window.
    4. Click the export button at top of Generators window. You will get a debug message in chat window showing the name of the export button control.
    5. Edit the button_export template in the Generators.xml file under the onButtonPress event handler to say ' Debug.chat("value=",getValue());'
    6. Reload ruleset and repeat steps 1-4. Now you will get the console error:

    Runtime Notice: Reloading ruleset
    Script Error: [string "button_custom2"]:1: attempt to call global 'getValue' (a nil value)


    So, the getName call from windowcontrol works (inherited from buttoncotntrol through the button_text_sm template), but the getValue call from buttoncotntrol does not (inherited through the button_text_sm template declared in the CoreRPG ruleset file common\template_buttons.xml).
    Attached Files Attached Files

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
  •  
Starfinder Playlist

Log in

Log in