Jump to content

How to trigger a function every x amount of in game hours. (Tuturial)


trepleen

Recommended Posts

Posted
I'm creating a super, super basic way to keep track of when a companion has bathed. 
 
I found this very useful:
 
Function SomeFunction()

     ;after 24 in game hours fire the onupdategametime event
     RegisterForSingleUpdateGameTime(24)

endFunction
 
Event OnUpdateGameTime() ; because of how we registered, this event occurs every 30 minutes of game time        

       ;note: this event triggers one time and then unregisters

       ;notify player than 24 in game hours have passed
       debug.messagebox("24 in game hours have passed")

       ;do what you want here

endEvent

 

Posted

If you want EVERY tot amount of game hours then you should do something like:

 

 

Function InitFunction()
  RegisterForSingleUpdateGameTime(24.0)
  ;after 24 in game hours fire the onupdategametime event
endFunction


Event OnUpdateGameTime() ; because of how we registered, this event occurs every 30 minutes of REAL time (24 hours game time)       
  
  ;notify player than 24 in game hours have passed
  
  debug.messagebox("24 in game hours have passed")

  ;do what you want here

  ;note: this event triggers one time and then unregisters, so you have to register it again.
  RegisterForSingleUpdateGameTime(24.0)
endEvent
But better to check if you have still to do the job, or your script will run forever also if you uninstall the mod.

 

 

 

Boolean Property doTheJob Auto

Function InitFunction()
  doTheJob = True
  RegisterForSingleUpdateGameTime(24.0)
  ;after 24 in game hours fire the onupdategametime event
endFunction


Function stopFunction()
  doTheJob = False
  UnregisterForUpdateGameTime()
endFunction
 
Event OnUpdateGameTime() ; because of how we registered, this event occurs every 30 minutes of REAL time (24 hours game time)     ;notify player than 24 in game hours have passed   debug.messagebox("24 in game hours have passed")   ;do what you want here

if (doTheJob)   ;note: this event triggers one time and then unregisters, so you have to register it again.
  RegisterForSingleUpdateGameTime(24.0)
endIf
endEvent

Posted

Its nice that you are making scripting tutorials. By the way is there a tutorial about how to setup everything so you can start scripting?

Posted

Its nice that you are making scripting tutorials. By the way is there a tutorial about how to setup everything so you can start scripting?

 

I made this tutorial a long time ago.

 

http://www.loverslab.com/topic/35451-sexlab-creation-kit-tutorial-for-beginners-make-actor-play-animations/

 

That should get you setup where you can start pasting script fragments to dialogue options.

 

CPU, I appreciate that, good code!

Archived

This topic is now archived and is closed to further replies.

  • Recently Browsing   0 members

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