mortgarra
April 10th, 2016, 21:48
I'm having a doosy of a time trying to figure out how the extension database works.
I can't seem to get 'getDatabaseNode()' to ever return anything other than a nil value. The extension guide says "Value nodes are created automatically when a window containing value field controls is opened. They can also be created using the scripting interface. Each value node has a specific type."
I assume this means that databasenodes are tied to the window whenever a window with certain controls are rendered. It doesn't seem to be working for me and I've no idea what I'm doing wrong.
For reference, here's the entirety of a settings windowclass for an extension I'm writing. The onInit method prints 'nil' for getDatabaseNode();
<windowclass name="combat_timer_settings">
<margins control="0,0,0,0" />
<frame name="groupbox" offset="15,15,20,15" />
<placement>
<size width="275" height="300" />
<nosave />
</placement>
<datasource>.settings</datasource>
<script>
function onInit()
Debug.console("onInit - combat_timer_settings", getDatabaseNode());
end
function onClose()
Debug.console("onClose - combat_timer_settings");
end
</script>
<sheetdata>
<settings_title name="title" />
<anchor_timer_settings name="contentanchor" />
<label name="label_timer_type">
<anchored to="contentanchor" height="20">
<top anchor="bottom" relation="relative" offset="10" />
<left offset="0" />
<right offset="-80" />
</anchored>
<static text="Timer Type" />
</label>
<button_stringcycler name="timer_type">
<anchored>
<top parent="label_timer_type" offset="0" />
<bottom parent="label_timer_type" offset="0" />
<left parent="label_timer_type" anchor="right" offset="0" />
<right parent="contentanchor" offset="0" />
</anchored>
</button_stringcycler>
<label name="label_timer_start">
<anchored to="contentanchor" height="20">
<top parent="label_timer_type" anchor="bottom" relation="relative" offset="10" />
<left offset="0" />
<right offset="-80" />
</anchored>
<static text="Initial Timer Value" />
</label>
<numbercontrol name="timer_start">
<frame name="tokennumber" offset="0,0,0,0" />
<anchored width="30">
<top parent="label_timer_start" offset="0" />
<bottom parent="label_timer_start" offset="0" />
<left parent="label_timer_start" anchor="right" offset="0" />
</anchored>
<default>60</default>
<min>0</min>
<max>5999</max>
</numbercontrol>
<label name="label_report_times">
<anchored to="contentanchor" height="20">
<top parent="label_timer_start" anchor="bottom" relation="relative" offset="10" />
<left offset="0" />
<right offset="-80" />
</anchored>
<static text="Summarize Turns" />
</label>
<button_checkbox name="report_player_times">
<anchored to="contentanchor" width="10">
<top parent="label_report_times" offset="0" />
<bottom parent="label_report_times" offset="0" />
<left parent="label_report_times" anchor="right" offset="0" />
</anchored>
</button_checkbox>
<close_timer_settings />
</sheetdata>
<invisible />
</windowclass>
I can't seem to get 'getDatabaseNode()' to ever return anything other than a nil value. The extension guide says "Value nodes are created automatically when a window containing value field controls is opened. They can also be created using the scripting interface. Each value node has a specific type."
I assume this means that databasenodes are tied to the window whenever a window with certain controls are rendered. It doesn't seem to be working for me and I've no idea what I'm doing wrong.
For reference, here's the entirety of a settings windowclass for an extension I'm writing. The onInit method prints 'nil' for getDatabaseNode();
<windowclass name="combat_timer_settings">
<margins control="0,0,0,0" />
<frame name="groupbox" offset="15,15,20,15" />
<placement>
<size width="275" height="300" />
<nosave />
</placement>
<datasource>.settings</datasource>
<script>
function onInit()
Debug.console("onInit - combat_timer_settings", getDatabaseNode());
end
function onClose()
Debug.console("onClose - combat_timer_settings");
end
</script>
<sheetdata>
<settings_title name="title" />
<anchor_timer_settings name="contentanchor" />
<label name="label_timer_type">
<anchored to="contentanchor" height="20">
<top anchor="bottom" relation="relative" offset="10" />
<left offset="0" />
<right offset="-80" />
</anchored>
<static text="Timer Type" />
</label>
<button_stringcycler name="timer_type">
<anchored>
<top parent="label_timer_type" offset="0" />
<bottom parent="label_timer_type" offset="0" />
<left parent="label_timer_type" anchor="right" offset="0" />
<right parent="contentanchor" offset="0" />
</anchored>
</button_stringcycler>
<label name="label_timer_start">
<anchored to="contentanchor" height="20">
<top parent="label_timer_type" anchor="bottom" relation="relative" offset="10" />
<left offset="0" />
<right offset="-80" />
</anchored>
<static text="Initial Timer Value" />
</label>
<numbercontrol name="timer_start">
<frame name="tokennumber" offset="0,0,0,0" />
<anchored width="30">
<top parent="label_timer_start" offset="0" />
<bottom parent="label_timer_start" offset="0" />
<left parent="label_timer_start" anchor="right" offset="0" />
</anchored>
<default>60</default>
<min>0</min>
<max>5999</max>
</numbercontrol>
<label name="label_report_times">
<anchored to="contentanchor" height="20">
<top parent="label_timer_start" anchor="bottom" relation="relative" offset="10" />
<left offset="0" />
<right offset="-80" />
</anchored>
<static text="Summarize Turns" />
</label>
<button_checkbox name="report_player_times">
<anchored to="contentanchor" width="10">
<top parent="label_report_times" offset="0" />
<bottom parent="label_report_times" offset="0" />
<left parent="label_report_times" anchor="right" offset="0" />
</anchored>
</button_checkbox>
<close_timer_settings />
</sheetdata>
<invisible />
</windowclass>