Hi Guys
First let me apologize for not being able to display my script in the proper recommended form with all the pretty colors, I just spent half an hour trying to figure out how and where to enter the whole thing, unsucessfully I'm afraid so I've attached it in the spoiler below. English is not my native language and I'm trying to learn coding from scratch ...
Anyway, here's my question: I'm trying to add a timer to a fire, which turns the fire out when 24 game-hours have passed after lighting the fire. I have attached the script to an activator and the first script I did works, simply adding the line" utility.waitGameTime(24)" after the fire has been enabled does the trick as long as I stay in game. If I quit and reload however, the script seems to reset and count the 24 hours from reload time.
I know I'm missing an "OnLoad" Event, but I cant' figure how to call the timer in that event.
I've watched Doughamil's video over and over, but the script he uses is attached to a quest which defines states and timer, whereas I'm trying to achieve the same effect directly on an Object instance.
The script in the spoiler is my second attempt, it does compile, message displays in game show that it does go from one state to another, but the timer does not work. I'm pretty sure I'm missing a function somewhere, but I can't figure which nor exactly where to place it.
I'd be really grateful if someone who knows better than me about all this would take a look at it. A thousand thanks in advance!..
Int Property FireplaceDeathTime Auto
Int Property BurningHours Auto
bool Property Fade = True auto
{fade in / fade out when enabled/disabled - default is False}
bool Property isBurning Auto
Int FireTimer = 0
Event OnLoad()
If (isBurning)
GoToState("Burning")
Else
GoToState("NotBurning")
EndIf
EndEvent
State Burning
Event OnUpdate()
FireTimer += BurningHours
If (FireTimer > FireplaceDeathTime)
FireplaceFireOff.enable(Fade)
FireplaceLight.disable(Fade)
FireplaceFireOn.disable(Fade)
ChimneySmoke01.disable(Fade)
ChimneySmoke02.disable(Fade)
UnregisterForUpdate()
GoToState("NotBurning")
isBurning = False
EndIf
EndEvent
Event OnActivate(ObjectReference TriggerRef)
FireplaceBurningMessage.Show()
; fire is burning, no need to add wood
EndEvent
EndState
State NotBurning
Event OnActivate(ObjectReference TriggerRef)
If (Game.GetPlayer().GetItemCount(Firewood01) >= 4)
Game.GetPlayer().RemoveItem(Firewood01, 4)
GoToState("Busy")
Utility.Wait(0.5) ; start building the fire
FireWoodBurningStart.enable(Fade)
FireplaceLight.enable(Fade)
Utility.Wait(10.0)
FireplaceFireOn.enable(Fade)
FireplaceFireOff.disable(Fade)
ChimneySmoke01.enable(Fade)
ChimneySmoke02.enable(Fade)
Utility.Wait(5.0)
FireWoodBurningStart.disable(Fade)
FireTimer = 0 ; fire is fully lit, start the timer
GoToState("Burning")
RegisterForUpdate(BurningTickingClock)
isBurning = True
Else
FireplaceWoodMessage.Show()
; Player does not have enough wood to build the fire
EndIf
EndEvent
EndState
State Busy ; dummy state to prevent interaction until the fire is fully lit
Event OnBeginState()
; Debug.Trace(Self + " is in the process of fading in " = TriggerRef)
EndEvent
EndState
MiscObject Property Firewood01 Auto
ObjectReference Property FireplaceFireOn Auto
ObjectReference Property FireWoodBurningStart Auto
ObjectReference Property FirePlaceLight Auto
ObjectReference Property FireplaceFireOff Auto
ObjectReference Property ChimneySmoke01 Auto
ObjectReference Property ChimneySmoke02 Auto
Message Property FireplaceWoodMessage Auto
Message Property FireplaceBurningMessage Auto
Message Property FireplaceDeathTimeMessage Auto
