PDA

View Full Version : acceptDrop



Tenian
July 25th, 2008, 03:20
My latest query...

I have a class of magic items, in it is a windowlist defining the powers assoicated with the magic item.

I want to take my magic item class and drop it into the item container (the item_list class of adventure_items.xml).

The acceptDrop works great for transferring the basic fields, but it doesn't seem to work with windowlist.

Any ideas how to make this happen?

Foen
July 25th, 2008, 07:10
This is the subject of an earlier post here (https://www.fantasygrounds.com/forums/showthread.php?t=8294).

It is a messy subject, especially if you have any formatted text fields.

Stuart

Tenian
July 25th, 2008, 11:32
Forutnately the two lists I need to drop are simple. One is a list of stringfields, the other is a list of links. Neither are formattedtext.

Any chance you could provide some psuedo code of your solution? Either here or in the other thread is fine.

I've very little experience playing with event handlers (not that that will stop me!).

Foen
July 25th, 2008, 14:52
For relatively simple window classes, you need to abandon the acceptDrop tags in the target list, and implement onDrop instead. For a good example, take a look at the onDrop handler in combattracker.lua and the way it detects the type of window being dropped and invokes addNpc.

Within the onDrop (or your equivalent to addNpc) you can iterate through the list of powers and add them to the target list. There isn't any code like that in combattracker.lua, but it works like this:



for i,win in ipairs(source.powerlist.getWindows())
local newwin = target.powerlist.createWindow();
newwin.name.setValue(win.name.getValue());
end


Hope that gives you enough to go on, otherwise shout and I'll try to be a bit more specific.

Cheers

Stuart

Tenian
July 26th, 2008, 01:03
You got a bit ahead of me there.

I added an onDrop and that works:


function onDrop(x, y, draginfo)
if draginfo.isType("shortcut") then
local class, datasource = draginfo.getShortcutData();
local source = draginfo.getDatabaseNode();

if source and class == "referencemagicitem" then
local newentry = addMI(source);
end

return false;
end
end


Next I started work on my addMI function (it's all based off the combattracker so this is the same as addNPC)



function addMI(source)

-- Create a new NPC window to hold the data
local newentry = createWindow();
newentry.type.setValue("item");

newentry.link.setValue("item", source.getNodeName());
newentry.link.setVisible(true);

-- Name
newentry.name.setValue(source.getChild("name").getValue());
newentry.level.setValue(source.getChild("level").getValue());
end


That should create the item and set it's name and level values. Unfortunately when I run it the console throws back:

Script Error:[string "scripts/magicitem.lua"]:20: attempt to index field 'type' (a function value).

This corresponds to

newentry.type.setValue("item");

I thought maybe I had the wrong type, but I tried copying the line exactly (which just replaces item with npc. And it still fails with the same error.

If I remove everything except for the newentry.name.setValue line, the name is set..so I'm on the right track. I'm just not sure what exactly I'm doing wrong here.

Foen
July 26th, 2008, 06:29
It looks like you are further ahead than you think ;)

Within addMI, the function creates a new window in the target list (which you are doing) and then sets the values of each of the controls in that window either from scratch or by copying the values from source node.

You are getting errors because you are trying to set values for controls that don't exist in your window class (such as 'type' which is a combat tracker control used to distinguish player entries from NPC entries on the combat tracker). You can successfully set the value of the 'name' control, because you probably have such a control in your magic item window class.

The thing to bear in mind is that the source is a DB node, but the newentry object is a window, so you need to use slightly different semantics to access their properties:



newentry.name.setValue(source.getChild("name").getValue());


In fact, I nearly always use createChild() instead of getChild() because it won't throw an error if the source doesn't have that particular property.



newentry.name.setValue(source.createChild("name","string").getValue());


Hope that helps

Stuart

Tenian
July 26th, 2008, 17:03
It solves 1 problem, but just leads to another (as programming solutions tend to do).

I'm dropping a magic item onto a window list. The code I have populates the list entry, which has only 1 element, name. I want to populate the actual item you would get by opening the list entry.

The combat tracker seems to hold all it's data directly into the list element. While in what I am trying to do, the list element is merely a link to an item. The item is where I need to set everything.

Foen
July 26th, 2008, 17:07
The thing to do is grab hold of the database node for the new entry (newentry.getDatabaseNode()) and then populate that node along the lines of (field names made up):



newnode = newentry.getDatabaseNode();
newnode.createChild("name","string").setValue(source.createChild("name","string").getValue());
newnode.createChild("spelllevel","number").setValue(source.createChild("spelllevel","number").getValue());


That way, you populate the database even though the list entry only displays one field (name).

Cheers

Stuart

Tenian
July 26th, 2008, 22:47
It handles all the string and number fields. The formattedtext field is chokes on (but you have a post on how to fix that).

The big problem is now, I don't know how to do the lists. Do I have to recreate the nodes as they are in XML? Can I just copy the list using the code snippet you supplied above?
Neither seems to work but I'm probably just screwing something up :)

Foen
July 27th, 2008, 05:54
The code snippet in the earlier post assumed you were working with windows, not database nodes. It needs to be modified along the lines of:



local newlist = newnode.createChild("powerlist");
for k,powernode in pairs(source.createChild("powerlist").getChildren())
local newpowernode = newlist.createChild();
newpowernode.createChild("name","string").setValue(powernode.createChild("name","string").getValue());
end


You need to create a new database node for each power in the source node, and then programmatically copy the properties from each old node to each new node.

My previous post handles formatted text fields in the top-level object.

If you have formatted text fields in any of the embedded lists, you are truly out of luck, as there is no way to copy them programmatically and the acceptDrop default behaviour ignores embedded lists.

Stuart

Tenian
July 28th, 2008, 00:44
Well the two window lists now populate correctly. I'm still working on making the links from the one of the windowlists work but I have some ideas on that.

Tenian
July 28th, 2008, 17:26
Since I've been banging my head against getting the power links to work correctly. I decided to stop and work on something else for a while. Hoping the answer would come to me.

Anyhow, I decided to work on having the Item be able to drop onto the character's inventory sheet. It was all going so well. I located the inventory sheet drop handler, found the section of code that handles dropping other reference objects, and successfully added in items.

Now here's the rub, if I take an item directly from the module, drop it on the item box and then drag it to the sheet WITHOUT opening the item, the console pops up with some attempt to index a nil value errors. If I open the item first, then it drops with no errors.

I know one of the fields it is having issues with is weight. Weight is on the item sheet, but it doesn't get populated by dragging the magical effect (weight comes from the base item. A dagger that's Frost Weapon + 1 would have a lower weight than a Two Handed sword that has Frost Weapon + 1). I'm assuming I need to initialize the value somehow, maybe by activating the sheet's onInit() ?

Any ideas?

Foen
July 28th, 2008, 20:08
I think you must be trying to populate the new object in the sheet from the item using something like:

target.creatChild("weight","number").setValue(source.getChild("weight").getValue())

If the source doesn't have a weight property, this fails noisily. A better option is to use something like:

target.creatChild("weight","number").setValue(source.createChild("weight","number").getValue())

If the property already exists, it is used, otherwise it is created and ascribed a default value (zero for numbers, "" for strings).

Hope that helps

Stuart

Tenian
July 28th, 2008, 21:53
The addMI() function I wrote and tied to the onDrop handler to populate the itemlist was using that method, per an earlier post by you.

The onDrop code of the charsheet_inventory was not using that method. I modified it from

newwin.name.setValue(sourcenode.getChild("weight").getValue());
to

newwin.weight.setValue(sourcenode.createChild("weight","number").getValue());

and my error disappeared.

Foen
July 28th, 2008, 22:14
Glad to help!

Sounds like you are forging ahead on your project.

Stuart

Tenian
July 28th, 2008, 22:42
Yup there are only a few features (beyond some display tweaks which are easy, just tiresome) that I'm still trying to figure out.

1) The original object (referencemagicitem) has a list of powers associated with it. My onDrop/addMI() pair successfully copies the list. However the powers look like this:


