noisestudio Posted February 20, 2013 Share Posted February 20, 2013 well...this really drive me insane...not wilson,i'm sorry,it's me......try to modify data\scripts\components\sanity.luaadd new variable self.ct = 1local Sanity = Class(function(self, inst) self.inst = inst self.max = 100 self.current = self.max --local dt = 1 --self.task = self.inst:DoPeriodicTask(dt, function() self:Recalc(dt) end) self.inst:StartUpdatingComponent(self) self:Recalc(0) self.rate = 0 self.sane = true self.ct = 1 end)then in the function belowfunction Sanity:DoDelta(delta, overtime) self.ct = self.ct + 1endself.ct = self.ct + 1,crash the game...well,this really make me insane,cause the original clauseself.current = self.current + deltajust do so,and no crash....so,what's wrong....:fatigue:i can not add a custom counter timer and change it?? Link to comment Share on other sites More sharing options...
Developer Kevin Posted February 20, 2013 Developer Share Posted February 20, 2013 I could guess that self:Recalc(0) ends up calling DoDelta. which would be happening before you set up self.ct. Just move self.ct = 1 to before that gets called. Link to comment Share on other sites More sharing options...
noisestudio Posted February 21, 2013 Author Share Posted February 21, 2013 oh,no,i forget this very important rule,define before use.thank you.now it's working. Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now