Rivals of Aether

Rivals of Aether

The Battle Cat
Redsword 8 Feb, 2023 @ 12:29pm
The code that makes the Currency increase isn't working!
Hi! I'm making a skin/alternate version of this character, but for some reason the code for the currency going up just flat out isn't working! The code I'm using to make it work is below, I could really use some help!


Code: (This is in the update.gml btw)
//update

if nspecialcooldown > 0{
nspecialcooldown = nspecialcooldown - 1
}

if fspecialcooldown > 0{
fspecialcooldown = fspecialcooldown - 1
}

if dspecialcooldown > 0{
dspecialcooldown = dspecialcooldown - 1
}

if uspecialcooldown > 0{
uspecialcooldown = uspecialcooldown - 1
}

//Funny Taunt Fix
if (state != PS_ATTACK_GROUND){
sound_stop(sound_get("burgertime"));
}

if (get_player_color(player) == 5){
outlineR = 75;
outlineG = 75;
outlineB = 75;
}

if (workercatlvl = 1)
{
currency = currency + 0.25;

if(currency > 500)
{
currency = 500;
}
}

if (workercatlvl = 2)
{
currency = currency + 0.4;

if(currency > 1000)
{
currency = 1000;
}
}

if (workercatlvl = 3)
{
currency = currency + 0.55;

if(currency > 1500)
{
currency = 1500;
}
}

if (workercatlvl = 4)
{
currency = currency + 0.7

if(currency > 2000)
{
currency = 2000;
}
}

if (workercatlvl = 5)
{
currency = currency + 0.85;

if(currency > 2500)
{
currency = 2500;
}
}

if (workercatlvl = 6)
{
currency = currency + 1;

if(currency > 3000)
{
currency = 3000;
}
}

if (workercatlvl = 7)
{
currency = currency + 1.15;

if(currency > 3500)
{
currency = 3500;
}
}

if (workercatlvl = 8)
{
currency = currency + 1.3;

if(currency > 4000)
{
currency = 4000;
}
}
< >
Showing 1-3 of 3 comments
wyome  [developer] 22 Apr, 2023 @ 1:15am 
Hey! sorry for being like 2 months late... Steam likes to eat my notifications sometimes ^ ^;

My first idea is probably not likely, considering it was a problem with MY version of the code, but when testing if something is equal in an if statement, you usually want to use "==" rather than "=" because a lot of languages see the single equals sign as you setting variables rather than a test. Let me know if that's the case cause, again, that was something on my end.

Second, I noticed a couple missing semi-colons.
- inside the first four if statements, after the lines that tick the cooldowns. (I noticed this in my
code as well, a worrying running theme)
- After the currency set in the if statement for worker level 4

That's the most I can tell from just the code alone. If these first two don't work, i'd suggest setting up temporary hud elements to track all the variables (using the draw debug text code at the bottom of draw_hud.gml) and just make sure everything is updating properly. Usually this can help if numbers are getting stuck somewhere.

Thanks for showing interest in my scuffed character, by the way. if you couldn't tell from the fact that 2/3rds of this reply was me noticing problems in my own code, It was a pretty old project of mine, so I'm glad it's still getting some love!

Hope you figure it out, and let me know if you have any more questions! Let's hope steam doesn't hog the notification this time.
Redsword 22 Apr, 2023 @ 10:52am 
Thanks for your input!
I actually already got this done and the character should be released if nothings wrong, so now the only thing I need to do is figure out the way to display the cost of units even though I did it before somehow??

Anyway, thanks for responding!
wyome  [developer] 22 Apr, 2023 @ 12:49pm 
There's two ways you can go about it...

1. Using draw_debug_text. It's fairly simple, but it has a specific look to it, so you may or may not be a fan. here's an example of me using it in my code:

draw_debug_text( temp_x + 118, temp_y - 56, "Total:" )

The Plus and Minus can be adjusted to place it where you need on the screen, and since the costs most likely won't change, you can just put the cost at the end inside the quotes.

if you want the cost of the units to change, then all you have to do is set the cost of the unit to a string using a line like this:

currencystring = string(currency);

Then write out the line like this:

draw_debug_text( temp_x + 162, temp_y - 56, currencystring )

Just make sure to exclude the quotes if using a variable.

2. The second would be the artists' approach, you can go through and add the costs to the sprites of the hud, that way you don't have to mess around with code if you just want a static number to be displayed. Just be careful about readability, and you should be a-ok!
< >
Showing 1-3 of 3 comments
Per page: 1530 50