Jump to content
  • 0

Lost Code


Lunam

Question

Hey guys, I know I've been away for a while, been busy with life and work and dealing with Covid and whatnot. Anyways, I lost a valueable chunk of code by accident and for some reason I cannot figure out for the life of me what that code was. I know what it was supposed to do and where it goes, but the line of code itself is lost to me. The code I'm refering to is the code that allowed the user to click a checkbox to choose their class instead of the standard combobox. I've tried many alterations of GetClass(), LoadClass(), ClassBase.Whatever, etc... and everytime the client crashes when I click New character. This is the code I have right now:

 

//Class Combobox
            //mClassCombobox = new ComboBox(mClassBackground, "ClassCombobox");
            //mClassCombobox.ItemSelected += classCombobox_ItemSelected;

            //Acolyte Checkbox
            mAcolyteCheck = new CheckBox(mClassBackground, "AcolyteCheckbox");
            mAcolyteCheck.Checked += AcolyteCheck_Checked;

            //Duelist Checkbox
            mDuelistCheck = new CheckBox(mClassBackground, "DuelistCheckbox");
            mDuelistCheck.Checked += DuelistCheck_Checked;

            //Scout Checkbox
            mScoutCheck = new CheckBox(mClassBackground, "ScoutCheckbox");
            mScoutCheck.Checked += ScoutCheck_Checked;



//Further down...

//void classCombobox_ItemSelected(Base control, ItemSelectedEventArgs args)
        //{
            
        //    LoadClass();
        //    UpdateDisplay();
        //}

        void AcolyteCheck_Checked(Base sender, EventArgs arguments)
        {
            ClassBase.Lookup.Get(ClassBase.FromList(1).Id);
            mAcolyteCheck.IsChecked = true;
            mDuelistCheck.IsChecked = false;
            mScoutCheck.IsChecked = false;
            LoadClass();
            ResetSprite();
            UpdateDisplay();
        }

        void DuelistCheck_Checked(Base sender, EventArgs arguments)
        {
            ClassBase.Lookup.Get(ClassBase.FromList(2).Id);
            mAcolyteCheck.IsChecked = false;
            mDuelistCheck.IsChecked = true;
            mScoutCheck.IsChecked = false;
            LoadClass();
            ResetSprite();
            UpdateDisplay();
        }

        void ScoutCheck_Checked(Base sender, EventArgs arguments)
        {
            ClassBase.Lookup.Get(ClassBase.FromList(3).Id);
            mAcolyteCheck.IsChecked = false;
            mDuelistCheck.IsChecked = false;
            mScoutCheck.IsChecked = true;
            LoadClass();
            ResetSprite();
            UpdateDisplay();
        }

 

As you can see, The combobox portion is commented out, and is replaced by the checkboxes. The specific line of code I'm talking about is this:

ClassBase.Lookup.Get(ClassBase.FromList(2).Id);

Link to comment
Share on other sites

8 answers to this question

Recommended Posts

  • 0

2021-09-20 13:47:22.758 [Error]
  Message: Object reference not set to an instance of an object.
    Stack:    at Intersect.Client.Interface.Menu.CreateCharacterWindow.Init()
   at Intersect.Client.Interface.Menu.MainMenu.CreateCharacterCreation()
   at Intersect.Client.Interface.Menu.MainMenu.Update()
   at Intersect.Client.Interface.Menu.MenuGuiBase.Draw()
   at Intersect.Client.Interface.Interface.DrawGui()
   at Intersect.Client.Core.Graphics.Render()
   at Intersect.Client.MonoGame.IntersectGame.Draw(GameTime gameTime)
   at Microsoft.Xna.Framework.Game.DoDraw(GameTime gameTime)
   at Microsoft.Xna.Framework.Game.Tick()
   at Microsoft.Xna.Framework.SdlGamePlatform.RunLoop()
   at Microsoft.Xna.Framework.Game.Run(GameRunBehavior runBehavior)
   at Intersect.Client.MonoGame.IntersectGame.MonoGameRunner.Start(IClientContext context, Action postStartupAction)
   at Intersect.Client.Core.ClientContext.InternalStart()
   at Intersect.Core.ApplicationContext`2.Start(Boolean lockUntilShutdown) in C:\Users\TheyA\Desktop\Intersect Source\Intersect-Engine\Intersect (Core)\Core\ApplicationContext`2.cs:line 221

 

 

"Object Reference not set to an instance of an object"

 

What object doesnt exist though? I know its that single line of code(Classbase.Lookup.Get(Classbase.FromList(#).Id)) that is causing it because when I comment it out, it doesnt crash. obviously i cant pick a class but it doesnt crash either lol

Link to comment
Share on other sites

  • 0

I don't get this line to begin with.

 

Classbase.Lookup.Get(Classbase.FromList(#).Id);

 

What are you trying to accomplish here? You already have the class and are looking it up again?

As for the exact reason, I fear you'll have to tear the statements apart and debug them one by one and go through it all to see what is null exactly. When I try and use ClassBase.FromList(0); it gives me a functional class base in the Init method.

Link to comment
Share on other sites

  • 0

So what i want to do, is what I had before i somehow accidentally lost this code. I want the player to choose one of 3 classes using checkboxes instead of the combobox(inspired from Leafling). The checkbox allows me to use images (as the checkbox itself) to display class stats such as Atk, Def, Spd, etc(which is all done graphically) but, I cant seem to remember what code I had that allowed me to load a classID from the Class List depending on which checkbox is selected.

 

E.g.: 3 Classes: Acolyte, Duelist, and Scout. First checkbox is Acolyte, second Duelist and third is Scout. Click respective checkbox and load respective class, as if you would select it from the combobox as usual.

 

Also, its obviously not the right code or else it would work. I was just trying to use logic and guess as to what it could be that would allow me to load the class when a checkbox is checked

Link to comment
Share on other sites

  • 0

I meant that line of code, it's redundant. Classbase.FromList(#) already returns the full class instance.

Your use on the selection buttons also makes no sense as it's not being assigned to anything, you're just executing?

 

As for the error, run it in debug mode and breakpoint the Init method, then step through every step to find out what's a null reference, I fear that might be the only way.

Link to comment
Share on other sites

  • 0

I'm trying to understand what you're trying to do exactly... But I think "Classbase.Lookup.Get(Classbase.FromList(#).Id);" should store the value into something. You're only returning a value, but not using it, no? And why using the "lookup" function to get something that is already inside in another function? Looks redundant to me...

Link to comment
Share on other sites

  • 0

Sorry guys my brain doesnt seem to want to work right. Just Ignore the code, its obviously wrong.

 

Ok, plain and simple... I want to replace the Class COMBOBOX in Character Creation with Class CHECKBOXES just like Leafling has.

 

Again, I had this all squared away at one point but at some point i think i may have updated the source or something and i lost it.

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...