BunnyPriestess

MoveItemsToChest Papyrus Script Example

Jun 13th, 2024 (edited)
145
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.18 KB | Gaming | 0 0
  1. Function MoveListItemsToChest()
  2.  
  3. Actor Player = Game.GetPlayer()
  4. ;Shorten the script
  5. Int FormToFind = 0
  6. ;We'll use this to iterate through the list
  7. Int MaxSize = Myformlist.GetSize()
  8. ;Find the Maxsize of the formlist so we can end the script if it goes above this number
  9.  
  10. While FormToFind <= MaxSize
  11. ;This will cause the script to loop until the full list is is iterated through
  12.  
  13. Int ItemToMoveCount = Player.GetItemCount(Myformlist.GetAt(FormToFind))
  14. ;Count of The Object we want to move in players inventory
  15. Form ItemToMove = MyFormlist.GetAt(FormToFind)
  16. ;The item We Want To Move
  17.  
  18. If ItemToMoveCount >= 1
  19. ;Skip all the other script if the player has zero
  20. Player.RemoveItem(ItemToMove,ItemToMoveCount,MyChest)
  21. ;Remove all of The item from the player add them to MyChest
  22. Debug.Notification("Removed "+ItemToMoveCount+ItemToMove+" from the player")
  23. ;Optional debug message to tell us what was removed
  24. FormToFind += 1
  25. ;Iterate to next form in list
  26. ElseIf ItemToMoveCount == 0
  27. ;Player Does Not have the Item
  28. FormToFind += 1
  29. ;Iterate to next form in list
  30. EndIf
  31. EndWhile
  32.  
  33. EndFunction
  34.  
  35. FormList Property MyFormlist Auto
  36. ObjectReference Property MyChest Auto
Tags: Script Papyrus
Advertisement
Add Comment
Please, Sign In to add comment