On Sale: GamesAssetsToolsTabletopComics
Indie game storeFree gamesFun gamesHorror games
Game developmentAssetsComics
SalesBundles
Jobs
Tags

I apologize for the very long delay in reply, but I ended up frustrated and giving up on the project due to not being able to get it working. Trying it again now, I believe I managed to create the 2D array properly wit the following:


global.weapon_upgrades_obtained = array_create(WID_MAX,0) //Number of upgrades for each weapon in the game

//global.weapon_upgrades_obtained = [array_create(WID_MAX,0),array_create(PWD_LOCALDATA_MAX,0)] //Number of upgrades for each weapon in the game

global.passive_upgrades_obtained = array_create(PID_EX_MAX,0) //Number of upgrades for each passive in the game

//Properly Initialize Var

for(var i = 0; i < array_length(global.weapon_upgrades_obtained); i++) {

    global.weapon_upgrades_obtained[i] = array_create(PWD_LOCALDATA_MAX);

}



But now the line that is:

if((global.weapon_upgrades_obtained[c][d] < global.weapon_data[c][pstat_POSSIBLEUPGRADES][d][dbupgd_MAXUPGRADES]) || allow_surpassing_max_level){ //Can we upgrade it further?


throws me an error about local variable 'd' not being found, which makes sense since its not initially until the loop starts beneath that line of code.

(+1)

It's been so long I've completely lost my original train of thought (happy 100-day anniversary!) but just looking at the last line in my last post, I think there's a clue here:

Oh yeah, and another issue, you're checking global.weapon_upgrades_obtained[c], but you should check global.weapon_upgrades_obtained[c][d] because upgrade level is per-upgrade now instead of shared for the entire weapon. (You'll need to move this check into the loop over array_length(ups) as well)

I.e. if the loop fails because you don't set d, it's probably actually a symptom that you still only loop over one variable (you need to loop over all weapons, and then inside that loop, have another loop that loops over all the upgrades defined for that weapon).


(In case you're wondering about the names, I always name my first loop counter c because then I get to write "c++" for the increment statement and I find that funny. And then for subsequent inner loops I use d, e, f and so on because I ran out of programming languages and it's easier just cycling through all letters)

(+1)

I greatly apologize for that delay: and interesting tidbit, actually. I have only used 'i' for local variables or a relavant title because of some mental carry over from RPG Maker.


That aside: You're a god. I just moved the code to be:

for(var c = 0; c < WID_MAX; c++){

if(playerweapon_has(c)){

if(include_weapons_we_have){

var ups = global.weapon_data[c][pstat_POSSIBLEUPGRADES];

for(var d = 0; d < array_length(ups); d++){

if((global.weapon_upgrades_obtained[c][d]  < global.weapon_data[c][pstat_POSSIBLEUPGRADES][d][dbupgd_MAXUPGRADES]) || allow_surpassing_max_level){ //Can we upgrade it further?

At the top of that function and it seems to be working perfectly. Now I'm just going to add some text to show the current 'level' of that upgrade for visual clarity. Thank you so very much for helping me out and your patience.

No problem! Glad you finally got it working ^__^