Jump to content

Scripting a time-difference event?


Recommended Posts

Thanks for your help!

 

Unless I've made a mistake, the script still isn't working correctly- I seem to be having the same problem as before.

Waiting 1 hour at a time will see the fire gradually go down, but waiting 6 hours seems to be the same as waiting 1...

 

 

I guess I'll need to think of a new approach.

 

Link to comment
Share on other sites

You need to reconsider how your new script works.  You have this snippet for example:

if pGlobal == 5
		FirewoodStage1.SetStage(stageToSet4)
		KHDFireplaceTemp.SetValue(4)
		RegisterForSingleUpdateGameTime(pHourstoWait)

You are trying to process the event, one hour at a time (or rather, one pHoursToWait at a time), but the function actually needs to process all the time that actually has passed since the previous OnUpdateGameTime...

When pGlobal == 5 at this point, it's because no time has passed.  After the following line, pGlobal contains the remaining level:

pGlobal = (pGlobal - StagesPassed) as Int

You should adjust your calls to FirewoodState1.setStage and KHDFireplaceTemp.setValue accordingly.  The registerForSingleUpdateGameTime remains the same, since pHoursToWait is still when you should next recheck the level.

Link to comment
Share on other sites

Posted (edited)

Put in some trace or notification statements that can tell you what values things have at certain times.  Make sure that the data is being returned the way you intend for it to be.  Only you can truly determine where your script might be failing.  This is because you have everything else that the script needs to work.  While we can test for compilation and provide suggestions, we cannot determine if it will work specifically for your needs.

 

EDIT:

When you start the fire, you have pGlobal with values of 0 through 5.  When you downgrade the fire, you only have values of 1 through 5.  If the fire is to be completely out at 6 hours or more, you'll need to add the ability to completely put out the fire when the pGlobal is at 0.  This is because 5 - 6 = -1 but gets set to 0 in the script.  And because there is no instructions as to what to do when pGlobal is at a value of 0, nothing happens.

Edited by IsharaMeradin
additional information
Link to comment
Share on other sites

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...