Hi, everyone. I'm having a weird issue.
Basically, all my custom actions are being called twice by AC, even though I'm not using any kind of loops in the run() function (or anywhere else for that matter). I'm also making sure to not have any duplicated actions in my Action lists, so I'm pretty sure that's not the issue.
I first noticed the problem when I tested an Action I made to recover my character's HP/MP or whatever, and I noticed when I used an Item I was getting the wrong amounts. I quickly saw I was getting double of what I was telling the action to restore, so I went and double checked all the scripts the action depended on, but I found nothing wrong, so instead I added Debug.Logs in my AC custom action. And sure enough the Debug.Logs returned twice in the console. Then, to make sure, I went and added Debug.Logs in the rest of my Custom actions and all of them return the log twice for each action. Apparently, the contents of the action seem to be irrelevant. Somehow AC always triggers the run() function twice...
Also, I'm using AC 1.52a and I haven't changed anything in AC's scripts... So, anyone has any idea why this may be happening?
Anyways, as usual, any advice would be greatly appreciated.
Comments
It could be down to skipping. When an ActionList is skipped midway-through running, it basically re-runs all Actions instantaneously at once - though you can prevent this from happening by creating a separate overriding "Skip" function.
I don't know why it would skip either - I'm just letting you know that was cause a similar effect.
Place Debug.Log statements in both your Run and Skip functions - when you see it called twice in the Console, we'll be able to use the full messages to determine when and how.
See the comments in the Run() function in ActionTemplate.cs. If that function returns a non-zero float (say X), then it'll be re-run X seconds later. This allows Actions to check if they've been completed or not. "defaultPauseTime" is a built-in time value. The Action will continue to be re-run until you both return 0 and set isRunning to false.
Your Action is set up to be re-run because you return defaultPauseTime. When it does re-run, all of the code above that gets re-run - so place it within the "isRunning" check.
You can also do without the invoking, because if you return a value of "AlertDuration", the next time it runs will be the time that the Menu needs to close.
Something along these lines.