   þ     " #1 "! "" ""              3  3  3 34@44033             ªª  ¼Ì
 ¼Ë
 ªª              ªª  Š¨  Š¨  ™™
 ™™
 ªª         @   À  LD  D4  @ @           P `ff fg  Vf PfV `          "3 "3!C€D€xV wf          ªª  ¼Ì
 ¼Ë
 "" ""             ª  Š  ŠD  ™4  ™  ª           #  "D  "4  "             ªª  ¼Ì
 ¼Ë
 34@44033                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                    ˆˆˆˆHDDDHDDDHID™H™D”H™™™H”™™HD™™!"""!""Ý!îîÞ!îîÞ!îîÞ!îîÞ!""Ýwwww‡ˆˆˆ‡ˆUU‡XeU‡UUV‡UVU‡UeU‡UUU3333CDDDCDDÌCDÄÌCDÎÌCîîîCNÞÝCNÞÝ™™™™©ªªª©™©ª©™ª›©™š™©™ªš©™™™©š™™UUUUuwwwewwwevwwefvwefbfef&befffîîîîþÿÿÿþÿÿÿþÿßÿþÿÝÿþßýÿþßýÿþÿÝýwwww‡ˆˆˆ‡8ˆˆ‡8ˆˆ‡8ƒˆ‡ˆ33‡ˆ33‡8wwww‡ˆˆˆ‡ˆˆˆ‡ˆˆˆ‡xVˆ‡hg…‡hvV‡ˆfgwwwwgfffgfffgfffg6fcgf3fgf3fg6c                                                                                                                                                                                                HDD™€DD”€DI™ H”” HD™ €D™  HD  €ˆ!""Ý""Ý""Ý !"Ý !"Ý "Ý  !"  ‡hfUpˆˆfpˆˆ3 ‡ˆ3 ‡ˆ3 p83  ‡ˆ  pwCNÞÝ0äÞÝ0DÞÝ Cäî CDD 0DD  CD  03©ª™™�ªª™�ªš™ ©š© ©™ª �ªª  ©ª  �™efefPgÅÅPg uf\ ugf Pwf  uw  PUþÿßÝàßýÝàÿÿÝ þÿß þÿß àÿÿ  þÿ  àî‡8pˆ31pˆ63 gcf 733 p33  73  pw‡ˆfgpˆhvpˆˆx ‡ˆˆ ‡ˆˆ pˆˆ  ‡ˆ  pwg6cpapFd gff gff pff  gf  pw                                                                                                                                                                                                îîîîÿÿÿïÝÿÿïÞÿÿïîýÿïîÞÿï^åýïU\ýïÿÿÿÿñÁñÌÍñÌÜÁñÌÁñÜÁñÜñ3333DDD4DD"4D$!43B4"1D42D4ÿ2D4""""îîî.î1î.3î.ã>.13ã.1áî.>áî.ffffwwwgUUwgUVugeUUgUUUgeUVgVeegîîîî"""â"""â""-â"Ò.â"í/â"í/âÒþ"âˆˆˆˆ™™™‰™Ù™‰™ýŸ‰Ùÿþ‰ýïÿ‰ÿþŸ‰ïÿ™‰UUUUwwwWw×ÝWw×þWw7ÿWwswW7wwWswwW»»»»ˆˆˆ¸Èˆˆ¸¸ˆŒ¸ˆ¸ˆ¸ªˆˆ¸»ŠË¸¼Šˆ¸""""""-""-""þ""þÞýþÿ/                                                                                                                                                                                                VeýïffýfÖÿfýï Ýÿï ÿÿ ÿï  î  ÌñÍÁÑñ ñ  ñ  ÿ  "2D4"CD2DDCD4 DD4 DD D4  3  îî.îã! >î. >î î.  "  Ufvgfww3ww3wg 3wg 3s wg  f  Þþ"âí/"íÞ.þòï þ"â ." "â  î  ñ™‰ù™Ÿ™‘‰ )‘‰ ™™ ™‰  ˆ  swwW7»w·£{·:Z w«W ww wW  U  »ŠË¸ªˆˆˆ¸ˆ¸ˆ¼ Èˆ¸ ˆˆ ˆ¸  »  ß""ï""ò."ò/ "/ "" "                                                                                                                                                                                                    DDDDAALA4AAAÁAªªªª»»»«»Ûî«»ëë«Ûîþ«ëëÿ«îþ¿«ëÿ»«DDDDˆˆˆHÈˆˆHˆˆˆHŒˆŒHDŒˆHˆDˆLˆHŒHÿÿÿÿñáñQÞñQïñQñÞñQïýñþ""""333#333#ÃD4#LD3#D43#D33#433#îîîîÿÿÿïÿÿÿïîÿÿïíîÿïííþïîîýï.âýïˆˆˆˆˆŠˆ¨�ˆ˜�ˆ‰¨Š¨‘Š™™™™ˆˆˆ˜""‚˜ÌÌ�˜ÞÍ‚˜ÌÌ�˜íÎ‚˜ÌÌ�˜                                                                                                                                                                                                                                                                AAÁALA 4A  A  D  þ¿»«ÿ»»
