Jump to content

[LE] Remove Function Not Working With Array


Recommended Posts

I am trying to get a random selection from an array and then remove that item from the list of options. However, when I try to do that, I am told remove is not a function or does not exist. Am I doing this properly?

 

My code is below, at least the parts that are important:

 

Scriptname SirBeastXM02PrepQuestScript extends Quest
;-----Properties
;In charge of all possible locations
Location[] Property HaafingarLoc Auto
Location[] Property ReachLoc Auto
Location[] Property WinterholdLoc Auto
Location[] Property WhiterunLoc Auto
Location[] Property RiftLoc Auto
Location[] Property FalkreathLoc Auto
Location[] Property EastmarchLoc Auto
Location[] Property HoldLocations Auto
int ArrayRandFindHold
Int ArrayRandFind
Int ArrayRemove
Location FirstHoldLocation
Location SecondHoldLocation
Location ThirdHoldLocation
Location FourthHoldLocation
Location FirstLocation
Location SecondLocation
Location ThirdLocation
Location FourthLocation
;-----Events
Event OnInit()
HoldsArrayLength = HoldLocations.length
;Debug.trace("There are " + HoldsArrayLength + " locations in Hold Locations Array.")
HaafingarArrayLength = HaafingarLoc.length
;Debug.trace("There are " + HaafingarArrayLength + " locations in the Haafingar Array.")
ReachArrayLength = ReachLoc.length
;Debug.trace("There are " + ReachArrayLength + " locations in the Reach Array.")
WinterholdArrayLength = WinterholdLoc.length
;Debug.trace("There are " + WinterholdArrayLength + " locations in the Winterhold Array.")
WhiterunArrayLength = WhiterunLoc.length
;Debug.trace("There are " + WhiterunArrayLength + " locations in the Whiterun Array.")
RiftArrayLength = RiftLoc.length
;Debug.trace("There are " + RiftArrayLength + " locations in the Rift Array.")
FalkreathArrayLength = FalkreathLoc.length
;Debug.trace("There are " + FalkreathArrayLength + " locations in the Falkreath Array.")
EastmarchArrayLength = EastmarchLoc.length
;Debug.trace("There are " + EastmarchArrayLength + " locations in the Eastmarch Array.")
;Debug.messagebox(HoldLocations)
;ArrayRandFindHold = Utility.RandomInt(0, (HoldsArrayLength - 1))
;FirstLocation = HoldLocations[ArrayRandFindHold]
; Debug.trace(FirstLocation + "has been found.")
EndEvent
Event OnUpdate()
if XM02Prep.GetStage() == 10
;Assign location aliases
;Alias One
ArrayRandFindHold = Utility.RandomInt(0, (HoldsArrayLength - 1))
FirstHoldLocation = HoldLocations[ArrayRandFindHold]
HoldLocations.Remove(ArrayRandFindHold)
;Alias two
ArrayRandFindHold = Utility.RandomInt(0, (HoldsArrayLength - 1))
SecondHoldLocation = HoldLocations[ArrayRandFindHold]
HoldLocations.Remove(ArrayRandFindHold)
endif
EndEvent
Thank you for all the help.

 

Link to comment
Share on other sites

There is no remove function for array forms. Only for formlists.

 

The closest you can get to "removing" elements from an array is by changing them to the defaults of the array's type.

 

For example a string array will have a default of "", ints = 0, floats = 0.0, forms/objectreferences = none

 

Array.Find/RFind can be used for this purpose. It returns the index of the element. You can search arrays with that.

Edited by Rasikko
Link to comment
Share on other sites

As Rasikko just wrote FormLists are the way to go here. You snippet of code is to small to find out out, what would be the best solution for papyrus scripting.

 

SirBeastXM02PrepQuestScript

  Reveal hidden contents

 

Link to comment
Share on other sites

  • Recently Browsing   0 members

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