<powers>
<id-001>
<name type="string">Power - At-Will</name>
<recharge type="string">At-Will</recharge>
<keywords type="string">Cold</keywords>
......
<link type="windowreference">
<class>powerdesc</class>
<recordname>powerdesc.itemFrostWeaponPower-At-Will@4E Players Handbook</recordname>
</link>
</id-001>
...
</powers>


addMI() copies this data with the following block:


--powerlist
if source.getChild("powers") then
local powernode = newnode.createChild("powers");
for key, val in pairs(source.getChild("powers").getChildren()) do
-- keys here are id-001,id-002 etc
-- vals are db nodes containing children that you need to parse through
local power1 = powernode.createChild(key);
for key2, val2 in pairs(val.getChildren()) do
-- keys here are links
-- values are leaf database nodes that contain the value
local power2 = power1.createChild(key2, type(val2.getValue()));
---step down one last level to get the link data
for key3, val3 in pairs(val2.getChildren()) do
local power3 = power2.createChild(key3, type(val3.getValue()));
power3.setValue(val3.getValue());
end
power2.setValue(val2.getValue());
end
end
end


Which is very similar to the properties code you helpd with, except it loops down 1 more level to get the elements within <link>

Unfortunately I can not create a windowreference that successfully ties to the link.

2) After dropping the referencemagicitem onto the itemlist, I now have an editable item. What I would like to do is to be able to drop a different class object (referenceweapon, referencearmor) onto the editable item and have it populate the relevant fields.

