Zorkaz Posted January 6, 2021 Share Posted January 6, 2021 Setup:So in my current frozen world snow is abundant, so it seems reasonable to melt snow in the cooking menu. Challenge:The snow should melt over an extended period of time and should not instantly become water. However how could I apply this via the crafting menu? My initial idea is to put snow into the cooking workbench in use, but unsure how to do this in a proper way Ideas are appreciated Link to comment Share on other sites More sharing options...
NoCashNoExp Posted January 6, 2021 Share Posted January 6, 2021 (edited) Ok, this is a bit complicated for your request but it might work. If you can attach this script to the cooking workbench object reference, this should make the bench automatically melt snow into water once the player moves snow to the workbench's inventory. I haven't really tested this, it's mostly just theory code. Scriptname SnowMelterScript extends ObjectReference Form Property YourModSnow Auto Const Mandatory Form Property YourModWater Auto Const Mandatory int Property timerIDIndex = 0 Auto Struct Recipe int timerID = 0 Form input Form output int itemCount = 0 EndStruct Recipe[] Property recipes Auto float timeForSnowToMelt = 60.0 Const ; In seconds Event OnInit() recipes = new Recipe[10] AddInventoryEventFilter(YourModSnow) EndEvent Event OnItemAdded(Form akBaseItem, int aiItemCount, ObjectReference akItemReference, ObjectReference akSourceContainer) ; If the player added snow to the cooking workbench If akBaseItem == YourModSnow ; If the array that is used to track recipes is not full If recipes.Length < 10 Debug.Notification("Starting New Recipe") ; Create new recipe Recipe newRecipe = new Recipe newRecipe.timerID = timerIDIndex newRecipe.input = YourModSnow newRecipe.output = YourModWater newRecipe.itemCount = aiItemCount recipes.Add(newRecipe) StartTimer(timeForSnowToMelt, timerIDIndex) timerIDIndex = timerIDIndex + 1 If timerIDIndex > 19 timerIDIndex = 0 EndIf Else Debug.Notification("Bench is full of recipes") EndIf EndIf EndEvent ; Some recipe finished its time Event OnTimer(int aiTimerID) int i = 0 ; Find the recipe in the array While i < recipes.Length && i != -1 If recipes[i].timerID == aiTimerID ; Found the recipe Recipe currentRecipe = recipes[i] ; Remove snow, add water to workbench RemoveItem(currentRecipe.input, currentRecipe.itemCount, true) AddItem(currentRecipe.output, currentRecipe.itemCount, true) ; Remove the tracked recipe from the array recipes.remove(i) ; This is used to break from the while loop if we found the recipe i = -2 Debug.Notification("Recipe Done") EndIf i = i + 1 EndWhile EndEvent Edited January 6, 2021 by NoCashNoExp Link to comment Share on other sites More sharing options...
Zorkaz Posted January 6, 2021 Author Share Posted January 6, 2021 Sounds interesting, I'll give it a try Link to comment Share on other sites More sharing options...
Recommended Posts