I've been working on a Game Master Assistance Program for SW PNR, and so far I've gotten to the Character Creation Stage, thankfully there is now devolopment currently so I'm just putting a large amount of rules into a program. As I said in the PNR thread, I've been working on Type Instance Arrays within Types, hence the topic. Basically I've written a Character type, a profession type, and a large amount of item types. The Character type relates that all Characters have these statistics, then the profession specific works are extended from that type. The Item type concern the items like a Garment is a type, while a Weapon is a type. Then I create fields within the Character/Profession type of the Type Garment causing a type instance. Apparently it likes to delete my posts, so here's what I remember. Basically when i call Char.Weapon[1].Name$ it gives me this error: "Unhandled Exception:Attempt to access field or method of Null object" When I call Char.Weapon.Name$[1] it gives me this error: "Identifier name not found." Here is the full version of the code:
'First the elements, garments, armor, ext. Type TGarment Field Name$ End TypeType THouse Field Name$ Field Storage Field Clothing:TGarment[5] 'Note:Change when you get more/less garments. Field Furniture 'Explore Later Field Refrigerator 'Explore Later Field Cost End Type Type TWeapon Field Name$ Field Strength End Type Type TItem Field Name$ Field TypeItem$ End Type Type TSkill Field Name$ Field Action$ Field Degree Field Cost End Type 'Then the smaller settings Type TZone End Type 'Then the large settings Type TPlanet End Type Type TSystem End Type 'Then the Characters Type TChar Field Name$ Field Gender$ Field Garment:TGarment Field Profession$ Field Class 'Explore later Field Species$ Field System$ Field Planet$ Field Zone$ Field House:THouse 'This is Profession specific so the profession type will branch off. Field Attack Field Defense Field Life Field MaxLife Field Experience Field MaxExperience Field Level Field Feeling Field MaxFeeling Field TotalAttack Field TotalDefense Field Weapon:TWeapon[2] Field Items:TItem[50] Field Credits End Type Type TJedi Extends TChar Field LightsaberCombat Field ForcePowers Field BlockBlasterBolts Field ForceLightning Field Skills:TSkill Field SkillPool End Type 'Then Finally the Player Type TPlayer Field Name$ Field Characters:TChar[] Field NumCharacters End Type #MainLoop Print "Hello welcome to Star Wars Protectors of the New Republic." choose$ = Input$("Would you like to create a character?") If Choose$ = "Yes" Or "yes" CreateCharacter() ElseIf Choose$ = "No" Or "no" End EndIf Function CreateCharacter() #Questions #ProfSet Prof$ = Input$("What is your character's profession?") If Prof$ = "Jedi" Then Char:TJedi = New TJedi Char.Profession$ = "Jedi" ElseIf Prof$ = "jedi" Then Char:TJedi = New TJedi Char.Profession$ = "Jedi" Else Print "Sorry, command not understood." Goto ProfSet EndIf #NameSet Char.Name$ = Input$("What is your character's name?") #GenderSet Gender$ = Input$("What is your character's gender?") If Gender = "Male" Char.Gender$ = "Male" ElseIf Gender = "male" Char.Gender$ = "Male" ElseIf Gender = "Female" Char.Gender$ = "Female" ElseIf Gender = "female" Char.Gender$ = "Female" Else Print "Sorry, command not understood." Goto GenderSet EndIf 'Ask Garment later 'Ask Class later #SpeciesSet Species$ = Input$("What is your character's species?") If Species = "Human" Char.Species$ = "Human" ElseIf Species = "human" Char.Species$ = "Human" Else Print "Sorry, command not understood." Goto SpeciesSet EndIf #SystemSet Print "What is your character's system?" Print "Choices include: Corellian" System$ = Input$("") If System = "Corellian" Char.System$ = "Corellian" ElseIf System = "corellian" Char.System$ = "Corellian" Else Print "Sorry, command not understood." Goto SystemSet EndIf #PlanetSet Print "What is your character's planet?" Print "Choices include: Corellia" Planet$ = Input$("") If Planet = "Corellia" Char.Planet$ = "Corellia" ElseIf Planet = "corellia" Char.Planet$ = "Corellia" Else Print "Sorry, command not understood." Goto PlanetSet EndIf #Settings If Char.Species = "Human" Char.Attack = 4 Char.Defense = 2 If Char.Profession = "Jedi" Char.LightsaberCombat = 2 Char.ForcePowers = 2 Char.BlockBlasterBolts = 2 Char.ForceLightning = 1 Char.Weapon[0].Name$ = "Lightsaber" Char.Weapon[1].Strength = 1 Char.Life = 150 Char.MaxLife = 150 Char.Feeling = 100 Char.MaxFeeling = 100 Char.Credits = 434 EndIf EndIf End Function
|
------------------ MM out- Thought travels much faster than sound, it is better to think something twice, and say it once, than to think something once, and have to say it twice. "Frogs and Fauns! The tournament!" - Professor Winneynoodle/HanClintoI reserve the full right to change my views/theories at any time. [This message has been edited by Mene-Mene (edited July 27, 2007).] [This message has been edited by Mene-Mene (edited July 27, 2007).] |