Jump to content

[LE] Script Help - Fusing Soul Gem Pieces


Nyrolian

Recommended Posts

Ah, if you wanted to do it that way you could do something like this:

 

Function TakeAway(int PiecesToRemove, ObjectReference Player, Form ObjectToGive)

    Int index = 0
    Int M = SoulGemPieces.GetSize()
    
    While PiecesToRemove > 0
        Form Entry = SoulGemPieces.GetAt(index)
        If  Player.GetItemCount(Entry) > 0
            Player.RemoveItem(Entry,1,true)
            PiecesToRemove -= 1
        EndIf
        
        index += 1
        
        If index >= M 
            index = 0 ;cycle through again.
        Endif
    EndWhile

    Player.AddItem(ObjectToGive)

EndFunction

That way, if PiecesToRemove == 4 and the player has say 2 of one type and 2 of another rather than 1 of each the function will still work.

Link to comment
Share on other sites

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...