¿»»
»»« »»« »»
 »«  ª
  ˆH„HˆLˆL„È„ˆH ˆÈH Èˆ ˆH  D  ñÑíÑþõ íõ þ ñ  ÿ  DDD#DD4ÃD3L4# D3# 43 3#  "  íîþïïíþïïÿïïï îþï ÿÿ ÿï  î  š¡ˆ©ˆŠˆ¡Š ˆˆ ˆˆ ˆ    íÍ‚˜ÌÌ�	ÞÎ‚	ÌÌ‘ ’ ˆˆ	 ˆ˜  ™		>                                                                Î8 DDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDD                                                                        DDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDD                                                                        DDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDD                                                                        DDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDD                                                                        DDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDD                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                     D                                            ª  
    ª         ª     
               ªª  
                             D D D@ @DDD                               ª 
 
  ª
ªª  ª ª      ª
ªª
              Š¨    ª 
 ª 
 
                   DDD DD@D                               ª 
 
 ª
 ª 
ª 
ªª
 ª ª
  
               Š¨  ª   ª 
                       D D @D                               ªª
 
 ª
 ª 
ª
 


 ª  ª
 
               ™™
 
 
                           D @D @DD                               ª 
 ª
 ª
ª 
 ª 


 ª ªª  ª
              ™™
   ª ª 
 
                                                                                                           ªª                                                                                                                                                                                                                                                                                        D @                               À   À            À     À   Ì   À À À                                DD D @   @                           ÀÌÀ   ÀÀ  À  Ì À Ì  Ì   ÌÌÌ ÀÀ                          DD@@ @ D                            Ì À     Ì   À  Ì ÀÌÀ   Ì  ÌÀ À À Ì À                          @ @ D D                             À À    Ì   À   À À     À À  Ì À                          @DD@ @                           À     ÀÌ À   À ÌÀ    À    ÌÀ                                                                                                                                                                                                                                                                                                                                                                                                                            À   Ì   Ì        Ì         Ì      Ì À                                                      ÌÌ Ì À  Ì À  ÀÀ À  Ì À   Ì        À ÀÀ   Ì ÀÀ   Ì À                                                 ÌÌÀÌ   ÀÌ   Ì  À ÀÀ   Ì       Ì Ì     Ì À Ì À À                                                      Ì     À À            À    Ì À À Ì                                                  ÀÌÌ   Ì À  Ì À ÀÀ ÌÌ  À        À Ì     Ì ÌÀÌÀ À                                                                                                                                                                                                                                                                                                                                                                                                                         À    À   À        À            Ì          Ì        À Ì        À   À         À           À                          ÌÌ Ì Ì  ÌÀÌ À  ÌÀ   ÀÀÀÀ À Ì       ÀÌ À   À ÀÌ ÀÌ  ÀÌ  À   ÀÀÌ ÀÀ  Ì                        À ÀÀ   À   À   À      Ì     ÌÀ  ÌÀ Ì À   Ì   ÌÌ Ì ÀÌ Ì À                        À À   À Ì   À   Ì Ì À       À   À  Ì À  À          À                         Ì    ÀÀ   À   ÀÀÀ ÀÌÀ Ì      ÌÀÌ     ÌÀÀÀ Ì    À    Ì Ì ÌÌ Ì À                                                                                                                                                                                                                                                                                                                                                                                                       Ì À             À                   ª
    
        
                                                          ÀÌ Ì À   Ì À  ÀÌÌ   ÀÀ            ª  ª
 
  ª ªª ªª
 ª
                                                      Ì Ì ÀÀ À   ÌÀ Ì Ì             ª 
 
 
 ª 
