STAR TREK 2d20
  1. #1

    dragdata.setIcon

    I am trying to understand how the Action Scripts in the 4e ruleset are working. I´ve 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.

    Code:
    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?

  2. #2
    Trenloe's Avatar
    Join Date
    May 2011
    Location
    Colorado, USA
    Posts
    33,413
    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.
    Private Messages: My inbox is forever filling up with PMs. Please don't send me PMs unless they are actually private/personal messages. General FG questions should be asked in the forums - don't be afraid, the FG community don't bite and you're giving everyone the chance to respond and learn!

  3. #3
    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...

  4. #4
    The dragdata object has a display prioritization specified by the FG client. (Dice -> Icon -> Token -> String -> Number)

    Regards,
    JPG

  5. #5
    Trenloe's Avatar
    Join Date
    May 2011
    Location
    Colorado, USA
    Posts
    33,413
    Quote Originally Posted by Talador View Post
    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.
    Private Messages: My inbox is forever filling up with PMs. Please don't send me PMs unless they are actually private/personal messages. General FG questions should be asked in the forums - don't be afraid, the FG community don't bite and you're giving everyone the chance to respond and learn!

  6. #6
    Thank you moon_wizzard and Trenloe for your explanations!

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
FG Spreadshirt Swag

Log in

Log in