Difference between revisions of "Talk:AddInventoryEventFilter - ObjectReference"

From the CreationKit Wiki
Jump to navigation Jump to search
imported>Sollar
(Created page with "== Script to Show Gift Window and Track Items Given == This is used for the Player to feed his animal companion. The FormList is created in the CK and includes all the food ...")
 
imported>Sollar
Line 8: Line 8:


Function FeedCompanion()
Function FeedCompanion()
ObjectReference foodItem = None
AddInventoryEventFilter(FoodList)
int indexPos = FoodList.GetSize()
ShowGiftMenu(True, FoodList, False, False)
While(indexPos > 0)
RemoveAllInventoryEventFilters()
indexPos -= 1
foodItem = FoodList.GetAt(indexPos) as ObjectReference
AddInventoryEventFilter(foodItem)
EndWhile
Self.ShowGiftMenu(true, FoodList, false, False)
Self.RemoveAllInventoryEventFilters()
EndFunction
EndFunction


Line 22: Line 16:
If akSourceContainer == Game.GetPlayer()
If akSourceContainer == Game.GetPlayer()
self.RemoveItem(akBaseItem,aiItemCount)
self.RemoveItem(akBaseItem,aiItemCount)
If hasBeenFedToday == False
If !hasBeenFedToday
hasBeenFedToday=True
hasBeenFedToday=True
EndIf
EndIf

Revision as of 04:18, 28 June 2012

Script to Show Gift Window and Track Items Given

This is used for the Player to feed his animal companion. The FormList is created in the CK and includes all the food (Potion & Ingredient) items I want to consider food for the animal.

FormList Property FoodList Auto
Bool hasBeenFedToday = False

Function FeedCompanion()
	AddInventoryEventFilter(FoodList)
	ShowGiftMenu(True, FoodList, False, False)
	RemoveAllInventoryEventFilters()
EndFunction

Event OnItemAdded(Form akBaseItem, int aiItemCount, ObjectReference akItemReference, ObjectReference akSourceContainer)
	If akSourceContainer == Game.GetPlayer()
		self.RemoveItem(akBaseItem,aiItemCount)
		If !hasBeenFedToday
			hasBeenFedToday=True
		EndIf
	EndIf
EndEvent

--Sollar 03:17, 28 June 2012 (EDT)