View Full Version : setPortrait Issue
dulux-oz
March 1st, 2013, 08:37
Hi Guys,
(Hope this is posted in the correct area).
Doing some coding around the User.setPortrait function and I'm getting an unresolvable (by me) error.
Code Line: User.setPortrait(node,portraitfile);
Error (from Console): setPortrait: Unable to locate character specified in parameter 1
print(node.getName()): id-00002
portraitfile is correct (a string containing the path to the portrait) and the correct character is being selected (id-00002).
I've also tried: User.setPortrait(node.getName(),portraitfile);
And gotten the same error.
So... what am I doing wrong?
Thanks in Advance
Valarian
March 1st, 2013, 08:59
On the GM's machine: Check that there's a id-00002 portrait file in the portraits subfolder for the campaign. This isn't the main portraits folder, but the one for the campaign. There should be one for each character in the character list. If not, copy a small .png file in there, rename to id-00002 (without the .png extension). You should then be able to change it from the player's side.
dulux-oz
March 1st, 2013, 09:15
Hi Valarian,
Nope, no good - the file does not exist for a new PC (in fact, the portraits folder didn't exist either) and I still get the same error when trying to change the portrait.
Having copied a portrait file from another campaign (with the same name: id-00002) an existing character will show that portrait, but again, I cannot change the portrait and I get the same error.
Any other ideas?
Zeus
March 1st, 2013, 09:21
Hi Valarian,
Nope, no good - the file does not exist for a new PC (in fact, the portraits folder didn't exist either) and I still get the same error when trying to change the portrait.
Having copied a portrait file from another campaign (with the same name: id-00002) an existing character will show that portrait, but again, I cannot change the portrait and I get the same error.
Any other ideas?
dulux-oz - are you attempting to set the portrait from the client?,if so make sure the client node has ownership of the character database node in question, otherwise it will not be allowed to make any changes.
Its not clear where you are calling setPortrait from or where you obtained the db node for the character but from the error message, it looks like it can't find the char node "id-00002".
Valarian
March 1st, 2013, 09:21
Other than creating a new character in the list, copying the stats over and then deleting the original - not really. Though that isn't going to work if the error is being thrown on any new character, not just id-00002.
May have to contact the support email, sending the db.xml file.
dulux-oz
March 1st, 2013, 09:45
To clarify:
The Client has ownership of character/node.
This is happening for ALL characters (I was just using id-00002 as an eg).
The node is coming is comming from a window.getDatabaseNode() statement called from an onDrop() function when the Portrait is dropped onto an appropriate area on the character sheet.
Q: the documentation specifies that the string/node to pass to the setPortrait() function is NOT the full path to the node. Am I to assume that the full path is "hard coded" into the function ie if the node was (for eg) <character><id-00002> would the setPortrait still work (btw, I've tried manually setting the db.xml file to both of these variants and I still get the same error).
Moon Wizard
March 2nd, 2013, 20:53
It's been a while since I looked at that function.
Some questions:
* Are you using code from an existing ruleset as your starting point? If so, which one?
* Is the script running on the host or the client?
Some other thoughts:
The following path must exist in the db.xml for the campaign (using 3.5E as an example with your code example):
root.charsheet.id-00002
The error message is stating that the path specified does not exist in the database on the instance that the script is running on.
Regards,
JPG
dulux-oz
March 4th, 2013, 15:45
Hi MW,
The original code came from the DnD 3.5 Ruleset(2.9.2).
The script is running (actually NOT running correctly) on the host and the client.
What does the function actually do? Does it:
1) Check to see if the 1st argument exists in the root.charsheet.<argument> tree.
2) Copy the file specified in the 2nd argument to the <campaign>/portraits folder.
3) Rename the copy as <1st argument> (whatever the actual id is).
Is this correct?
Does it do anything else?
Would it be possible for you to post the source code for the function (or email it to me, maybe)?
Cheers
Moon Wizard
March 4th, 2013, 19:32
Here is the rough pseudo-code for setPortrait:
if type(PARAM1) == "string" then
if LOCAL MODE then error and exit
sIdentity = PARAM1
elseif type(PARAM1) == "databasenode" then
nodeChar = PARAM1
elseif type(PARAM1) == 'nil' then
if CLIENT MODE and ACTIVE IDENTITY then sIdentity = ACTIVE IDENTITY
else exit
else
error and exit
end
if type(PARAM2) != "string" then error and exit
if nodeChar then
if LOCAL MODE then
if nodeChar is LOCAL then set local portrait and exit
else error and exit
end
sIdentity = nodeChar.getName()
end
FIND "root.charsheet." + sIdentity
if NOT FOUND then error and exit
if HOST then SET PORTRAIT(sIdentity, PARAM2) and BROADCAST PORTRAIT
if CLIENT then SEND PORTRAIT FILE TO HOST (sIdentity, PARAM2)
Regards,
JPG
dulux-oz
March 5th, 2013, 04:00
Hi MW/JPG - Thanks for that.
Ah - there's my problem.
You've hard-coded the path to root.charsheet.<id>.
My ruleset uses root.pcsheet.<id> and therefore is failing the final FIND.
Now, what to do about it - all of the rest of my ruleset code uses root.pcsheet; to change that is a rather large undertaking. It might be easier to write a modified version of setPortrait - I'll need to work out how to do the BROADCAST PORTRAIT and SEND PORTRAIT TO HOST bits, but the rest of it should be straight forward.
Look, my real email is
[email protected]. Send you a contact email and we'll take this offline for privacy (if you like). I've also got a FG2 tutorial-vid I'd like to send you which I think you'd like to see.
Anyway, hear from you soon - great work on the application, btw.
Cheers
Moon Wizard
March 5th, 2013, 06:48
Actually, the path is "root.<chardbroot>.<identity>", but I was simplifying.
To set <chardbroot> to something other than char sheet, define the following tag in your ruleset base.xml file:
<characterdbroot>pcsheet</characterdbroot>
If you want to send us something to look at, you can send it to
[email protected]
or
[email protected]
Doug and I both monitor those e-mails.
Regards,
JPG
dulux-oz
March 5th, 2013, 15:40
Hi JPG,
Thanks for that - all fixed now :)
Email inbound
Cheers
lule
April 18th, 2013, 22:20
Hi at all!
One more question in this area.
If you want to change the portrait on client side when the char is released but the charsheet is still open this is not working. After you selected the char in the character selection every thing is working fine again.
In this case is it necessary for the setPortrait-function or the setIcon-function ("wnd.portrait.setIcon("portrait_" .. id .. "_charlist", true);") that the char is still requested?
On host side there is no such "problem".
Is there a reason for this behaviour? Or could it be changed? If it is the setIcon-function then I could try to go around by using OOB.
Best regards,
Lule
Trenloe
April 18th, 2013, 22:39
If you want to change the portrait on client side when the char is released but the charsheet is still open this is not working. After you selected the char in the character selection every thing is working fine again.
In this case is it necessary for the setPortrait-function or the setIcon-function ("wnd.portrait.setIcon("portrait_" .. id .. "_charlist", true);") that the char is still requested?
On host side there is no such "problem".
Is there a reason for this behaviour? Or could it be changed? If it is the setIcon-function then I could try to go around by using OOB.
Once the character is released the player can no longer change things in the character sheet - as they no longer have ownership of the PC.
The host (GM) can always change things, whether a PC owns them or not.
What ruleset are you using? In 3.5e if a player has the character sheet open and the GM removes their ownership the character sheet closes - as it should, as the player no longer controls/owns it.
lule
April 19th, 2013, 06:33
Thanks for your answer. But it is not an ownership issue. The ownership is still set and not removed by the host.
The issue is in 3.5e and 4e. Clients can not change the Portrait when the char portrait is not shown above the chat box. You can test this by opening the character sheet on client side and then release as client the character but do not close the character sheet. In this state the client can not change the portrait.
When the campaign is saved in this state by the host in the db.xml the ownership is still set.
Moon Wizard
April 19th, 2013, 23:34
I'd have to look in the code, but my assumption is that you can not change the portrait for a character you do not actively control, even if you "own" the character sheet. This is similar for color, and any other character "meta-data" not stored in the db.xml file.
Just curious, why would you still use a character sheet that you have released? Or why would you want or need to release in the first place?
Regards,
JPG
lule
April 22nd, 2013, 20:03
Thank you again JPG!
The reasons are the following:
1. Some players did this by accident and than complained that the change of the portrait is not working. No really reason to change that.
2. There is the request to administrate a companion (animal) via the charsheet. That's no problem. But when we implement this there will be sooner or later the request for an own token (via picture in the portrait-folder) for this companion. Therefore it would be nice to know if the character need to be in actively control for the setPortrait-function or for the setIcon-function. If it is not the setPortrait-function there could be a workaround via OOB-Message.
If it is the setPortrait-function then there will be no such support for the companion and an token have to set via a shared token-file.
JohnD
April 25th, 2013, 01:58
Why wouldn't the DM just add the portrait in game since he/she can open any PC or NPC regardless of who "owns" it?
lule
April 25th, 2013, 10:21
Just simply as that: The picture is on client side and not on host side. In this case the player has to send the picture first to the DM, than the DM has to save it in the portrait folder (many pictures can make the selection unclear) and at last the DM has to set the portrait. This is not really user-friendly.
Powered by vBulletin® Version 4.2.1 Copyright © 2026 vBulletin Solutions, Inc. All rights reserved.