Jump to content

Event for passing of day?


mounty1512

Recommended Posts

Hi

 

I'm writing a script that I want to run once a day to add items to a container.

 

I'm fine with writing the procedure to add the items but I cant seam to find an event that allows a script to run at a set time or at the start/end of a day.

 

Does anyone know of an event I could use or another way I could achieve this?

 

Thanks

Link to comment
Share on other sites

The easiest way imho is using a quest.

 

- Create a new quest, mark it as "start game enabled". Create only stage 0 and mark it as "startup stage".

 

- go to "scripts", create a new script.

 

- write this:

 

Event OnUpdateGameTime()
    ;your script to add items here
EndEvent

 

Add also all the properties needed to add the items to the container

 

- now go back to the stages tab, select stage 0, right click on the Stage Info and "add new". This will enable the fragment section.

 

- In the kmyquest dropdown select the script you just created, then add this fragment

 

kmyquest.RegisterForUpdateGameTime(24)

Link to comment
Share on other sites

If you really want it to be precise about the hour you could start the script via a quest or whatever, then use "GetCurrentGameTime()" to schedule an updateGameTime at that hour. Say it's noon (for simplicity), then GetCurrentGameTime() should return X.5 (I think), you could then schedule an update after 12 hours and it'll be at midnight. You'd have to use maths and stuff though
Link to comment
Share on other sites

I used gasti89's method but came up with the following error:

 

Starting 1 compile threads for 1 files...
Compiling "QF_Argontine_Miningquest_020051B0"...
...\skyrim\Data\Scripts\Source\temp\QF_Argontine_Miningquest_020051B0.psc(9,30): cannot cast a quest to a miningquest, types are incompatible
...\skyrim\Data\Scripts\Source\temp\QF_Argontine_Miningquest_020051B0.psc(12,9): RegisterForUpdateGameTime is not a function or does not exist
No output generated for QF_Argontine_Miningquest_020051B0, compilation failed.

Batch compile of 1 files finished. 0 succeeded, 1 failed.
Failed on QF_Argontine_Miningquest_020051B0

 

Any ideas how to sort this?

 

here is my fragment script:

 

;BEGIN FRAGMENT CODE - Do not edit anything between this and the end comment
;NEXT FRAGMENT INDEX 1
Scriptname QF_Argontine_Miningquest_020051B0 Extends Quest Hidden

;BEGIN FRAGMENT Fragment_0
Function Fragment_0()
;BEGIN AUTOCAST TYPE miningquest
Quest __temp = self as Quest
miningquest kmyQuest = __temp as miningquest
;END AUTOCAST
;BEGIN CODE
kmyquest.RegisterForUpdateGameTime(24)
;END CODE
EndFunction
;END FRAGMENT

;END FRAGMENT CODE - Do not edit anything between this and the begin comment

 

 

And here's the script to add the items to the container:

 

Scriptname miningquest  

MiscObject Property Ore  Auto  

ObjectReference Property stockpile  Auto  

Quest Property mainquest  Auto  

Event OnUpdateGameTime()

    	if mainquest.getstage() >= 60

	stockpile.additem(ore,5)

endif
EndEvent

 

Edited by mounty1512
Link to comment
Share on other sites

Read my last post.

 

Make a quest alias for your container (if you haven't already) then attach this modified script to the container's alias.

 

Scriptname miningquest extends ReferenceAlias

MiscObject Property Ore  Auto  

Event OnUpdateGameTime()
       if GetOwningQuest().getstage() >= 60
               self.GetRef().additem(ore,5)
       endif
EndEvent

 

use a fragment:

 

alias_<your container alias>.RegisterForUpdateGameTime(24)

Edited by steve40
Link to comment
Share on other sites

  • Recently Browsing   0 members

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