So I have seem some tutorials here and there but they do not answer a question for me to help me with this scenario. You see I am currently writing a new custom script for a "Hopper" workshop item. It is based on WorkShop Hopper 03 in the creation kit. This script ofcourse extends from DLC05:WorkshopHopperScript.
However I want to do something a bit more to this, to "Throttle" and to limit the fucntion cals I need to use a timer. However I want this timer to actually "Reset" everytime the Self.AddItem() happens here. The intial time will be 60 seconds (1minute) but I am gonna change it for testing later. And yes if you look into the code, this script is going to interact with Sim Settlements 2. However since KingsGrath did not yet publicied the code, I have removed the original code here to prevent leakage and to respect his work.
Testing of my code has made it that it kind will lag if a lot of items are processed through Sim Settlements 2. So that is why I am introducing some throteling.
Scriptname TS91_SS2ConveyorStorage:SS2ConveyorStorage extends DLC05:WorkshopHopperScript
SECRET Property SECRET Auto Const
workshopscript Property kWorkshopRef Auto hidden
float countdownTimer1 = 60.0 Auto Hidden ; Initial countdown timer value
Int Property TimerID = 1 Auto
Int Property TimerCount = 0 Auto
Event OnInit()
; initialize current projectile values
SetOutputForce(ProjectileMagnitude)
kWorkshopRef = Self.GetLinkedRef(WorkshopItemKeyword) as workshopscript ; #DEBUG_LINE_NO:3
endEvent
Event OnTriggerEnter(ObjectReference akActionRef)
If bAllowTriggerInput ; #DEBUG_LINE_NO:4
If akActionRef.IsDisabled() == False ; #DEBUG_LINE_NO:5
If akActionRef is Actor == False ; #DEBUG_LINE_NO:6
If akActionRef.GetBaseObject() is Container ; #DEBUG_LINE_NO:7
Self.AddContainer(akActionRef) ; #DEBUG_LINE_NO:8
Self.StartCheckContainersTimer() ; #DEBUG_LINE_NO:9
; Start counting Timer here.
Else ; #DEBUG_LINE_NO:
Self.AddItem(akActionRef)
Debug.Trace("SS2ConveyorStorageScript:" + "Container:" + self + "Workshop:" + kWorkshopRef)
if Self.GetItemCount() > 10
Debug.Notification("Item Treshold reached")
ExecuteSimSettlements2Code()
if Self.GetItemCount() > 1
kWorkshopRef.AddItem(akActionRef as Form, 1, False)
EndIf
EndIf
EndIf ; #DEBUG_LINE_NO:
EndIf ; #DEBUG_LINE_NO:
EndIf ; #DEBUG_LINE_NO:
EndIf ; #DEBUG_LINE_NO:
EndEvent
Function ExecuteSimSettlements2Code()
If TimeISRUN OUT executed the code
SECRET CODE GETS EXUTED HERE
; Reset Time here
endFunction