Difference between revisions of "User:PROXiCiDE/AddItemsToPlayerFromForm"

From the CreationKit Wiki
Jump to navigation Jump to search
imported>PROXiCiDE
(Created page with " == Syntax == <source lang="papyrus"> Function AddItemsToPlayerFromForm(FormList pList, Bool bRemove = False) </source> == Parameters == *pList: The form list containing Spe...")
 
imported>PROXiCiDE
m
 
(One intermediate revision by the same user not shown)
Line 1: Line 1:
 
==Overview==
'''AddItemsToPlayerFromForm()''' is useful for Debugging


== Syntax ==
== Syntax ==
Line 45: Line 46:
Else
Else
pPlayer.AddSpell(pSpell)
pPlayer.AddSpell(pSpell)
EndIf
ElseIf (fmItem As Potion) || (fmItem As Scroll) || (fmItem As SoulGem)
If bRemove
pPlayer.RemoveItem(fmItem, 5)
Else
pPlayer.AddItem(fmItem, 5)
EndIf
EndIf
ElseIf fmItem As Ammo
ElseIf fmItem As Ammo
Line 64: Line 71:
If !bRemove
If !bRemove
pPlayer.EquipItem(pAmmo)
If pAmmo != None
pPlayer.EquipItem(pWeapon)
pPlayer.EquipItem(pAmmo)
EndIf
If pWeapon != None
pPlayer.EquipItem(pWeapon)
EndIf
If pSpell != None
pPlayer.EquipSpell(pSpell,1)
EndIf
EndIf
EndIf
EndFunction
EndFunction
</source>
</source>

Latest revision as of 21:06, 25 March 2014

Overview[edit | edit source]

AddItemsToPlayerFromForm() is useful for Debugging

Syntax[edit | edit source]

Function AddItemsToPlayerFromForm(FormList pList, Bool bRemove = False)

Parameters[edit | edit source]

  • pList: The form list containing Spells / Ammo / Weapon.
  • bRemove : Items from the FormList will be removed instead of added to the player.
    • Default: False

Return Value[edit | edit source]

None

Example[edit | edit source]

FormList Property _PX_DebugSpellList Auto
Event OnInit()
	;Debug
	AddItemsToPlayerFromForm(_PX_DebugSpellList)
EndEvent

Script[edit | edit source]

Function AddItemsToPlayerFromForm(FormList pList, Bool bRemove = False)
	If pList == None
		Return
	EndIf
	
	Actor pPlayer = Game.GetPlayer()
	Ammo pAmmo = None
	Weapon pWeapon = None
	Spell pSpell = None
	
	Int Size = pList.GetSize()
	While Size > 0
		Size -= 1
		Form fmItem = pList.GetAt(Size)
		If fmItem As Spell
			pSpell = fmItem As Spell
			If bRemove
				pPlayer.RemoveSpell(pSpell)
			Else
				pPlayer.AddSpell(pSpell)
			EndIf
		ElseIf (fmItem As Potion) || (fmItem As Scroll) || (fmItem As SoulGem)
			If bRemove
				pPlayer.RemoveItem(fmItem, 5)
			Else
				pPlayer.AddItem(fmItem, 5)
			EndIf
		ElseIf fmItem As Ammo
			pAmmo = fmItem As Ammo
			If bRemove
				pPlayer.RemoveItem(fmItem, 100)
			Else
				pPlayer.AddItem(fmItem, 100)
			EndIf
		ElseIf fmItem As Weapon
			pWeapon = fmItem As Weapon
			If bRemove
				pPlayer.RemoveItem(fmItem, 1)
			Else
				pPlayer.AddItem(fmItem,1)
			EndIf
		EndIf
	EndWhile
	
	If !bRemove
		If pAmmo != None
			pPlayer.EquipItem(pAmmo)
		EndIf
		If pWeapon != None
			pPlayer.EquipItem(pWeapon)
		EndIf
		If pSpell != None
			pPlayer.EquipSpell(pSpell,1)
		EndIf
	EndIf
EndFunction