Difference between revisions of "User:PROXiCiDE/GetSleepStateEx"
Jump to navigation
Jump to search
imported>PROXiCiDE (Created page with " Extended version of GetSleepState. Helpful detecting if a actor is sleeping in a interior while the player is in a exterior due to the limitation of GetSleepState. If the act...") |
imported>PROXiCiDE |
||
Line 1: | Line 1: | ||
Adds or Removes items from the player inventory / spell list. | |||
== Syntax == | == Syntax == | ||
<source lang="papyrus"> | <source lang="papyrus"> | ||
Function AddItemsToPlayerFromForm(FormList pList, Bool bRemove = False) | |||
</source> | </source> | ||
== Parameters == | == Parameters == | ||
* | *pList: The form list containing Spells / Ammo / Weapon. | ||
* | *bRemove : Items from the FormList will be removed instead of added to the player. | ||
**'''Default''': False | |||
**'''Default''': | |||
== Return Value == | == Return Value == | ||
None | |||
== Example == | == Example == | ||
<source lang="papyrus"> | <source lang="papyrus"> | ||
FormList Property _PX_DebugSpellList Auto | |||
Event OnInit() | |||
; | ;Debug | ||
AddItemsToPlayerFromForm(_PX_DebugSpellList) | |||
EndEvent | |||
</source> | </source> | ||
== Script == | == Script == | ||
<source lang="papyrus"> | <source lang="papyrus"> | ||
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) | |||
If | |||
EndIf | EndIf | ||
ElseIf fmItem As Ammo | |||
If | pAmmo = fmItem As Ammo | ||
If bRemove | |||
pPlayer.RemoveItem(fmItem, 100) | |||
Else | |||
pPlayer.AddItem(fmItem, 100) | |||
EndIf | EndIf | ||
ElseIf fmItem As Weapon | |||
If | pWeapon = fmItem As Weapon | ||
If bRemove | |||
pPlayer.RemoveItem(fmItem, 1) | |||
Else | |||
pPlayer.AddItem(fmItem,1) | |||
EndIf | EndIf | ||
EndIf | EndIf | ||
EndWhile | |||
If !bRemove | |||
pPlayer.EquipItem(pAmmo) | |||
pPlayer.EquipItem(pWeapon) | |||
EndIf | EndIf | ||
EndFunction | EndFunction | ||
</source> | </source> | ||
Revision as of 17:30, 7 February 2014
Adds or Removes items from the player inventory / spell list.
Syntax
Function AddItemsToPlayerFromForm(FormList pList, Bool bRemove = False)
Parameters
- 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
None
Example
FormList Property _PX_DebugSpellList Auto
Event OnInit()
;Debug
AddItemsToPlayerFromForm(_PX_DebugSpellList)
EndEvent
Script
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 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
pPlayer.EquipItem(pAmmo)
pPlayer.EquipItem(pWeapon)
EndIf
EndFunction