Windows Skill Errors and Screw ups

R

Rairak

Guest
Using this code, the attack, intelligence, speed, and defense stats upgrade when my Experience equal 100. However, the next time I level up, the same stat is increased without the debug window appearing.
EX: If I choose Speed as my first increase, the next time I level up, Speed is automatically increased.

I would like the debug to appear each time the Experience threshold is reached.

Also, I would like it so that if a case is inputted that is not a part of those four stats, that the debug window does not disappear.

Thank you!GM FORUM2.PNG
 
R

Rairak

Guest
You can put the debug message within each switch condition -- this will stop it from showing if a case is not chosen. Also, try removing "Experience = 0" from each switch condition and just put it at the top like:

Code:
if Experience >= 100
{
    Experience = 0;
    switch(levelup)
    {
        case "Attack":
            Attack += 5;
            show_debug_message(levelup);
        break;
        case "Intelligence":
            Intelligence += 5;
            show_debug_message(levelup);
        break;
        case "Defense":
            Defense += 5;
            show_debug_message(levelup);
        break;
        case "Speed":
            Speed += 0.5;
            show_debug_message(levelup);
        break;
    }
}
That didn't work. When I input "Speed" when the debug appears, it adds .5 like it is supposed to. When I get 100 Experience again, however, Speed is automatically chosen as increased.

When I inputted an amalgamation of random numbers, the debug window disappeared. I would like it so that it does not disappear until one of the four cases is inputted.

Thank you!
 
R

Rairak

Guest
You can put the debug message within each switch condition -- this will stop it from showing if a case is not chosen. Also, try removing "Experience = 0" from each switch condition and just put it at the top like:

Code:
if Experience >= 100
{
    Experience = 0;
    switch(levelup)
    {
        case "Attack":
            Attack += 5;
            show_debug_message(levelup);
        break;
        case "Intelligence":
            Intelligence += 5;
            show_debug_message(levelup);
        break;
        case "Defense":
            Defense += 5;
            show_debug_message(levelup);
        break;
        case "Speed":
            Speed += 0.5;
            show_debug_message(levelup);
        break;
    }
}
Also it sounds like the reason the "levelup" choice is made after leveling the first time, is because a variable is not being reset!

For example: levelup = "Speed" and is not reset to levelup = "" after a choice is made.
Could be a number of things -- post all your code is you're still having trouble.
That last part worked for resetting "levelup" and allowing me to change my choice of upgrades, thank you!

The other problem is that I can input anything (EX: Harrow) in the debug window, and it would disappear.

I want it to stay up unless one of those four cases is inputted.

Is there a way to set it to something like:
If anything else is inputted, display the same message?
 
R

Rairak

Guest
You could try testing the variable levelup -- to see if it actually holds a string -- that might show you!
Code:
if string_length(levelup) > 0
{
    show_debug_message(levelup);
}
Perhaps add this after the switch.
NEW.PNG .


I'm sorry, I don't understand what you mean. The variable levelup brings up with debug menu and when inputted with anything, it disappears. I want it so that the four cases named are the only thing that make the debug box disappear.
 
R

Rairak

Guest
You could try testing the variable levelup -- to see if it actually holds a string -- that might show you!
Code:
if string_length(levelup) > 0
{
    show_debug_message(levelup);
}
Perhaps add this after the switch.
Also, when I input a case to upgrade, such as Speed, nothing changes. When I level up again, I choose Attack, but Speed increases. Next time, if I choose Defense, Attack increases. How do I fix this? ( I'm using the code you posted)
 
R

Rairak

Guest
Honestly I've never used the show_debug_message function. I usually debug by other means -- so I'm not sure what you're trying to achieve. As far as adding to the wrong stats, I'd have to see your other code.

I'm assuming you have 4 or more select-able "skills" when you level up, which in turn, store a string into levelup. The switch seems pretty straight-forward so you must have errors somewhere else.
The debug message allows for input of player which can change values in game. Someone else helped me with the problem but thank you so much for what you helped me with! It all works perfectly!
 
Top