PDA

View Full Version : Quick "target" naming related question - using 2E code example



Varsuuk
September 12th, 2019, 06:06
So, I got my saving throws setup code wise for classes/races leveling (inc multiclass/dual) where base and bonuses are filled in/updated.

I went to activate "rollable" aspect.
Grabbed a fast example in 2E just to start. Printed via console some of the variables mentioned in that method in my own "stub" action (called from double-click) method just to see what I have.

I remember in early API docs a page where referencing xml (ie: using that [1] thing) is explained and I will refresh myself tomorrow reading it (allergies and 1AM ;) ).
Just had a question - is "target" the accepted element name to use (recall it often) anytime you basically want to do a "this"/name type key lookup? In the example below it takes the expected base path and inserts the "target" to build complete path.

If so, I will continue to use it. Otherwise, I'd replace it with per-use naming like: "<savecategory>devices</savecategory>" etc?



example:




<template name="number_charasavescore">
<number_savescore>
<anchored to="statstitle" position="below"/>
<rollable />
<script>
function action(draginfo)
local nTargetDC = 20;
local rActor = ActorManager.getActor("", window.getDatabaseNode());
local sActorType, nodeActor = ActorManager.getTypeAndNode(rActor);
nTargetDC = DB.getValue(nodeActor, "saves." .. self.target[1] .. ".score", 0);
ActionSave.performRoll(draginfo, rActor, self.target[1],nTargetDC);
return true;
end

function onDragStart(button, x, y, draginfo)
return action(draginfo);
end

function onDoubleClick(x,y)
return action();
end
</script>

</number_savescore>
</template>

Moon Wizard
September 12th, 2019, 17:52
There's no standard really for that stuff. Using a "target" or "source" tag is the most common implementation I have seen; and what is used in most of the rulesets I do.

Regards,
JPG