Difference between revisions of "User talk:Lisselli"
Jump to navigation
Jump to search
no edit summary
imported>Lisselli |
imported>Lisselli |
||
Line 1: | Line 1: | ||
Sandbox Page for when I need to post code on the forums. Because it doesn't allow indention.. | Sandbox Page for when I need to post code on the forums. Because it doesn't allow indention.. | ||
<source lang="papyrus"> | |||
Message property SimpleMessage auto | |||
Armor property myArmor auto | |||
ReferenceAlias property myAliasRef auto | |||
Event OnInit() | |||
; You're listening for this specific item. | |||
; This function needs to be called before using OnItemAdded/Removed | |||
AddInventoryEventFilter(myArmor) | |||
EndEvent | |||
Event OnItemAdded(Form akBaseItem, int aiItemCount, ObjectReference akItemReference, ObjectReference akSourceContainer) | |||
; You want to know if your ReferenceAlias is filled. Let's do that first. | |||
; Note: I used parenthesises to ensure important statements run in a certain order. It's not always needed though. | |||
if (myAliasRef.GetReference() != none) | |||
debug.notification("My alias is filled.") | |||
; debug.messagebox might pause/stop the script, I don't know. I prefer notification, or trace. | |||
else | |||
debug.notification("None") | |||
endif | |||
; if the item added was an armor and was myArmor | |||
if (akBaseItem as Armor == myArmor) | |||
; Here you add your armor to a variable and can do stuff with it later | |||
; Meanwhile, OnItemAdded will keep checking whatever is added to the player, but only cares about myArmor.Until you change the event filter. | |||
Armor kArmor = akBaseItem as Armor | |||
; Getting around GetItemCount's issue with properties, hopefully, and calling it on the variable. | |||
Int iMyArmorCount = Game.GetPlayer().GetItemCount(kArmor) | |||
; Print how many of myArmor was added,OR print how many instances of the object that is identicial to myArmor's base object. | |||
debug.messagebox("Total Armor Count " +iMyArmorCount) | |||
endif | |||
; If you're done with this event, remove the filter. | |||
; This is called after everything is done above. | |||
RemoveAllInventoryEventFilters() | |||
EndEvent</source><br><br> | |||
<source lang="papyrus"> | <source lang="papyrus"> | ||
Scriptname SimpleTestScript extends ObjectReference | Scriptname SimpleTestScript extends ObjectReference |