PDA

View Full Version : Link token to Charsheet



favashi
May 21st, 2008, 10:11
Hi, first sorry for my english. I'm a new user from Spain, and i'm currently working on some modifications for my Campaign. I've done this for linking tokens to the charactersheets. This could be refactored (and I encourage you to do it):

Change this in the characterlist_entry.lua:


function onDrag(button, x, y, draginfo)
if User.isHost() or User.isOwnedIdentity(identityname) then
draginfo.setType("playercharacter");
draginfo.setDatabaseNode("charsheet." .. identityname);
draginfo.setStringData(identityname);

local node = DB.findNode("charsheet");
if node then
local userid = User.getCurrentIdentity(User.getIdentityOwner(iden tityname));
local character = node.getChild(userid);
if character then

local token = character.getChild("token");
if token then
draginfo.setTokenData(character.getChild("token").getValue());
return true;
else
draginfo.setTokenData("portrait_" .. identityname .. "_token");
local base = draginfo.createBaseData();
base.setType("token");
base.setTokenData("portrait_" .. identityname .. "_token");
end
end
end
return true;
end
end


And in charsheet_main.xml change this:


<genericcontrol>
<bounds>432,30,60,51</bounds>
<icon>cs_logo</icon>
</genericcontrol>
For this:


<tokenfield name="token">
<bounds>432,30,60,51</bounds>
<empty>indicator_emptytoken</empty>
</tokenfield>