Jump to content

Scripting question/help - Item Array


soulbladex

Recommended Posts

I don't know if anyone can help me out, but I am trying to create an array that holds the values of 10 items. I want the script below to select one of the 10 items at random after a menu option is selected and place the item on the floor. Thanks for any help/suggestions.

 

 

Scriptname RandomItemArray extends ObjectReference

Actor Property PlayerREF Auto
ObjectReference property ItemPlacementMarker auto
Message property OptionsMenu Auto
FormList Property ListOfItems Auto

Event OnActivate(ObjectReference akActionRef)
If akActionRef == PlayerREF
OpenMenu()
EndIf
EndEvent

 

Function OpenMenu(int aiButton = 0)
aiButton = OptionsMenu.show()

If aiButton == 0 ; Cancel Button
ElseIf aiButton == 1

Int RandomNumber = Utility.RandomInt(0,9)

Int iIndex = ListOfItems.GetSize()
While iIndex
iIndex -= 1
ObjectReference RandomItem = ListOfItems.GetAt(iIndex) As ObjectReference
If RandomNumber == 0
ElseIf RandomNumber == iIndex
ItemPlacementMarker.placeAtMe(RandomItem, 1)
EndIf
EndWhile

EndIf
EndFunction

Link to comment
Share on other sites

so... move the objectplacementmarker to where you want the item to appear before you place the item... unless it's already there in a static location... check your papyrus log to see if you're getting any errors?

Link to comment
Share on other sites

I just realized you are the one that helped me the other day with my other question. Thanks!

 

I am trying to convert my lengthy "if/then" based script to a shorter array based script. The script you saw the other day works perfectly, but I am running out of space in the script. I hit line 621 and can no longer type/paste anything.

Link to comment
Share on other sites

  • Recently Browsing   0 members

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