Difference between revisions of "Talk:Arrays (Papyrus)"
Jump to navigation
Jump to search
m
→Finding highest value
imported>Lisselli |
imported>Lisselli |
||
Line 271: | Line 271: | ||
== Finding highest value == | == Finding highest value == | ||
Attempting my hand at explaining arrays. My | Attempting my hand at explaining arrays. My examples has been tested. Let's say you want to return the highest value of an index. | ||
<source lang="papyrus"> | <source lang="papyrus"> | ||
Float Function GetNumbers() | Float Function GetNumbers() | ||
Float[] fNums = new Float[5] | Float[] fNums = new Float[5] ; This is the number of available slots.(0-4) | ||
fNums[0] = 100.0 | fNums[0] = 100.0 | ||
fNums[1] = 100.0 | fNums[1] = 100.0 | ||
Line 296: | Line 296: | ||
return fHighestValue ; return highest value | return fHighestValue ; return highest value | ||
EndFunction | |||
</source> | |||
Let's say you want to get how many skills a player has that are maxed. | |||
<source lang="papyrus"> | |||
Int Function GetNumMaxSkills() | |||
; returns the number of skills that are capped. | |||
Actor Player = Game.GetPlayer() | |||
Float[] fSkills = new Float[18] ; Available slots(0-17) | |||
fSkills[0] = Player.GetActorValue("Alteration") | |||
fSkills[1] = Player.GetActorValue("Alchemy") | |||
fSkills[2] = Player.GetActorValue("Block") | |||
fSkills[3] = Player.GetActorValue("Conjuration") | |||
fSkills[4] = Player.GetActorValue("Destruction") | |||
fSkills[5] = Player.GetActorValue("Enchanting") | |||
fSkills[6] = Player.GetActorValue("HeavyArmor") | |||
fSkills[7] = Player.GetActorValue("Illusion") | |||
fSkills[8] = Player.GetActorValue("Lockpicking") | |||
fSkills[9] = Player.GetActorValue("LightArmor") | |||
fSkills[10] = Player.GetActorValue("Marksman") | |||
fSkills[11] = Player.GetActorValue("OneHanded") | |||
fSkills[12] = Player.GetActorValue("Pickpocket") | |||
fSkills[13] = Player.GetActorValue("TwoHanded") | |||
fSkills[14] = Player.GetActorValue("Restoration") | |||
fSkills[15] = Player.GetActorValue("Sneak") | |||
fSkills[16] = Player.GetActorValue("Smithing") | |||
fSkills[17] = Player.GetActorValue("Speechcraft") | |||
Int index = fSkills.Length | |||
Int iCount | |||
While index | |||
index -= 1 ; Start from the last index. | |||
if fSkills[index] == 100.0 ; Find any skill that is lvl 100. | |||
iCount += 1 ; Record how many were found. | |||
endif | |||
EndWhile | |||
return iCount | |||
EndFunction | EndFunction | ||
</source> | </source> |