PDA

View Full Version : dragdata.setIcon



Talador
August 11th, 2013, 17:52
I am trying to understand how the Action Scripts in the 4e ruleset are working. Ive got a question regarding the function "encodeActionForDrag(draginfo, rSource, sType, rRolls, rCustom)" inside scripts/manager_actions.lua .
As far as I understand, the function is called (among others) when somebody drags an field which contains an action.
The statement "draginfo.setIcon(aActionIcons[sType]);" should render a graphic at the mouse cursor. For example the icon "graphics\icons\action_roll.png". But everytime I drag a field towards the chatbox I only see a dice...
The function and the statement are both definetly called.



function encodeActionForDrag(draginfo, rSource, sType, rRolls, rCustom)
draginfo.setType(sType);

if aActionIcons[sType] then
draginfo.setIcon(aActionIcons[sType]);
end
if #rRolls == 1 then
draginfo.setDescription(rRolls[1].sDesc);
end

draginfo.setSlot(1);
draginfo.setNumberData(#rRolls);
if rSource then
if rSource.sCTNode ~= "" then
draginfo.setShortcutData("combattracker_entry", rSource.sCTNode);
elseif rSource.sCreatureNode ~= "" then
if rSource.sType == "pc" then
draginfo.setShortcutData("charsheet", rSource.sCreatureNode);
elseif rSource.sType == "npc" then
draginfo.setShortcutData("npc", rSource.sCreatureNode);
end
end
end

local nStart = 1;
for kRoll, vRoll in ipairs(rRolls) do
draginfo.setSlot(kRoll + nStart);

draginfo.setStringData(vRoll.sDesc);
draginfo.setDieList(vRoll.aDice);
draginfo.setNumberData(vRoll.nMod);
end

if rCustom then
nStart = nStart + #rRolls;
for kCustom, vCustom in ipairs(rCustom) do
draginfo.setSlot(kCustom + nStart);

draginfo.setStringData(vCustom.sDesc or "");
draginfo.setDieList(vCustom.aDice or {});
draginfo.setNumberData(vCustom.nMod or 0);
draginfo.setShortcutData(vCustom.sClass or "", vCustom.sRecord or "");
end
end
end



What am I missing?
Maybe I missunderstood how dragdata.setIcon() works...
Any help?

Trenloe
August 11th, 2013, 21:34
The string used in dragData.setIcon is not the path/filename it is "The name of an icon resource used for the icon". An icon resource is a reference name that FG uses (which then points to the actual graphics file). For 4e I believe these are in the ruleset in the \graphics\graphics_misc.xml file, search for the "<!-- Action icons for dragging -->" section. This will list the icon "name" you can use, such as "action_roll", "action_attack", etc.

Talador
August 12th, 2013, 08:10
Thank you for your help!
That code is not from me. It is from the 4e ruleset. The icons are in the *.pac and bound in in the code.
Why can I not see the icons when using the ruleset? Ever action event in the 4e ruleset should render an "action_icon" on drag and drop events. But that does not happen. Only a dice is rendered...

Moon Wizard
August 12th, 2013, 08:35
The dragdata object has a display prioritization specified by the FG client. (Dice -> Icon -> Token -> String -> Number)

Regards,
JPG

Trenloe
August 12th, 2013, 12:50
Why can I not see the icons when using the ruleset? Ever action event in the 4e ruleset should render an "action_icon" on drag and drop events. But that does not happen. Only a dice is rendered...
Dice will be rendered if dice are going to be rolled.

To see examples of the action icons in use open the default "Second Wind" power, click the "sword" icon to the right of the power heading to show the healing and "DEF:2" effect. Click-and-drag either of these and you will see a action_heal icon for dragging "1[HSV]" or the the action_effect icon for dragging "DEF:2".

If you have a power that just does the same damage each time (no dice being rolled) you'd see the action_damage icon when being dragged. However, if there are any dice in the damage entry then you would see the dice when dragging.

Talador
August 12th, 2013, 15:13
Thank you moon_wizzard and Trenloe for your explanations!