PDA

View Full Version : [MoreCore] Setting up icon to display when dragging results of a roll



Varsuuk
January 3rd, 2021, 08:36
I had guessed this had to do with the:
-- manager_custom_dice.lua file and the add_roll_type() method (arg named "action_icon")

So I found an example, The Dark Eye extension by Trenloe. I loaded it and it did just that with /dsadamage 1d6 result being draggable and the text is replaced with a little drop of blood icon.

I thought, simple and did same for my manager_custom_thac0.lua - based roller. I copied the "attack" icon from MoreCore and set this up in my own graphics_icons.xml and passed it in the "action_icon" argument.

Nothing. Still drags the roll definition text when I try to drag the results. I tried several variations (including using the exact icon TDE used in case it was size/type related.) More things tried and still nothing.

So. I added some debug code to MoreCore in a likely place and it seems it IS related but I can't figure what is missing:

in MoreCore, manager_actions.lua I added the Debugs and the "else" clause:


function onChatDragStart(draginfo)
local sDragType = draginfo.getType();
Debug.console("MC) -- sDragType", sDragType)
if GameSystem.actions[sDragType] and GameSystem.actions[sDragType].sIcon then
Debug.console("MC) -- sDragType icon found", GameSystem.actions[sDragType].sIcon)
draginfo.setIcon(GameSystem.actions[sDragType].sIcon);
else
Debug.console("MC) -- sDragType icon NOT found")
end
end


The result was, from the console log:


...
Runtime Notice: s'performAction: ' | nil | { s'sType' = s'pc', s'sCreatureNode' = s'charsheet.id-00003', s'sCTNode' = s'combattracker.list.id-00001', s'sName' = s'Varsuuk' } | s'1d6 Melee Attack'
...
Runtime Notice: s'MC) -- sDragType' | s'dsadamage'
Runtime Notice: s'MC) -- sDragType icon found' | s'attack'

...
Runtime Notice: s'performAction: ' | nil | { s'sType' = s'pc', s'sCreatureNode' = s'charsheet.id-00003', s'sCTNode' = s'combattracker.list.id-00001', s'sName' = s'Varsuuk' } | s'1d20x0 Melee Attack'

Runtime Notice: s'MC) -- sDragType' | s'number'
Runtime Notice: s'MC) -- sDragType icon NOT found'


The actual roller is not finished - I was just trying to get the icon up so I removed all of that from the log.
Interestingly, the dragType when it works is the name of the roll (dsadamage). On my roller, it is "number" instead. The original dsadamage used a different icon name - I changed it while trying to figure out what was wrong and left it that way. The icon it uses is the one >I< was trying to get working on my roller.


Any good advice or how-to on this dragging-icon behavior?

Trenloe
January 3rd, 2021, 09:00
You’ll need to include examples of all of the code you’re using, otherwise it will just be guesswork as to where this has gone wrong.

Varsuuk
January 3rd, 2021, 09:21
The good news is in trying to pick what out of all the changes I did (some totally unrelated but COULD be part of the problem I feared code) it hit me... ummm... forget my extension, do it in MoreCore alone (which has a copy of my swthac0 starting point also)

I modified dsadamage to use a token known to MoreCore and it worked - shows the "attack" icon when dragging.
A) BASELINE!

Now, I took my swthac0 and changed the to use the same name and tried that... NOPE :(
B) EXAMPLE OF PROBLEM

I am going to include the dsadamage with the argument change and the swthac0.lua in question. If you want to add the debugging to the "manager_actions.lua" in MoreCore the function is in my first post. I'll also include the other roller related files to change in more core. And after seeing how many files - made it a zip file emulating the morecore dir structure (with only the modified files - note no graphics_icons.xml since I reused "attack")

Varsuuk
January 3rd, 2021, 09:31
Cool - I took a new MoreCore unzip and put my files into it and it behaved same as in my test prior to starting anew.

The strings I used (dsa format you know :) ) were: /dsadamage 1d6 and /swthac0 1d20x19

Tried dragging both results, only the dsa shows the icon. I assume something in the rest of the dsa code is needed but don't see what. I made swthac0 from thac0.lua in MoreCore as the start point and added logging to get to know how things went and hadn't gotten far before saw this issue.

Thanks!

EDIT: YEEEP, it is 4:30, hitting sack Trenloe - thanks so much again for looking at this. Hopefully the zip makes it take way less time for you to review the issue. Many thanks.

Varsuuk
January 3rd, 2021, 21:11
I just started looking again.

On the vanilla MoreCore with the zip additions, I inserted the "logging" code into MoreCore's onChatDragStart() with same results.

Then, when the swthac0 roll's drag results in passing in sDragType=s'number' (for as yet not understood reason) - I replace it with "swthac0" and then - it works just like dsadamage. So the issue as I first noticed, appears to be WTH is the contents of drag info.getType() = "number" instead off the roll's name?

(Wish breakpoints were a "thing" ;) )

Varsuuk
January 3rd, 2021, 21:35
FOUND it!

So, I knew the right "type" for dsadamage was "dsadamage" and it WAS set right - so I looked all places in the lua file where it did something with "dsadamage" and saw:


rMessage = createChatMessage(rSource, rTarget, rRoll);
rMessage.type = "dsadamage";
Comm.deliverChatMessage(rMessage);


*remember, I started my roll from thac0, not dsadamage... which had instead:*


rMessage = createChatMessage(rSource, rRoll);
rMessage.type = "dice";
Comm.deliverChatMessage(rMessage);


So, I changed the rMessage.type = "dice" to:
= sCmd


And all works... now I know what is needed, it really wasn't;t the roll creation with the sCmd/"dsadamage" setting, it was later (makes sense) in the chat message creation which is what, really, is being dragged... duh, once I saw it.