Jump to content

AddItem at certain times after conditions


Meridias561

Recommended Posts

Yep.

 

 

Scriptname TCHavenKeepStarterChestScript extends ObjectReference  

;assuming I understand this right, the function sets the timer and
;when the timer ends, fires the event allowing for fast travel ends, etc

float property HoursTilNextNoon auto
ObjectReference Property chest  Auto  
MiscObject Property OreIron  Auto  
Location Property Embershard  Auto  
ObjectReference Property HavenSiteMarker Auto

float function GetCurrentHourOfDay()
float Time = Utility.GetCurrentGameTime()
Time -= Math.Floor(Time)
Time *= 24
Return Time
EndFunction

function SetTimerForHavenKeepSupply()
HoursTilNextNoon = GetCurrentHourOfDay()
if HoursTilNextNoon < 12
;it is before noon
	RegisterForSingleUpdateGameTime(HoursTilNextNoon)
elseif HoursTilNextNoon == 12
;it is noon, set for next day
	RegisterForSingleUpdateGameTime(24)
else
;it is after noon
	HoursTilNextNoon = 36 - HoursTilNextNoon
	RegisterForSingleUpdateGameTime(HoursTilNextNoon)
endif
endFunction

event OnInit()
SetTimerForHavenKeepSupply()

EndEvent

Event OnUpdateGameTime()
if (HavenSiteMarker.IsEnabled())
	if (Embershard.IsCleared())
		chest.AddItem(OreIron, 1, true)
		Debug.Notification("Adding....?")
	endif

;actual stuff for AddItem and such goes here
endif
SetTimerForHavenKeepSupply()
endEvent

 

Edited by Meridias561
Link to comment
Share on other sites

Given that you're getting the Debug message, the problem lies in the AddItem line, so here's some things to try:

change the line to;

 

                        chest.AddItem(OreIron, 1, 1) 

 

or shift the additem line to below the debug line.

 

Otherwise, is the chest a respawning container?

is the chest reference pointing at the correct chest?

shouldn't the chest reference be declared as a container?

is the oreiron reference pointing at the correct version of iron ore?

 

I think that's it, unless you've got a previous version of the script saved in the savegame you're using for testing and the game's running that instead of the current one.

Edited by Eckss
Link to comment
Share on other sites

Is this script assigned to the chest directly?

 

If so, you have no need to declare the chest as a property. Just use Self instead. -- If you do wish to test this, then be sure to clear the current property value on the form first before deleting it from the script file. Otherwise you will get warnings in the papyrus log.

 

Also is the chest a respawning chest? If so then it may not work at all. From the wiki

An item added to a respawning chest using AddItem will most likely not appear. This is due to the chest resetting its contents every day or so. If the player has not talked to the merchant recently, their inventory will reset before they see the item in it.
Link to comment
Share on other sites

  • Recently Browsing   0 members

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