mounty1512 Posted July 23, 2012 Share Posted July 23, 2012 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 More sharing options...
Ghaunadaur Posted July 23, 2012 Share Posted July 23, 2012 I would guess you have to use a function with RegisterForUpdateGameTime(24) and an event OnUpdateGameTime(). http://www.creationkit.com/OnUpdateGameTime_-_Form Link to comment Share on other sites More sharing options...
gasti89 Posted July 23, 2012 Share Posted July 23, 2012 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 More sharing options...
DavidD Posted July 23, 2012 Share Posted July 23, 2012 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 More sharing options...
mounty1512 Posted July 23, 2012 Author Share Posted July 23, 2012 Thanks to everyone for the replies. I've added the script but for some reason my previous quest has corrupted itself so i will need to fix that before i can see if this works. Link to comment Share on other sites More sharing options...
steve40 Posted July 24, 2012 Share Posted July 24, 2012 See this thread :thumbsup: Link to comment Share on other sites More sharing options...
mounty1512 Posted July 25, 2012 Author Share Posted July 25, 2012 (edited) 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 July 25, 2012 by mounty1512 Link to comment Share on other sites More sharing options...
steve40 Posted July 25, 2012 Share Posted July 25, 2012 (edited) 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 July 26, 2012 by steve40 Link to comment Share on other sites More sharing options...
gasti89 Posted July 25, 2012 Share Posted July 25, 2012 Shouldn't it be "Scriptname miningquest extends Quest"? Link to comment Share on other sites More sharing options...
mounty1512 Posted July 26, 2012 Author Share Posted July 26, 2012 Thanks steve40 worked perfectly. Link to comment Share on other sites More sharing options...
Recommended Posts