ª 
 
 ª
                                                         ÌÀ À Ì  Ì À  Ì              ª 
 
 
 ª
 ª 
 
  ª
                                                      Ì Ì  ÌÌÌÀ    ÀÌ À  ÀÌ À           ª  ª
 ª
 ª ª 
 ª
ªª                                                                      À                                                                                                                                                                                                                                                                                                                                                                                                     À     À Ì              À  À   Ì                                                                                       Ì À   À ÀÌ ÀÌ     Ì ÌÌ À ÌÀ                                                                                À     ÌÀ  Ì     ÀÀ ÀÀ À                                                                                À À   À  Ì À     À À À Ì                                                                                 Ì    ÌÀÀ À   ÀÌ ÌÌ ÌÀ                                                                                                  À              À                                                                                                                                                                                                                                                                                      @D       D @                                 Ì     Ì                                                                 D DD @D   DD@D                              À    ÀÌ                                                         D D @ D @ D                              À     Ì Ì Ì À                                                        D D  @ D @  D                              À     Ì Ì                                                         D D  @D D  DDD                              Ì    ÌÀ ÀÌ                                                                                                                                                                                                                                                                                                                                                                                                                                          Ì           Ì                       Ì   À                                                              Ì Ì ÀÀ   À Ì À  À             À   À ÌÀÌ À                                                     Ì À Ì     Ì Ì   Ì Ì Ì              Ì    Ì À                                                        Ì À       Ì  Ì               À    À Ì  À                                                     ÌÀ    Ì À ÀÌ    À                    À  ÀÀ                                                                                                                       À                                                                                                                                                                                                                                                                                                                 Ì           Ì    À   À          À    ÌÀ                                                                Ì Ì ÀÀ   À Ì À  À Ì   Ì   Ì À      À   Ì                                                               Ì À Ì     Ì Ì   À Ì ÀÀ À      Ì    À À                                                               Ì À      À  À À Ì     À   À                                                              ÌÀ    Ì À ÀÌ   À  ÌÀ À       Ì    À                                                                                                      À                                                                                                                                                                                                                                                                                                                               ÀÀ           Ì   À     À À   Ì                Ì    Ì À     Ì                                                           ÌÀ Ì À  À ÌÀÌ Ì  Ì À                À     À  Ì Ì À                                                   À À Ì   Ì À À À ÀÀ                Ì    Ì À   Ì À                                                    À  Ì   À Ì À À À                À   À Ì  Ì                                                   Ì   À     À  À À ÌÌ               Ì    Ì À    Ì Ì                                                              À                                              À         À                                                                                                                                                                                                                                                                                                         ˆˆˆˆˆˆˆˆàîîîîîîî                       À À    Ì   À       Ì  À     À                                                 ˆˆˆˆˆˆˆˆàîîîîîîî                       Ì À     ÌÌ   ÌÌ ÌÀ  Ì                                               ˆDDDDDDDðÿÿÿÿÿÿï                       À     Ì Ì À ÌÀ  ÀÀ Ì À À                                              ˆDDDDDDDðÿÿÿÿÿÿï                       À À     À   À Ì  À                                               ˆDDDDDDDÐÝýÿÿÿÿï                       ÌÌ       À Ì  Ì À À Ì                                              ˆDDDDDDDÐÝýÿÿÿÿï                                                                                                       ˆD™DDD™™àÞýÿÿÿÿï                                                                                                       ˆD™DDD™™àÞýÿÿÿÿï                                                                                                       ˆD™™DDD™àîÞýÿÿÿï                        ª
ª   ª  
  
                                                                  ˆD™™DDD™àîÞýÿÿÿï                       ª
 ª 
    
  
  ª
                                                              ˆD™™™™™™àîîÞýÿÿï                        ª ªª  ª  
  
 ª
                                                               ˆD™™™™™™àîîÞýÿÿï                        ª
ª 
 ª  
  
  ª
                                                              ˆDD™™™™™à^UåÞýÿï                       ªª ª 
 ª  ª
 ª
