Jump to content

Create Papyrus script that resets every 1 day


Recommended Posts

Can use GameDaysPassed global var to determine, if a full day has passed since last Player's activation. To avoid unneccessary persistence should use a dedicated Global for storing last access time.

 

Like that (draft):

OnActivate

If ((gNextAccess.GetValue() < GameDaysPassed.GetValue()) && (akActionRef == Game.GetPlayer()))

gNextAccess = GameDaysPassed.GetValue() + 1.0

; do my thing

Else

; show message ?

Endif

End event

 

Or can use StartTimerGameTime(), if want an extra timer in game and a persistent object, depends on exact goals though - e.g. if want the activator to be disabled/enabled.

Edited by hereami
Link to comment
Share on other sites

Can use GameDaysPassed global var to determine, if a full day has passed since last Player's activation. To avoid unneccessary persistence should use a dedicated Global for storing last access time.

Â

Like that (draft):

OnActivate

   If ((gNextAccess.GetValue() < GameDaysPassed.GetValue()) && (akActionRef == Game.GetPlayer()))

      gNextAccess = GameDaysPassed.GetValue() + 1.0

        ; do my thing

   Else

        ; show message ?

   Endif

End event

Â

Or can use StartTimerGameTime(), if want an extra timer in game and a persistent object, depends on exact goals though - e.g. if want the activator to be disabled/enabled.

The thing is I'm going to edit a script from a mod that's no longer public, and it has a faulty script. It uses StartTimerGameTime() but the else statement seems to make it loop.

 

Essentially the script goes by:

1. Set used variable to 0

2. If used, set variable to 1 and set timer to 24 hours, else set timer to 24 hours.

3. Set used variable to 0

 

I want to fix that.

Link to comment
Share on other sites

Is the variable used from outside for sync? Hm, sequence looks weird. Post the script as is, use Code statement for readability. Somebody might say something then.

idk, could be like this then:

Event OnActivate
	If (AccessLocked == False)&&(akActionRef == Game.GetPlayer())
		self.BlockActivation(True, True) ; optional
		AccessLocked = True;
		; do my thing
		StartTimerGameTime(24.0)
	Endif
End Event

Event OnTimerGameTime
	AccessLocked = False;
	self.BlockActivation(False) ; optional
End Event
Edited by hereami
Link to comment
Share on other sites

Is the variable used from outside for sync? Hm, sequence looks weird. Post the script as is, use Code statement for readability. Somebody might say something then.

 idk, could be like this then:

Event OnActivate
	If (AccessLocked == False)&&(akActionRef == Game.GetPlayer())
		self.BlockActivation(True, True) ; optional
		AccessLocked = True;
		; do my thing
		StartTimerGameTime(24.0)
	Endif
End Event

Event OnTimerGameTime
	AccessLocked = False;
	self.BlockActivation(False) ; optional
End Event

Okay, I'll try that. I'm modifying a version of reptileye's mod, which is why I can't show the code because he might come at me mad. Trying to contact with him right now.

 

Hope it sticks when I get home to do your suggested code (after I replace the AccessLocked into the mod's variable).

 

 

 

GlobalVariable Property rep_BoSration1 Auto

Event OnInit()
	Self.StartTimerGameTime(24, 1)
EndEvent

Event OnTimerGameTime(int aiTimerID)
	If (rep_BoSration1.GetValue() == 0 as float)
		rep_BoSration1.SetValue(1 as float)
		Self.StartTimerGameTime(24, 1)
	Else
		Self.StartTimerGameTime(24, 1)
	EndIf
EndEvent  

 

 

Edited by RowanSkie
Link to comment
Share on other sites

Well, you need to track the usage of rep_BoSration1 variable then. What i suggested is for a case of a single independent activator (exactly what you asked in first post).

 

What is wrong with mod actually? This part of code is ok, but redundant, it may equal to OnTimer -> SetValue(1.0) -> StartTimer - BUT here assuming BoSration1 is a boolean-like (restoring access on timer no matter what). If not - track the variable usage and logic flow.

Edited by hereami
Link to comment
Share on other sites

  • Recently Browsing   0 members

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