Page 1 of 1

Restoring resources with callBackOnRest

Posted: Fri Nov 06, 2015 2:52 pm
by Razakai
I have a throwing knife talent that uses stacks on a temporary effect to simulate ammo. To make it simple, I wanted it to restore knives while resting, via the following callback:

Code: Select all

	callbackOnRest = function(self, t)
		local reload = self:callTalent(self.T_THROWING_KNIVES, "getReload")
		local max = self:callTalent(self.T_THROWING_KNIVES, "getNb")
		self:setEffect(self.EFF_THROWING_KNIVES, 1, {stacks=reload, max_stacks=max })
	end,
However, what instead happens is that when you hit the rest key, even if there are mobs nearby and you only rest for 0 turns it still restores your stacks to maximum. What am I doing wrong?

Re: Restoring resources with callBackOnRest

Posted: Fri Nov 06, 2015 9:45 pm
by Effigy
Have you verified that it's not a problem with those getReload and getNb methods? Also, I would recommend changing getNb to a more descriptive name.

Re: Restoring resources with callBackOnRest

Posted: Sun Nov 08, 2015 9:15 pm
by Razakai
Yeah, the same bit of code is used elsewhere so it's fine. What I did notice is that it seems to trigger twice on a 0 turn rest - e.g. when it's supposed to reload 2 daggers per turn, just hitting rest once returns 4.

Re: Restoring resources with callBackOnRest

Posted: Sun Nov 08, 2015 11:43 pm
by HousePet
Does it have a state variable notifying if it is triggering on rest initiated or on rest ended/interupted?

Re: Restoring resources with callBackOnRest

Posted: Mon Nov 09, 2015 10:16 am
by Razakai
Nope! Looking at it now I think that's the issue, that it's prob just calling the reload without checking whether the rest is in progress etc. Shame there isn't many examples of on rest callbacks in the code.