Categorizing your spell book

Post » Tue Nov 20, 2012 1:34 pm

My objective is to build arrays of all spells in your current spell book (including mod added). I wish to sort them by school, then powers and shouts.
Currently the only way I have found to do this is by checking the perk assigned to the spell. This is very flawed though and I can't get shouts this way. Plus the powers array fills up with a bunch of racials and other (mod added?) permanent buffs.

Spoiler
Function Spells()  Alteration = New Form[62]  Conjuration = New Form[62]  Destruction = New Form[62]  Illusion = New Form[62]  Restoration = New Form[62]  Powers = New Form[62]  Shouts = New Form[62]  int s = 0  int a = 0  int c = 0  int d = 0  int i = 0  int r = 0  int p = 0  int sh = 0  int z = player.GetSpellCount()  While s &--#60; z	Form Spell_ = player.GetNthSpell(s) as Form	If Spell_.gettype() == 22	  Perk Perk_ =  player.GetNthSpell(s).GetPerk()	  String PerkStr = ""	  If Perk_ != None		PerkStr = Perk_.getname()	  endif	  If StringUtil.Find(PerkStr, "Alter") &--#62; -1 && a &--#60; Alteration.length		Alteration[a] = Spell_		a += 1	  elseif StringUtil.Find(PerkStr, "Conjur") &--#62; -1 && c &--#60; Conjuration.length		Conjuration[c] = Spell_		c += 1	  elseif StringUtil.Find(PerkStr, "Destru") &--#62; -1 && d &--#60; Destruction.length		Destruction[d] = Spell_		d += 1	  elseif StringUtil.Find(PerkStr, "Illus") &--#62; -1 && i &--#60; Illusion.length		Illusion[i] = Spell_		i += 1	  elseif StringUtil.Find(PerkStr, "Restor") &--#62; -1 && r &--#60; Restoration.length		Restoration[r] = Spell_		r += 1	  elseif p &--#60; Powers.length		Powers[p] = Spell_		p += 1	  endif	elseif Spell_.gettype() == 119 && sh &--#60; Shouts.length	  Shouts[sh] = Spell_	  sh += 1	endif	s += 1  endwhileEndFunction

Any help would be greatly appreciated.
Thank You

EDIT: Just found GetAssociatedSkill()... smh
Just have to figure out shouts now.
User avatar
Lexy Dick
 
Posts: 3459
Joined: Mon Feb 12, 2007 12:15 pm

Post » Tue Nov 20, 2012 1:04 pm

I do not have a solution for the problem you are asking about. One observation though, since this is adding modded spells, is that the combination of vanilla and mod-related spells can lead to out-of-bounds arrays, unless arrays resize automatically. You need something in there that will resize the arrays or you are going to encounter out of bound exceptions.
User avatar
Lance Vannortwick
 
Posts: 3479
Joined: Thu Sep 27, 2007 5:30 pm

Post » Tue Nov 20, 2012 4:42 am

Thnx for the observation =]
As of now you can only store 62 items in an array then it stops filling. I plan on adding more, but I just wanted to get working for now.
User avatar
Caroline flitcroft
 
Posts: 3412
Joined: Sat Nov 25, 2006 7:05 am

Post » Tue Nov 20, 2012 1:47 pm

I do not have a solution for the problem you are asking about. One observation though, since this is adding modded spells, is that the combination of vanilla and mod-related spells can lead to out-of-bounds arrays, unless arrays resize automatically. You need something in there that will resize the arrays or you are going to encounter out of bound exceptions.
Thanks for pointing that out. I'll build on it with this:
http://www.gamesas.com/topic/1413790-resource-beyond-128-extended-array-functions-to-go-to-512-and-up/page__p__21714264__hl__array%20resource__fromsearch__1#entry21714264
Hope this helps and good luck!
User avatar
Jah Allen
 
Posts: 3444
Joined: Wed Jan 24, 2007 2:09 am


Return to V - Skyrim