ªª                                                               ˆDD™™™™™à^UåÞýÿï                                                                                                       ˆDDD™™™™PUÅ\Õýÿï                                                                                                       ˆDDD™™™™PUÅ\Õýÿï                                                                                                       ˆDDDDD™™`VUeÖýÿï                        ªª  ª       
       À                                                          ˆDDDDD™™`VUeÖýÿï                        Š¨      
 
 ª  ÀÀ Ì                                                           ˆDDDDD™`fffÖýï                         Š¨    
 ª ª 
   ÌÀÀÀÀ                                                           ˆDDDDD™`fffÖýï                         ™™
       
 
  ÀÀÀÀÀÀ                                                           ˆDD™D™™`ffÖýÿï                         ™™
 ª   ª 
    ÀÌÀÀ Ì                                                           ˆDD™D™™`ffÖýÿï                         ªª                                                                               ˆDD™D™`fÖýÿï                                                                                                           ˆDD™D™`fÖýÿï                                                                                                           ˆDDD™™ÐÝýÿÿï                          "3         UP  PP  À     À   ÀÀÀ                                            ˆDDD™™ÐÝýÿÿï                         "3PPPPP  P PP      À   ÌÀÀ  ÀÀ                                             ˆDD™™ðÿÿÿï                          !CPUPPPP   P     ÀÀ À À  ÀÌ                                             ˆDD™™ðÿÿÿï                          €DPPPP U   PP     ÀÀ À À   À                                              ˆDDDðÿÿï                           €xVPPPP P  PPP PUPU  ÀÀ  ÌÀÀ   ÀÀ                                              ˆDDDðÿÿï                            wf                     À                                                           ˆˆˆàîî                                                                                                                 ˆˆˆàîî­, -- title:   vagabond pulp creator
-- author:  Georg Mir, @eisenfuchs on IG
-- desc:    a quick visual character creator
-- site:    https://www.drivethrurpg.com/en/product/512122/vagabond-pulp-fantasy-rpg-core-rulebook
-- license: MIT License (change this to your license of choice)
-- version: 0.1
-- script:  lua

t=0
x=96
y=24
section = 1
pick = 1
step = 1
count = 0

maxsection = 2
maxpick = {8, 18}

lineheight = 8

classpick = 1
ancestrypick = 1

stat = {
	{"Might", 2, 256, 2},
	{"Dexterity", 3, 257, 3},
	{"Awareness", 11, 258, 11},
	{"Reason", 10, 259, 10},
	{"Presence", 4, 260, 4},
	{"Luck", 6, 261, 6},
 {"-none-", 13, 262, 13},
 {"Mit or Awa", 2, 263, 11}, 
 {"Rea or Pre", 10, 264, 4},
 {"Mit or Pre", 2, 265, 4},
 {"Dex or Awa", 3, 266, 11},
}

skill = {
	{"Melee", 1},
	{"Brawl", 1},
	{"Finesse", 2},
	{"Sneak", 2},
	{"Detect", 3},
	{"Mystic.", 3},
	{"Survival", 3},
	{"Ranged", 3},
	{"Arcana", 4},
	{"Craft", 4},
	{"Medic.", 4},
	{"Influ.", 5},
	{"Lead.", 5},
	{"Perform.", 5},
 {"Any Skill", 7},
}

creaturetype = {
 {"Humanlike"},
 {"Fae"},
 {"Cryptid"}
}

ancestry = {
	{"Human",   288,  4, 1, "Knack: Bonus Perk", "Knack: Bonus Training", "Strong Potential", 
			"Humans are social &", 
			"that tend to develop", 
			"sprawling empires."},
	{"Dwarf",   289,  2, 1, "Darksight", "Sturdy", "Tough", 
			"Dwarves are built", 
			"from sterner stuff", 
			"maybe even forged"},
	{"Elf",     290,  6, 2, "Ascendancy", "Elven Eyes", "Naturally Attuned", 
			"Elves are known for", 
			"their etheral beauty", 
			"and curious passion"},
	{"Halfling",291,  3, 1, "Nimble", "Squat", "Tricky", 
			"Halflings are plucky", 
			"hill-dwelling folk", 
			"and rise to any task"},
	{"Draken",  292,  9, 3, "Breath Attack", "Scale", "Draconic Resilience", 
			"Humanoid dragons", 
			"elementally charged", 
			"and very resilient"},
	{"Goblin",  293,  5, 3, "Darksight", "Nimble", "Scavenger", 
			"Havoc-wagers known", 
			"to delight in chaos", 
			"goblins are small"},
	{"Orc",     294, 14, 3, "Darksight", "Beefy", "Hulking", 
			"Orcs are night-kin", 
			"with a wide variety", 
			"of mutated looks"},
	{"Michtim", 295,  7, 2, "Darksight", "Naturally Attuned", "Squat", 
			"Michtims are small,", 
			"fae hamster beings", 
			"protecting the woods"}
}

