Jump to content

Ideas: Cooking Snow


Zorkaz

Recommended Posts

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

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 by NoCashNoExp
Link to comment
Share on other sites

  • Recently Browsing   0 members

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