Tenian
July 29th, 2008, 00:41
I got weapon drops working. Armor is the same deal just different fields..so that should be no problem.

Here's an update (https://dnd-4e.blogspot.com/2008/07/magic-itemsthe-process-w-images-galore.html) of how it will actually work if you're interested.

Foen
July 29th, 2008, 06:34
On #1, I wouldn't normally iterate through getChildren unless it is a list I'm dealing with.

In pseudo-code:



Iterate 'oldpower' over the children of 'powers' in the source
newpower = new subnode of 'powers' in the target list
newpower.createChild("name","string").setValue(oldpower.createChild("name","string").getValue());
newpower.createChild("link","windowreference").setValue(oldpower.createChild("link","windowreference").getValue());
-- etc for each property in a power
end iteration


If the properties in a power aren't always present (maybe 'keywords' is an optional field), you could test for it first:



if oldpower.getChild("keywords") and oldpower.getChild("keywords").getValue()~="" then
newpower.createChild("keywords","string").setValue(oldpower.getChild("keywords").getValue());
end


Hope that helps

Stuart

Tenian
July 29th, 2008, 18:07
Remember powers look like this:


<powers>
<id-001>
<name type="string">Power - At-Will</name>
<recharge type="string">At-Will</recharge>
<keywords type="string">Cold</keywords>
......
<link type="windowreference">
<class>powerdesc</class>
<recordname>powerdesc.itemFrostWeaponPower-At-Will@4E Players Handbook</recordname>
</link>
</id-001>
...
</powers>


I put a print statement inside my copying loop that returns the key and it's value. Everything works fine...except for link.

link returns "powerdesc".

So I added some additional print statements. I was hoping to read the class and recordname out of the link node. Unfortunately, all I get is (null).

So I know the link doesn't work because the class and recordname aren't set, but I'm stuck on how to set them, or why they aren't available to begin with.

I'm stuck.

Foen
July 29th, 2008, 18:58
Hi Tenian

I think you should be copying the properties directly, not iterating through them. To turn my pseudo-code into real code:



--powerlist
if source.getChild("powers") then
local powernode = newnode.createChild("powers");
for key, oldpow in pairs(source.getChild("powers").getChildren()) do
-- key is id-001,id-002 etc
-- oldpow are db nodes containing children that you need to parse through
local newpow = powernode.createChild(key);
-- name
if oldpow.getChild("name") then
newpow.createChild("name","string").setValue(oldpow.getChild("name").getValue());
end
-- recharge
if oldpow.getChild("recharge") then
newpow.createChild("recharge","string").setValue(oldpow.getChild("recharge").getValue());
end
-- keywords
if oldpow.getChild("keywords") then
newpow.createChild("keywords","string").setValue(oldpow.getChild("keywords").getValue());
end
-- link
if oldpow.getChild("link") then
newpow.createChild("link","windowreference").setValue(oldpow.getChild("link").getValue());
end
end
end


The downside of this approach is that it isn't very flexible if you subsequently change the properties in the power database node, but that probably won't happen lightly.

An alternative method would be to create a general function to create a copy of an arbitrary database structure. I'll post the code for that when I get five minutes, but it uses recursion to deal with arbitrary depth.

Let me know how that goes.

Stuart

Foen
July 29th, 2008, 19:03
Hi Tenian

No sooner said than done: here is the general purpose node copying function.



function copyNode(source, targetlist)
-- creates a copy of the source node in the target list
local nodetype = source.getType();
if nodeType=="number" or nodeType=="string" or nodeType=="image" or nodeType=="dice" or nodeType=="windowreference" then
local newnode = targetlist.createChild(source.getName(),nodeType). setValue(source.getValue());
return;
end
-- copying formattedtext isn't supported
if nodeType=="formattedtext" then
-- create the node but don't bother trying to populate it
local newnode = targetlist.createChild(source.getName(),nodeType);
return;
end
-- unknown value?
if nodeType~="node" then
-- don't create anything. Should perhaps throw an error
return;
end
-- must be a complex node, we need to repeat the process on all child nodes.
local newlist = targetlist.createChild(source.getName());
for k,subnode in pairs(source.getChildren()) do
copyNode(subnode,newlist);
end
-- done
end