class = {
	{"Alchemist", 
		"Use (Craft & Attack)", 
		"Backline", 
		"Alchemist or Assassin", 
		4, 
		-- fixed skills
		-- #picks 
		-- skill list
		{10},
		4,
		{15},
		"Alchemy", "Catalyze",
		"Eureka",
		"Potency",
		"Mix",
		"Big Bang",
		"Prima Materia", 320, 4},
	{"Barbarian", 
		"Attack (Melee)", 
		"Frontline", 
		"Gladiator or Warrior", 
		1, 
		-- fixed skills
		-- #picks 
		-- skill list
		{1,2},
		3,
		{5,6,7,12,13},
		"Rage", "Wrath",
		"Aggressor",
		"Fearmonger",
		"Mindless Rancor",
		"Bloodthirsty",
		"Rip and Tear", 321, 2},
	{"Bard", 
		"Virtuoso", 
		"Midline/Backline", 
		"Musician", 
		5, 
		-- fixed skills
		-- #picks 
		-- skill list
		{14},
		4,
		{15},
		"Virtuoso", "Well-Versed",
		"Song of Rest",
		"Starstruck",
		"Bravado",
		"Climax",
		"Starstruck II", 322, 2},
	{"Dancer", 
		"Step Up", 
		"Midline", 
		"Courtesan or Musician", 
		2, 
		-- fixed skills
		-- #picks 
		-- skill list
		{3,14},
		2,
		{2,4,12},
		"Fleet of Foot", "Step Up",
		"Evasive",
		"Don't Stop Me Now",
		"Choreographer",
		"Flash of Beauty",
		"Double Time", 323, 2},
	{"Druid", 
		"Cast or Beast Attacks", 
		"Midline", 
		"Hermit", 
		3, 
		-- fixed skills
		-- #picks 
		-- skill list
		{6},
		3,
		{2,5,7,10,11},
		"Primal Mystic", "Feral Shift",
		"Tempest Within",
		"Innervate",
		"Ancient Growth",
		"Savagery",
		"Force of Nature", 324, 3},
	{"Fighter", 
		"Attack", 
		"Flexible", 
		"Warrior, Knight, Gladiator", 
		8, 
		-- fixed skills
		-- #picks 
		-- skill list
		{1,8},
		4,
		{2,3,4,5,13},
		"Fighting Style", "Valor",
		"Momentum",
		"Valor II",
		"Muster for Battle",
		"Valor III",
		"Harrying", 325, 1},
	{"Gunslinger", 
		"Attack", 
		"Backline", 
		"Bounty Hunter or Tinker", 
		3, 
		-- fixed skills
		-- #picks 
		-- skill list
		{5,8},
		3,
		{2,3,4,7,12},
		"Quick Draw", "Deadeye",
		"Skeet Shooter",
		"Grit",
		"Devastator",
		"Bad Medicine",
		"High Noon", 326, 3},
	{"Hunter", 
		"Attack", 
		"Midline or Backline", 
		"Scout or Warrior", 
		3, 
		-- fixed skills
		-- #picks 
		-- skill list
		{1,7,8},
		4,
		{15},
		"Hunter's Mark", "Survivalist",
		"Rover",
		"Overwatch",
		"Quarry",
		"Lethal Precision",
		"Apex Predator", 327, 2},
	{"Luminary", 
		"Cast", 
		"Midline/Backline", 
		"Devout", 
		3, 
		-- fixed skills
		-- #picks 
		-- skill list
		{6},
		3,
		{5,9,11,12,13},
		"Theurgy", "Radiant Healer",
		"Overheal",
		"Ever-Cure",
		"Revivify",
		"Saving Grace",
		"Life-Giver", 328, 3},
	{"Magus", 
		"Attack/Cast", 
		"Flexible", 
		"Knight, Gladiator, Warrior", 
		4, 
		-- fixed skills
		-- #picks 
		-- skill list
		{1,9},
		3,
		{2,3,4,5,6,12},
		"Spellstriker", "Esoteric Eye",
		"Spell Parry",
		"Arcane Recall",
		"Spell Surge",
		"Aegis Obscura",
		"Spell Surge II", 329, 4},
	{"Merchant", 
		"Use", 
		"Flexible (skip to Use)", 
		"Blacksmith, Cook, Tinker", 
		9, 
		-- fixed skills
		-- #picks 
		-- skill list
		{10,12},
		3,
		{15},
		"Gold Sink", "Deep Pockets",
		"Bang for Your Buck",
		"Diamond Hands",
		"Treasure Seeker",
		"Bang for Your Buck II",
		"Top Shelf", 352, 3},
	{"Pugilist", 
		"Attack", 
		"Frontline", 
		"Brawler or Monk", 
		1, 
		-- fixed skills
		-- #picks 
		-- skill list
		{2},
		3,
		{3,4,5,11,12},
		"Fisticuffs", "Rope-a-Dope",
		"Beat Rush",
		"Prowess",
		"Haymaker",
		"Impact",
		"Haymaker II", 353, 2},
	{"Revelator", 
		"Attack/Cast", 
		"Frontline", 
		"Knight or Warrior", 
		10, 
		-- fixed skills
		-- #picks 
		-- skill list
		{1,13},
		3,
		{2,5,6,12},
		"Righteous", "Selfless",
		"Lay on Hands",
		"Paragon's Aura",
		"Divine Resolve",
		"Holy Diver",
		"Sacrosanct", 354, 3},
	{"Rogue", 
		"Attack", 
		"Midline", 
		"Assassin, Investigator, Scout", 
		11, 
		-- fixed skills
		-- #picks 
		-- skill list
		{8,3,4},
		3,
		{15},
		"Sneak Attack", "Infiltrator",
		"Unflinching Luck",
		"Evasive",
		"Lethal Weapon",
		"Unflinching Luck II",
		"Waylay", 355, 2},
	{"Sorcerer", 
		"Cast", 
		"Backline", 
		"Mage or Occultist", 
		5, 
		-- fixed skills
		-- #picks 
		-- skill list
		{12},
		3,
		{2,6,9,14},
		"Glamour", "Tap",
		"Spell-Slinger",
		"Quickening",
		"Arcane Anomaly",
		"Spell Twinning",
		"Overpowered", 356, 3},
	{"Vanguard", 
		"Shove (Attack)", 
		"Frontline", 
		"Sentinel", 
		1, 
		-- fixed skills
		-- #picks 
		-- skill list
		{1,2},
		3,
		{5,7,11,13},
		"Stalwart", "Guard",
		"Rampant Charge",
		"Wall",
		"Unstoppable",
		"Wall II",
		"Indestructable", 357, 3},
	{"Witch", 
		"Cast", 
		"Backline", 
		"Fortune Teller or Mage", 
		3, 
		-- fixed skills
		-- #picks 
		-- skill list
		{6},
		3,
		{7,9,10,11},
		"Occultist", "Hex",
		"Ritualism",
		"Things Betwixt",
		"Coventry",
		"Widdershins",
		"Ritualism II", 358, 3},
	{"Wizard", 
		"Cast", 
		"Backline", 
		"Astronomer or Mage", 
		4, 
		-- fixed skills
		-- #picks 
		-- skill list
		{9},
		4,
		{15},
		"Spellcaster", "Page Master",
		"Sculpt Spell",
		"Manifold Mind",
		"Extracurricular",
		"Manifold Mind II",
		"Archwizard", 359, 3},
}


