Difference between revisions of "Talk:Arrays (Papyrus)"
Confirming that arrays are passed by value
imported>JaxFirehart (Perhaps arrays or passed by value rather than reference?) |
imported>JaxFirehart (Confirming that arrays are passed by value) |
||
Line 218: | Line 218: | ||
</source> | </source> | ||
--[[User:JaxFirehart|JaxFirehart]] ([[User talk:JaxFirehart|talk]]) 16:16, 30 August 2012 (EDT) | --[[User:JaxFirehart|JaxFirehart]] ([[User talk:JaxFirehart|talk]]) 16:16, 30 August 2012 (EDT) | ||
: I modified this script as thus: | |||
<source lang="papyrus"> | |||
Form[] property playerEquipArray auto; | |||
Form[] Function GetEquipment(Actor akActor) | |||
int count = 0; | |||
Form[] akEquipList = new Form[11]; | |||
Form tempSlot; | |||
tempSlot = akActor.GetWornForm(1); This is an skse function that gets the worn form if given a slot | |||
if (tempSlot != None) && (akEquipList.find(tempSlot) < 0) ;Ensures that something was found and that it is not already in the array | |||
akEquipList[count] = tempSlot; Assigns currently worn form to the current slot in the array | |||
count += 1; Increments the array index | |||
endif | |||
;SNIP | |||
while (count < 11) | |||
akEquipList[count] = None; | |||
count += 1; | |||
endWhile | |||
endFunction | |||
Event OnActivate(ObjectReference akActionRef) | |||
playerEquipArray = GetEquipment(Game.GetPlayer()); Player is definitely wearing something when tested | |||
debug.messagebox(playerEquipArray[0].GetName()); Outputs "Shrowded Cowl" as expected | |||
endEvent | |||
</source> | |||
: It now works as expected, this confirms to me that arrays are passed by value unless someone can explain how I am wrong | |||
--[[User:JaxFirehart|JaxFirehart]] ([[User talk:JaxFirehart|talk]]) 16:41, 30 August 2012 (EDT) |