-
July 31st, 2020, 02:22 #1
- Join Date
- Apr 2009
- Posts
- 1,098
CombatManager.setCustomDrop - event is executed twice
I am trying to create a custom on drop event on the Combat Tracker.
The idea is that i can drag special tokens into the combat tracker actor, and add stuff to it (damage, etca)
So I am having an issue, and then to be safe, I checked this and it happens with CORERPG code also
Here is what i did:
- Clean CORERPG code
After that, I edited manager_combat2.lua, and did this:
function onInit()
CombatManager.setCustomSort(CombatManager.sortfunc Standard);
CombatManager.setCustomCombatReset(resetInit);
CombatManager.setCustomDrop(onDropEvent);
end
function onDropEvent(rSource, rTarget, draginfo)
local sDragType = draginfo.getType();
Debug.chat("onDropEvent");
Debug.chat("rSource",rSource);
Debug.chat("rTarget",rTarget);
Debug.chat("draginfo",draginfo);
end
The function is being called twice (check attached image)
error.PNG
I have no idea why this is happening, any ideas?
-
July 31st, 2020, 05:10 #2
Supreme Deity
- Join Date
- Mar 2007
- Posts
- 20,613
I'm not sure why it would be called twice; though you could use a Debug.printstack to review where it's being called from. One scenario is if there is an error; event scripts will be called twice by default.
JPG
-
July 31st, 2020, 06:09 #3
- Join Date
- Apr 2009
- Posts
- 1,098
Thanks for the tip Moon Wizard.
I could not really find out the issue, printstack didnt show much, but it is quite weird behaviour. I ended up creating a workaround, a counter to avoid the second ondrop.
It only happens when on the ondrop in the combat tracker.
So, with the workaround, it is working now... i may investigate further and try to find what happens.
It happens in corerpg, but i did test savageworlds and it doesnt happen there, but its combat tracker code has been changed a lot, so, i dont know
-
August 1st, 2020, 00:38 #4
- Join Date
- Apr 2009
- Posts
- 1,098
Hey Moon Wizard, not sure if you are going to read this, but i found another interesting thing.
I did the same test on FGU, and CORE fgu does not have the same issue.
I believe it could be a bug on corerpg, since i did test on a clean code, but of course i am not the best on coding for FG...
-
August 1st, 2020, 05:21 #5
Supreme Deity
- Join Date
- Mar 2007
- Posts
- 20,613
I'm not seeing the double call when I drop a dice on the CT. Do you have an extension or ruleset that I could use to recreate?
Regards,
JPG
-
August 1st, 2020, 17:12 #6
- Join Date
- Apr 2009
- Posts
- 1,098
Here. This is just CoreRPG.pak unzipped, and I added the lines i described above, to scripts/manager_combat2.lua
(FGClassic)
https://drive.google.com/file/d/1lNY...ew?usp=sharing
-
August 1st, 2020, 21:55 #7
Supreme Deity
- Join Date
- Mar 2007
- Posts
- 20,613
There's an interesting behavior in the current script system where some events are called twice if they aren't handled (i.e. return true/false), but an event function is defined. I've never tracked it down, because it's usually not that hard to avoid. It seems like that is what is happening here.
I should probably change the CombatManager.onDropEvent to return true always; but I don't want to change it at this point, since I don't know what the repercussions might be.
For now, you can add a "return true" to the end of your custom onDropEvent function to stop it.
Regards,
JPG
-
August 2nd, 2020, 03:35 #8
- Join Date
- Apr 2009
- Posts
- 1,098
Thread Information
Users Browsing this Thread
There are currently 1 users browsing this thread. (0 members and 1 guests)
Bookmarks