function drawSection()
 half_w = 95
 bar_h = 5

 if (section == 1) then
  rect(0,0,half_w,bar_h,ancestry[ancestrypick][3])
 elseif (section == 2) then
  rect(half_w,0,240-half_w,bar_h-2,stat[class[classpick][5]][2]) 
  rect(half_w,bar_h-2,240-half_w,2,stat[class[classpick][5]][4]) 
 end
end

function printSkill(_skill, x, y)
 local width = 0
 local col = stat[skill[_skill][2]][2]
 
 if _skill == 15 then col = step end
 
 spr(stat[skill[_skill][2]][3], x, y-1)
 width = print(skill[_skill][1], x+9, y, col, true, 1, true)
 width = width + 9
 return width
end

function showSkills(_class, posX, posY)
 local _width, _current = 0, 0
 
 for _, skill in ipairs(class[_class][6]) do
  _width = printSkill(skill, posX+_current, posY+lineheight*12)
  _current = _current + _width + 4 
 end
 print("and", posX+_current, posY+lineheight*12, 12, true, 1, true)
 _width = 0
 _current = 0
 local y_offset = 0
 local item_count = 0
 
 for _, skill in ipairs(class[_class][8]) do
  if item_count > 0 and item_count % 3 == 0 then
   y_offset = y_offset + lineheight
   _current = 0
  end
  
  _width = printSkill(skill, posX+_current, posY+lineheight*13 + y_offset)
  _current = _current + _width + 4
  item_count = item_count + 1
 end
 
 print("(pick " .. class[_class][7] ..")", posX+_current-2, posY+lineheight*13 + y_offset, 12, true, 1, true)
