View Full Version : Error with iadd
damned
May 22nd, 2016, 06:12
Hi team,
I have added a new campaign tool called CAS (Command Line Attributes and Skills) for MoreCore. It will allow you to have a library of drag n drop skills / attributes / rolls for use with systems being played on top of MoreCore. Im totally fudging my way thru here but I have the button, the window, the list of skills. I can right click in the window and add a new CAS entry but when I use the iadd button I get an error:
Script Error: [string "campaign/cas_button_new.lua"]:8: attempt to index a nil value
14133
I took code from campaign_button_new.lua and template_campaign.xml.
iadd button xml
<template name="button_iadd_cas">
<button_iadd_campaign>
<script file="campaign/cas_button_new.lua" />
</button_iadd_campaign>
</template>
cas_button_new.lua
--
-- Please see the license.html file included with this distribution for
-- attribution and copyright information.
--
function onButtonPress()
if User.isHost() then
local node = window.getDatabaseNode().createChild();
if node then
local w = Interface.openWindow(class[1], node.getNodeName());
if w and w.name then
w.name.setFocus();
end
end
else
local nodeWin = window.getDatabaseNode();
if nodeWin then
Interface.requestNewClientWindow(class[1], nodeWin.getNodeName());
end
end
window.list_iedit.setValue(0);
end
I believe that the window.getDatabaseNode() is not getting a value and this is the cause of the error... but I cant see why this is happening...
Line 8 is:
local node = window.getDatabaseNode().createChild();
Any suggestions?
Happy to post a dropbox link to the whole ruleset...
damned
May 22nd, 2016, 07:23
Not an answer to my question above but I just added the ability to export these rolls to a module as part of the inbuilt /export command/utility.
I probably need to change the window to use campaignlistwithtabs instead of the current one but that will have to come later.
14135
But in other news - I still need help with the iadd button if anyone has any ideas...
damned
May 22nd, 2016, 12:09
Tabs are also working now.
14136
But still not the other thing.... :(
Zacchaeus
May 22nd, 2016, 12:47
I think you'll need a Moon Wizard :)
MadBeardMan
May 22nd, 2016, 13:13
Hi Chap,
Just fired an email off. If you're struggling - chuck me the ruleset and when I finish being 'Dad' for this afternoon, I'll take a butchers.
Cheers
damned
May 22nd, 2016, 13:35
As I get a Nil result on the window.getDatabaseNode() I think my issue is happening earlier.
Going back to the campaign_cas.xml (new) file where the cas_button_new.lua is being called from Im pretty sure that it wasnt getting the getDatabaseNode() there either as I have specified it manually to get it to work... <datasource>clilist</datasource>
campaign_cas.xml
<?xml version="1.0" encoding="iso-8859-1"?>
<!--
Please see the license.html file included with this distribution for
attribution and copyright information.
-->
<root>
<template name="button_iadd_cas">
<button_iadd_campaign>
<script file="campaign/cas_button_new.lua" />
</button_iadd_campaign>
</template>
<windowclass name="cassmall">
<margins control="0,0,0,2" />
<!-- come back and fix!!! <script file="campaign/scripts/campaign_list_record.lua" /> -->
<sheetdata>
<!-- Create Left Anchor -->
<genericcontrol name="leftanchor">
<anchored height="0" width="0">
<top offset="2" />
<left />
</anchored>
</genericcontrol>
<!-- Create Right Anchor -->
<genericcontrol name="rightanchor">
<anchored height="0" width="0">
<top offset="2" />
<right />
</anchored>
</genericcontrol>
<!-- Add Shortcut Button for use with Libraries or to store info -->
<linkfield name="shortcut">
<anchored to="leftanchor" width="20" height="20">
<top />
<left anchor="right" relation="relative" offset="4" />
</anchored>
<class>ref_attributes</class>
<description field="name" />
<readonly />
</linkfield>
<!-- Create Field to hold the Roll Info -->
<simplestring name="name">
<readonly />
<anchored position="insidetopleft" offset="0,0" height="20">
<left parent="leftanchor" anchor="right" relation="relative" offset="8" />
</anchored>
<script>
function onEnter()
return true;
end
function onDeleteUp()
if isReadOnly() then
return;
end
end
</script>
</simplestring>
<button_idelete name="idelete">
<anchored>
<top />
<right parent="rightanchor" anchor="left" relation="relative" offset="-2" />
</anchored>
</button_idelete>
</sheetdata>
</windowclass>
<windowclass name="caslist">
<frame>campaignlistwithtabs</frame>
<placement>
<size width="300" height="400" />
</placement>
<sizelimits>
<minimum width="300" height="400" />
<dynamic />
</sizelimits>
<softclose />
<nodelete />
<sheetdata>
<banner_campaign>
<icon>title_cas</icon>
</banner_campaign>
<list_campaign_nofilter name="list">
<datasource>clilist</datasource>
<class>cassmall</class>
<script>
function onDrop(x, y, draginfo)
if draginfo.isType("shortcut") then
return CampaignDataManager.handleDrop("cassmall", draginfo);
end
end
</script>
</list_campaign_nofilter>
<scrollbar_list />
<anchor_campaign_nofilter />
<button_iedit_campaign>
<script>
function onInit()
setVisible(true);
end
</script>
</button_iedit_campaign>
<button_iadd_cas>
<class>cassmall</class>
</button_iadd_cas>
<categories>
<targetcontrol>list</targetcontrol>
</categories>
<resize_campaignlistwithtabs />
<close_campaignlist />
</sheetdata>
</windowclass>
</root>
So Ive messed up something further back... hrmmmm....
damned
May 22nd, 2016, 14:57
Ok a bit more info for anyone that may look at this while I sleep...
I added the db node clilist in desktop.lua using:
function registerPublicNodes()
if User.isHost() then
DB.createNode("options").setPublic(true);
DB.createNode("partysheet").setPublic(true);
DB.createNode("calendar").setPublic(true);
DB.createNode("combattracker").setPublic(true);
DB.createNode("modifiers").setPublic(true);
DB.createNode("effects").setPublic(true);
DB.createNode("clilist").setPublic(true);
end
end
I added the campaign tool button in desktop.lua using:
DesktopManager.registerStackShortcut2("button_cas", "button_cas_down", "sidebar_tooltip_cas", "caslist");
Created the file campaign_cas.xml with the following templates and windowclasses
<template name="button_iadd_cas">
<windowclass name="cassmall">
<windowclass name="caslist">
And from there on we go back up to the posts at the start of this thread.
Ruleset is here: https://www.dropbox.com/s/yovjrz7c68dvf63/MoreCore.pak?dl=0
Basic, basic dataset here: https://www.dropbox.com/s/gmccywjsrflte5c/MoreCoreRuleset.zip?dl=0
How to recreate error:
Create a new MoreCore campaign or use MoreCoreRuleset campain.
Open console (/console)
Open CAS from Campaign Tools
Click Edit button and then Add
You will see the Nil result from Debug.console and the resultant FG error message.
Trenloe
May 22nd, 2016, 15:13
I added the campaign tool button in desktop.lua using:
DesktopManager.registerStackShortcut2("button_cas", "button_cas_down", "sidebar_tooltip_cas", "caslist");
You're missing the final parameter that specifies the databasenode to tie the "caslist" windowclass to. Use:
DesktopManager.registerStackShortcut2("button_cas", "button_cas_down", "sidebar_tooltip_cas", "caslist", "clilist");
MadBeardMan
May 22nd, 2016, 18:05
You're missing the final parameter that specifies the databasenode to tie the "caslist" windowclass to. Use:
DesktopManager.registerStackShortcut2("button_cas", "button_cas_down", "sidebar_tooltip_cas", "caslist", "clilist");
Hi Chap,
Does that fix his issue? As I'm almost done being Dad today (ie the kids can watch the TV now) so I can take a look.
Cheers
Trenloe
May 22nd, 2016, 20:06
Does that fix his issue?
It's fixes this issue, yeah.
MadBeardMan
May 22nd, 2016, 20:12
It's fixes this issue, yeah.
Cool - GJ chap. I need to read up on registerStackShortcuts I think then, just finally fixed an issue I have with dragging shortcuts in my Traveller Ruleset and dragging Equipment.....
Cheers
damned
May 22nd, 2016, 23:03
Thank you gentlemen - it does of course fix the issue.
Trenloe - I had started it earlier and didnt get it quite working and when I redid it the second time I copied the Options string in the desktop.lua instead of modifiers/tables/effects and of course Options doesnt use the last parameter. Thank you very much for your help and time.
It also means I can remove a redundant template and one include file as the default ones work as they should.
Powered by vBulletin® Version 4.2.1 Copyright © 2024 vBulletin Solutions, Inc. All rights reserved.