1. #1

    button_stringcycler nil error

    So I'm trying to write an extension for Numenera that involves a button_stringcycler placed in a window on the desktop. When I try to run the campaign with my extension enabled, I receive the following error:

    Script Error: [string "common/scripts/button_stringcycler.lua"]:74: attempt to index local 'node' (a nil value)

    I've looked at the code for button_stringcycler and it seems its having a problem retrieving the database node from the window object. Am I not able to use this widget from within the desktop_classes.xml file, or have I simply set something up wrong?

    desktop_classes.xml
    Code:
    <?xml version="1.0" encoding="iso-8859-1"?>
    
    <!-- 
      Please see the license.html file included with this distribution for 
      attribution and copyright information.
    -->
    
    <root>
    	<windowclass name="ct_stat_roll">
    		<sizelimits>
    			<minimum width="110" height="57" />
    		</sizelimits>
    
    		<noclose />
    		<nodrag />
    		<nodrop />
    
    		<script>
    			function onInit()
    				CtStatRoll.registerControl(self)
    			end
    			
    			function onClose()
    				CtStatRoll.registerControl(nil)
    			end
    		</script>
    
    		<sheetdata>
    			<anchor_column name="columnanchor" />
    
    			<genericcontrol name="base">
    				<bounds>5,5,180,52</bounds>
    				<icon>stat_roll</icon>
    			</genericcontrol>
    			
    			<button_stringcycler name="type">
    				<anchored width="70" height="20">
    					<top parent="columnanchor" anchor="bottom" offset="22" />
    					<left parent="columnanchor" anchor="left" offset="23" />
    				</anchored>
    				<parameters>
    					<labelsres>char_label_might|char_label_speed|char_label_intellect</labelsres>
    					<values>might|speed|intellect</values>
    					<defaultlabel>-</defaultlabel>
    				</parameters>
    				<tooltip textres="char_tooltip_stat" />
    			</button_stringcycler>
    
    			<numbercontrol name="effort">
    				<anchored width="42" height="22">
    					<top parent="columnanchor" anchor="bottom" offset="22" />
    					<left parent="columnanchor" anchor="left" offset="103" />
    				</anchored>
    				<font>modcollector</font>
    				<default>0</default>
    			</numbercontrol>
    
    			<button_roll name="statroll">
    				<anchored width="42" height="22">
    					<top parent="columnanchor" anchor="bottom" offset="22" />
    					<left parent="columnanchor" anchor="left" offset="133" />
    				</anchored>
    				<script>
    					function action(stat, effort)
    						CypherStatRolls.rollSkill(stat, effort);
    					end
    
    					function onButtonPress(x, y)
    						local stat = CtStatRoll.getType()
    						local effort = CtStatRoll.getEffort()
    						
    						if stat == nil then
    							return false
    						end
    
    						action(stat, effort)
    						return true
    					end
    				</script>
    			</button_roll>
    		</sheetdata>
    	</windowclass>
    </root>
    Last edited by bojjenclon; November 20th, 2019 at 03:52.

  2. #2
    Trenloe's Avatar
    Join Date
    May 2011
    Location
    Denver, Colorado, USA (for a bit)
    Posts
    24,129
    Looking at the file that raises the error (in the CoreRPG ruleset) - the error is caused by line 74, which tries to use the node variable which is set in the previous line (line 73): local node = window.getDatabaseNode();

    This code (window.getDatabaseNode) is trying to get the database node that the Window is tied to - the window is the control container, which in this case is the desktop panel. Desktop panels don't have a datasource - see here: https://www.fantasygrounds.com/refdoc/panel.xcp Hence why this is failing.

    You may be able to specify a <datasource> within your <windowclass> specification: https://www.fantasygrounds.com/refdoc/windowclass.xcp I don't know if this will work, I haven't tried this. EDIT: If it doesn't work, then you may have to use different controls. See here for a note regarding not using controls linked to the database in windows without a data source: https://www.fantasygrounds.com/refdo...asecontrol.xcp

    Here's an example of a desktop panel with controls that aren't sourced on the database, it uses LUA code to store their values in the database: https://www.fantasygrounds.com/forum...l=1#post387852
    Last edited by Trenloe; November 20th, 2019 at 04:24. Reason: Added info about database control used in windows without a data source.
    FG Con 15 Fantasy Grounds Online RPG Convention - Nov. 8-10, 2019
    Register at www.fg-con.com for all the latest info.

    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!

  3. #3
    Thanks for the reply! I wasn't able to get datasource to work so I've switched to using a combobox instead, which is working fine.

Thread Information

Users Browsing this Thread

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

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  

Log in

Log in