You can invoke this by modifying your existing code as follows:



--powerlist
if source.getChild("powers") then
local newlist = newnode.createChild("powers");
for key, oldpow in pairs(source.getChild("powers").getChildren()) do
copyNode(oldpow, newlist);
end
end


It should add arbitrary power nodes to the powers list, without hard-coding their structure. I haven't tried it out, so please let me know if it does the trick?

Cheers

Stuart

Tenian
July 29th, 2008, 22:05
Specifying the nodes directly worked. Your recursive node copy does not. It seems to choke on the fact that the nodetype comes back as node.

It seems to exit after this:


-- unknown value?
if nodeType~="node" then
-- don't create anything. Should perhaps throw an error
return;
end
-- must be a complex node, we need to repeat the process on all child nodes.


It doesn't produce any errors but nothing copies. Not even any of the string or number variables.

It would be great if it did work! I'll poke at it after I finish making the last part work.

Tenian
July 29th, 2008, 22:19
Actually in the specifying method..the link worked but nothing else did.

I went with a hybrid version of your link code on top of my child loop.



--powerlist
if source.getChild("powers") then
local powernode = newnode.createChild("powers");
for key, oldpow in pairs(source.getChild("powers").getChildren()) do
-- key is id-001,id-002 etc
-- oldpow are db nodes containing children that you need to parse through
local newpow = powernode.createChild(key);
for key2, val2 in pairs(oldpow.getChildren()) do
-- keys
-- values are leaf database nodes that contain the value which is the string description
if key2 ~= "link" then
local power2 = newpow.createChild(key2, type(val2.getValue()));
power2.setValue(val2.getValue());
end
end

-- link
if oldpow.getChild("link") then
newpow.createChild("link","windowreference").setValue(oldpow.getChild("link").getValue());
end
end
end

Foen
July 29th, 2008, 23:09
Ah-ha! Just testing ... I spotted a typo in my code.



local nodetype = source.getType();


Should be:



local nodeType = source.getType();

Sorry about that.

Just to be on the safe side, you might want to change:


if nodeType~="node" then
-- don't create anything. Should perhaps throw an error
return;
end

For:


if nodeType~="node" then
-- don't create anything. Should perhaps throw an error
print("Unrecognise node type '"..nodeType.."' for "..source.getName());
return;
end


Cheers

Stuart

Tenian
July 30th, 2008, 00:56
That typo correction fixes it nicely. Everything works using that method (and it looks much cleaner than the exception one I had for links).

Tenian
July 31st, 2008, 01:10
Onwards to new and exciting problems....

Since these are a modification of adventure_item the player doesn't see the actual stats until the item is identified and then shared. Once this is done, I've changed it so they can see a stat sheet. It all works nice..

But here's the rub. If you close FG2 down and relaunch it. The identified status saves...but if a player clicks on the link in their inventory, they get a blank stat sheet. If I share the item again, this corrects to showing the full stat sheet.

Essentially you would need to reshare the item each session (which would be kinda annoying). So I'm looking for a way to share the sheet when a player clicks on the item in the their inventory. (something in the onInit function).

Foen
July 31st, 2008, 06:00
The way I did this for another ruleset was a bit different. Instead of sharing the item, when it is placed in a player's inventory, I created a local copy for the player. It is then separate from the GM copy and doesn't need re-sharing each session.

Stuart

Tenian
July 31st, 2008, 11:05
How exactly would I make a local copy? I assume that it's a two step process:

1) Create the new local object
2) Transfer the data to the local object.

Step 2 should be no problem (especially since someone wrote this generic recursive copy thing....)

I don't imagine step 1 is all that difficult...I've just never done it :)

So if you have some psuedo code lying about.

Also is there any searchable ruleset programming documentation? Yesterday I wanted the information on getShortcutData() and it took me a long time to find it by clicking (somewhat randomly) through the web library. I really would like to RTFM on some of the easy stuff....if the manual was more readable :)

Foen
July 31st, 2008, 15:55
I think it is slightly easier, you don't need to create the object first as that is done for you, you just need to get a reference to the list where you want to put it.

If you are adding it to someone's inventory list (in, say, the inventorylist node) you'd do something like:



local list = window.getDatabaseNode().createChild("inventorylist");
copyNode(source, list);


This presumes that source is set to the database node of the object being dropped (from draginfo in the onDrop event handler).

I can see one difficulty: the copyNode function names the new node the same as the source node, so if the source node is called id-00001, so will the new node. If you drop two nodes with that name on the same list it will break FG.

To get around that problem, we'd need to amend the copyNode function to take an optional third parameter 'rename'.

Give me a yell if you want a help with that.

Stuart

Tenian
July 31st, 2008, 17:46
Well....it copies it and populates stuff however:

1) How do I handle the shortcut. The old code had:


newwin.shortcut.setValue(draginfo.getShortcutData( ));

which points back to the dragged object. In this case I want to point to the node I just created.

2) I have the rename code working, that was a snap. The question is, what's a good method of generating unique names?

Foen
July 31st, 2008, 18:00
A shortcut has two parameters: the name of the windowclass to display, and the location of the database node to populate the windowclass. If you take a peek at the documentation (https://www.fantasygrounds.com/refdoc/windowreferencecontrol.xcp) you see you can omit the second parameter and it defaults to using the calling databasenode.

I think you want to do something like:


newwin.shortcut.setValue("myclassname");


Auto-naming is quite straightforward: if you call list.createChild() with no parameters, it will create a new node and auto-name it.

I think the revised copyNode function would therefore look like this:


function copyNode(source, targetlist, rename)
-- creates a copy of the source node in the target list
local nodeType = source.getType();
if nodeType=="number" or nodeType=="string" or nodeType=="image" or nodeType=="dice" or nodeType=="windowreference" then
local newnode = targetlist.createChild(source.getName(),nodeType). setValue(source.getValue());
return;
end
-- copying formattedtext isn't supported
if nodeType=="formattedtext" then
-- create the node but don't bother trying to populate it
local newnode = targetlist.createChild(source.getName(),nodeType);
return;
end
-- unknown value?
if nodeType~="node" then
-- don't create anything. Should perhaps throw an error
return;
end
-- must be a complex node, we need to repeat the process on all child nodes.
local newlist;
if rename then
newlist = targetlist.createChild();
else
newlist = targetlist.createChild(source.getName());
end
for k,subnode in pairs(source.getChildren()) do
copyNode(subnode,newlist);
end
-- done
end


Cheers

Stuart

Tenian
July 31st, 2008, 18:22
There's the whole need for searchable help again :) I'll try that shortcut fix, when I get home from work.

You utilized the rename parameter in a different way than I did. I was intending to send the new name to copyNode at the top I added:

if rename == nil then
rename = source.getName()
end

I then replaced all the source.getName() references to be rename. i.e.

local newnode = targetlist.createChild(source.getName(),nodeType). setValue(source.getValue());
became

local newnode = targetlist.createChild(rename,nodeType).setValue(s ource.getValue());

This gave me the option of renaming less complex nodes (i.e. strings/numbers/etc).
The downside is I would have to generate the unique name somehow.

Foen
July 31st, 2008, 18:43
Your method for renaming is more flexible, but I used the other approach on the basis that the most frequent use would be for list entries (which are usually complex nodes).

Another choice is whether on not to cascade the parameter down to sub-lists: the inner call to copyNode could be copyNode(subnode,newlist,rename). I chose not to, because a sub-list probably already has its nodes uniquely named, or else they may be deliberately named.

There are no right answers, but it is good to know what choices you make, why they are made, and what the implications might be.

All for a 'simple' copyNode function!

Stuart

Tenian
July 31st, 2008, 21:28
Nope that doesn't work.
My code looks like this (without renaming atm):


if link == "item" then
local list = window.getDatabaseNode().createChild("inventorylist");
copyNode(draginfo.getDatabaseNode(),list);
return true;

end


So I tried to add in the shortcut:


if link == "item" then
local list = window.getDatabaseNode().createChild("inventorylist");
copyNode(draginfo.getDatabaseNode(),list);
list.shortcut.setValue("item");
return true;

end


That dumped a attempt to index a nil value to the console....no biggie...I'll just create it:


if link == "item" then
local list = window.getDatabaseNode().createChild("inventorylist");
copyNode(draginfo.getDatabaseNode(),list);
list.createChild("shortcut","windowreference").setValue("item");
return true;

end


That doesn't work either. No errors are produced but a blank record is created and neither record (the named or the blank) has a working shortcut.

Foen
July 31st, 2008, 22:19
A possible problem with your first attempt is mixing database node references:


list = getDatabaseNode().createChild("inventorylist")

with window/property references:


list.shortcut

The list.shortcut reference would have returned a nil value because 'shortcut' is not a property of the database node 'list'.

The second attempt fails because you are mixing the containing list node 'list' with the newly-created object in it (to which no reference is available).

So if you imagine a list, containing a new item 'id-00001', then you need to do something like:


copyNode(draginfo.getDatabaseNode(),list);
local itm = list.getChild("id-00001");
itm.createChild("shortcut","windowreference").setValue("item");


Unfortunately, copyNode doesn't return a reference to the newly created node ("id-00001"), so it needs to be changed (again) as follows:



function copyNode(source, targetlist, rename)
-- creates a copy of the source node in the target list
local nodeType = source.getType();
if nodeType=="number" or nodeType=="string" or nodeType=="image" or nodeType=="dice" or nodeType=="windowreference" then
local newnode = targetlist.createChild(source.getName(),nodeType). setValue(source.getValue());
return newnode;
end
-- copying formattedtext isn't supported
if nodeType=="formattedtext" then
-- create the node but don't bother trying to populate it
local newnode = targetlist.createChild(source.getName(),nodeType);
return newnode;
end
-- unknown value?
if nodeType~="node" then
-- don't create anything. Should perhaps throw an error
return nil;
end
-- must be a complex node, we need to repeat the process on all child nodes.
local newlist;
if rename then
newlist = targetlist.createChild();
else
newlist = targetlist.createChild(source.getName());
end
for k,subnode in pairs(source.getChildren()) do
copyNode(subnode,newlist);
end
return newlist;
-- done
end

You can then change your original code to:


if link == "item" then
local list = window.getDatabaseNode().createChild("inventorylist");
local newnode = copyNode(draginfo.getDatabaseNode(),list);
if newnode then
newnode.createChild("shortcut","windowreference").setValue("item");
end
return true;
end

Cheers

Stuart

Tenian
July 31st, 2008, 22:58
Okay that made a link that's clickable.....but it opens a sheet with none of the data on it full of vertical anchor issues (because there is no data).

So I made a new windowclass (which I wanted to do anyhow since the player view should be different than the gm view)
It's a very simple class...it just displays the name.

<windowclass name="item_test">
<frame>charsheet</frame>
<placement>
<size>
<width>500</width>
<height>370</height>
</size>
</placement>
<sizelimits>
<dynamic />
<minimum>
<width>200</width>
<height>220</height>
</minimum>
</sizelimits>

<sheetdata>
<!-- NAME -->
<genericcontrol name="nameframe">
<bounds>10,20,-20,35</bounds>
<frame>
<name>sheetgroup</name>
</frame>
</genericcontrol>
<stringfield name="name">
<anchored>
<top>
<parent>nameframe</parent>
<anchor>top</anchor>
<offset>9</offset>
</top>
<left>
<parent>nameframe</parent>
<anchor>left</anchor>
<offset>35</offset>
</left>
<right>
<parent>nameframe</parent>
<anchor>right</anchor>
<offset>-15</offset>
</right>
</anchored>
<empty>&#171; New Item &#187;</empty>
<font>sheettext</font>
</stringfield>

</sheetdata>
</windowclass>

However the name comes up blank. I think the shortcut is pointing to the wrong level...

Actually I played with this a bit more. If I add more than 1 item and then follow the shortcut, it all leads to the same place. They should lead to different places (i.e. the nodes I just created). Instead I think it points to the list.

Tenian
August 1st, 2008, 00:38
I was right, the value was not being set correctly.

I changed

newnode.createChild("shortcut","windowreference").setValue("item_test");

to

newnode.createChild("shortcut","windowreference").setValue("item_test",newnode.getNodeName());

now the link works (well at least the name gets populated)

Tenian
August 1st, 2008, 11:46
Now it works completely. I updated my player magic item display to show everything the GM sees (because I didn't feel like playing with spacing last night).

As an added bonus the local copy fixed another issue I was having. When it was using an item from the item box, I was forced to keep the item there as long as a player had it in inventory. Since the adventure items get exported when you bundle up an adventure this would mean keeping the adventure module loaded as long as the player had the item in inventory. The local copy, ties the item to the character sheet. Which means I no longer need to keep it's originating module open.

Oh and I turned on the rename option, so now it's possible to drop the same item multiple times onto one player's sheet.

It's definitely much cleaner this way.

Foen
August 1st, 2008, 18:14
Excellent!

Sound like problem solved.

Stuart