PDA

View Full Version : Assitance with Extension



Mgrancey
February 25th, 2014, 23:06
I am working on the Superpowers 2nd ed module, and am attempting to create an extension to create two objects like vehicle or npc for headquarters and powers or items for the rooms/features. I believe I have it mostly correct but don't know enough to be sure what is wrong. Currently getting two errors:

Script Error: [string "scripts/manager_desktop.lua"]:173: bad argument #1 to 'min' (number expected, got string)
Runtime Error: desktop: Unable to create window with invalid class (tab_rooms : tab_main)

The first is from something I changed that screwed up the sidebar, I did have it in the right spot but not working before.
I am not sure why it is trying to say 'tab_rooms' is an invalid class as it is only the icon for the sidetab.

Any help would be greatly appreciated.

Trenloe
February 26th, 2014, 00:44
If you check the function DesktopManager.registerDockShortcut that you are calling in your .LUA file, you'll find the following (in \scripts\manager_desktop.lua):

function registerDockShortcut(iconNormal, iconPressed, tooltipText, className, recordName, useSubdock, index)...

When it is called in the extension the code is:

DesktopManager.registerDockShortcut("button_hq", "button_hq_down", "headquarters", "tab_rooms", "tab_main", "sw_room_feature", "hq_main", "hq_rooms");

The error you are getting is that tab_rooms is an invalid class - from the above code it can be seen that "tab_rooms" is indeed being sent to the function as the "className" variable. FG is looking for a window class called "tab_rooms" which will be the window that will be opened when the button is pressed. Check desktop\scripts\desktop.lua for some examples of how to use DesktopManager.registerDockShortcut.

You're probably looking to use something like this:

DesktopManager.registerDockShortcut("button_hq", "button_hq_down", "Headquarters", "hq_list", "headquarters");

This will create the Dock shortcut with the button_hq button which will turn to button_hq_down when pressed. The tooltip to display if the mouse is hovered over will be "Headquarters" and if the button is pressed a window will be launched with the "hq_list" windowclass and it will be tied to the "headquarters" data in the campaign database.

Mgrancey
February 26th, 2014, 00:55
Ah, thanks, I tried looking for in the library but had been having connection issues and couldn't find it later.

Trenloe
February 26th, 2014, 01:02
Ah, thanks, I tried looking for in the library but had been having connection issues and couldn't find it later.
You won't find it in the library, DesktopManager is a ruleset specific package.

Mgrancey
February 27th, 2014, 14:55
So most of the way there with the Headquarters extension. 95ish% functional. So thank you very much for help.

6169

At this point there is really only a handful of things that need fixed/created:

Add new button is not working; right click -> create new is working though
For some reason the 'sheetlabelsmall' that are supposed to be above the numbers next HQ Points and Rooms, aren't appearing
Dropping NPCs into defences,
Creation of Minimized Icon for HQs, just need to create though base for those icons would be helpful
Creation of side label for Headquarters and fix font for Card, font is Fedora?
Putting headquarters above the Library card?


Any help that you can provide would again be greatly appreciated. It might be something simple I am missing it might not.

Trenloe
February 27th, 2014, 15:26
For some reason the 'sheetlabelsmall' that are supposed to be above the numbers next HQ Points and Rooms, aren't appearing

A very quick look at this, try changing your code:

<static>
<text>Used</text>
</static>
To Just the following (like you have in <stringcontrol name="hqPointsLabel"> for example):

<static>Used</static>

Also, as you're using the "Above" anchor, this determines both edges of the anchor - see the section "Using the anchoring shorthand notation" here: https://www.fantasygrounds.com/modguide/windowing.xcp As these controls has it's width already defined by the "Above" anchor it is ignoring the <width> command used and will cut short some text. Keep a console window open (type /console in the chat window) and you will see a few warnings about width being ignored.

Also, I notice that the stringcontrol name="availHqPointsLabel" is used more than once - make sure that names are unique.

Quick feedback on one of your issues! :)

Trenloe
February 27th, 2014, 15:38
Add new button is not working; right click -> create new is working though
This is because the hq_list window was launched without a class assigned to it - this is done in the DesktopManager.registerDockShortcut command. If you use the one I suggest in post #2 it will work OK.

You will then need to change the <datasource> for the headquarters list from .headquarters to just . otherwise you will get DB entries of headquarters.headquarters. Make sure your list has as the following:


<list_campaign name="list">
<datasource>.</datasource>
<class>hq_small</class>

Trenloe
February 27th, 2014, 15:49
Putting headquarters above the Library card?
The definition of registerDockShortcut(iconNormal, iconPressed, tooltipText, className, recordName, useSubdock, index) has a 7th argument of "index" - this is the position to put the dock shortcut in. So, if you use:

DesktopManager.registerDockShortcut("button_hq", "button_hq_down", "Headquarters", "hq_list", "headquarters", nil, 8);
This will put the Headquarters shortcut in the 8th slot down in the sidebar.

Mgrancey
February 27th, 2014, 21:37
Yep, removing the size tags made the difference, I did have it only <static>used</static>, but looking it up in library said it was supposed to be <static><text>, and thanks for catchng that repeat name, thought I had changed it.