PDA

View Full Version : Getting the character being modified.



MadBeardMan
April 14th, 2017, 18:36
Folks,

How do I in script access the 'current' character/character sheet.

What I want to do, is move this code into a script file, when I do the 'getDatabaseNode()' accesses the wrong item (the skill window) and not the parent, the character sheet (ie ID_0001).


<script>
function onDrop(x, y, draginfo)
if draginfo.isType("shortcut") then
local sClass, sRecord = draginfo.getShortcutData();

if StringManager.contains({"ref_skills"}, sClass) then
CharManager.addInfoDB(getDatabaseNode(), sClass, sRecord);
return true;
end
end
end
</script>


Cheers
MBM

Moon Wizard
April 14th, 2017, 19:09
If you are in the skill window, you will need to traverse the tree to get to the character node, something like this.

DB.getChild(getDatabaseNode(), "...");
getDatabaseNode().getParent().getParent()

This assumes that your character sheet node is only two steps removed from your skill nodes for the character.

Make sure to use Debug.chat and Debug.console functions to output variables as you go to make sure you are getting the nodes (or any other values) you expect.

Regards,
JPG

MadBeardMan
April 14th, 2017, 22:26
If you are in the skill window, you will need to traverse the tree to get to the character node, something like this.

DB.getChild(getDatabaseNode(), "...");
getDatabaseNode().getParent().getParent()

This assumes that your character sheet node is only two steps removed from your skill nodes for the character.

Make sure to use Debug.chat and Debug.console functions to output variables as you go to make sure you are getting the nodes (or any other values) you expect.

Regards,
JPG

Cheers chap, this is what worked.


function onDrop(x, y, draginfo)
if draginfo.isType("shortcut") then

local sClass = draginfo.getShortcutData();
local node = draginfo.getDatabaseNode();

if StringManager.contains({"reference_exploit", "reference_skill"}, sClass) then
CharManager.addInfoDB(getDatabaseNode().getParent( ), node, sClass);
return true;
end
end
end

Thanks
MBM