end

function showClass(_pick)
 local posX, posY = 100, 10
 
 classcol = stat[class[_pick][5]][2]
 if step > 3 then
  classcol = stat[class[_pick][5]][4]
 end

 print(class[_pick][1], posX, posY, classcol, true, 1, false)

 spr(stat[class[_pick][5]][3], posX+80, posY-1+lineheight*0)
 print(stat[class[_pick][5]][1], posX+89, posY+lineheight*0, classcol, true, 1, true)

 print("Act: " .. class[_pick][2], posX, posY+lineheight*1, 12, true, 1, true)
 print("Pos: " .. class[_pick][3], posX, posY+lineheight*2, 12, true, 1, true)
 print("Eqp: " .. class[_pick][4], posX, posY+lineheight*3, 12, true, 1, true)

 print("Talents", posX, posY+lineheight*4, classcol, true, 1, false)
 print(" 1: " .. class[_pick][9] .. ", " .. class[_pick][10], posX, posY+lineheight*5, 12, true, 1, true)
 print(" 2: " .. class[_pick][11], posX, posY+lineheight*6, 12, true, 1, true)
 print(" 4: " .. class[_pick][12], posX, posY+lineheight*7, 12, true, 1, true)
 print(" 6: " .. class[_pick][13], posX, posY+lineheight*8, 12, true, 1, true)
 print(" 8: " .. class[_pick][14], posX, posY+lineheight*9, 12, true, 1, true)
 print("10: " .. class[_pick][15], posX, posY+lineheight*10, 12, true, 1, true)
 
 print("Skills", posX, posY+lineheight*11, classcol, true, 1, false)
 showSkills(_pick, posX, posY)
 
  spr(class[_pick][16], 37, posY+lineheight*10, 0, 2, 0, 0, 1, 2)
end

function showAncestry(_pick)
 local posX, posY = 10, 10

 print(ancestry[_pick][1], posX, posY, ancestry[_pick][3], true, 1, false)
 print(creaturetype[ancestry[_pick][4]][1], posX, posY+lineheight*1, ancestry[_pick][3], true, 1, true)
 print(ancestry[_pick][8], posX, posY+lineheight*2, 12, true, 1, true)
 print(ancestry[_pick][9], posX, posY+lineheight*3, 12, true, 1, true)
 print(ancestry[_pick][10], posX, posY+lineheight*4, 12, true, 1, true)
 
 print("Traits", posX, posY+lineheight*6, ancestry[_pick][3], true, 1, false)
 print(ancestry[_pick][5], posX, posY+lineheight*7, 12, true, 1, true)
 print(ancestry[_pick][6], posX, posY+lineheight*8, 12, true, 1, true)
 print(ancestry[_pick][7], posX, posY+lineheight*9, 12, true, 1, true)
 
 spr(ancestry[_pick][2], posX+10, posY+lineheight*10, 0, 2, 0, 0, 1, 2)
end

function TIC()
 
	if btnp(2) and (section > 1) then section=section-1 end
	if btnp(3) and (section < maxsection) then section=section+1 end
	if btnp(0) then 
		if (section == 1) and (ancestrypick > 1) then ancestrypick=ancestrypick-1 end
		if (section == 2) and (classpick > 1) then classpick=classpick-1 end
	end
	if btnp(1) then 
		if (section == 1) and (ancestrypick < maxpick[1]) then ancestrypick=ancestrypick+1 end
		if (section == 2) and (classpick < maxpick[2]) then classpick=classpick+1 end
	end

	cls(0)

 count = count + 1
 
 if count > 4 then
  count = 0
  step = step + 1
	end
	
	if step >= 8 then
	 step = 1
	end
	
	drawSection()
	showAncestry(ancestrypick)
	showClass(classpick)
	
end
