K
KiD_Rager
Guest
Hey folks!
I'm using the Inventory System by Beyond Us Games that mostly involves a variable called itemSelected. Since the project runs on DS grids, I have virtually no problem using accessors and whatnot to retrieve certain cell data, except...
My core issue involves retrieving certain data of one inventory's cell based on the name being pulled from another inventory's cell (two DS grids). Look at the drawn strings in the top left that show Grid info.
As you can see, when Short Sword is selected (not used btw) in the inventory, it says that the next upgrade name is Long Sword. Seems right. But selecting any other weapon doesn't change this.
To reference, I have two inventory lists: inv (main inventory) and invSword (list of all swords in the game for checking purposes).
inv - Added weapons
invSword - Sword list
The code I have in my Draw Event will be identical to my weapon upgrade script, so if I can get it right the first time I just need to replicate it. The Draw code is as follows:
OBJ CONTROL - Draw
** Yes, I'm aware that Royal Sword doesn't have its own row in invSword. I'm more focused on Small and Long Sword items, haha.
Basically, itemSelect is "selecting" the grid row I choose. If I scroll down to a sword, I can obtain all the cells within that row. Obviously, something in the last draw_text line isn't quite working as planned.
My goal for that string is to do this:
Draw: the name of Upg A from invSword by grabbing the name of the itemSelected
In theory, it should function like so:
Was hoping that someone could see where I'm going wrong. I've even tested just using...
...but it also scrolls in invSword so it's not really pulling data based on the name of the item's weapon.
You can see that after picking up those three swords that were in the middle, the last item "Short Sword" has a Grid Ele UPG A value of -4. This is because in my invSword list, it's pulling from row 5 of that list instead of noticing "hey this item is called Short Sword so let's see what the value 1 of of Short Sword is in this invSword list". I know I could just have it be all in inv but we're talking at least like 10+ arguments - even for items that aren't weapons - so I wanted to differentiate the two inventories.
Maybe I'm wrong on that, tho. Wanted to get some help with this situation before I lose my mind, aha.
I'm using the Inventory System by Beyond Us Games that mostly involves a variable called itemSelected. Since the project runs on DS grids, I have virtually no problem using accessors and whatnot to retrieve certain cell data, except...
My core issue involves retrieving certain data of one inventory's cell based on the name being pulled from another inventory's cell (two DS grids). Look at the drawn strings in the top left that show Grid info.
As you can see, when Short Sword is selected (not used btw) in the inventory, it says that the next upgrade name is Long Sword. Seems right. But selecting any other weapon doesn't change this.
To reference, I have two inventory lists: inv (main inventory) and invSword (list of all swords in the game for checking purposes).
inv - Added weapons
GML:
//Grid, Name, Lvl, Desc, Sprite, Type, Script, ID
scr_itemAdd(inv, "Short Sword", 1, "Basic sword.", spr_wepSword_ShortSword, "sword", wpnEquip, 1, 0);
scr_itemAdd(inv, "Long Sword", 1, "Long sword. Very good reach.", spr_wepSword_ShortSword, "sword", wpnEquip, 1, 532);
scr_itemAdd(inv, "Royal Sword", 1, "Special sword designed for royal knights.", spr_wepSword_ShortSword, "sword", wpnEquip, 1, 875);
GML:
///Master swords list
//Grid, Name, Upg A, Upg Lvl A, Upg B, Upg Lvl B
scr_swordMaster(invSword, "Short Sword", "Long Sword", 3, "Sand Breaker", 5); //Row 0
scr_swordMaster(invSword, "Long Sword", "Pumpkin Eater", 5, noone, noone);
scr_swordMaster(invSword, "Sand Breaker", "Bravado", 3, noone, noone);
scr_swordMaster(invSword, "Pumpkin Eater", "Bravado", 3, "Gladius", 5);
scr_swordMaster(invSword, "Bravado", "Gladius", 3, noone, noone);
scr_swordMaster(invSword, "Gladius", noone, noone, noone, noone);
OBJ CONTROL - Draw
GML:
if instance_exists(obj_invGUI) {
draw_text(30,120,"Selected #: " + string(itemSelected));
draw_text(30,150,"Grid Ele Name: " + string(inv[# 0, itemSelected]));
draw_text(30,180,"Grid Ele LVL: " + string(inv[# 6, itemSelected]));
draw_text(30,210,"Grid Ele UPG A: " + string(invSword[# 1,
inv[# 0, itemSelected]]));
}
Basically, itemSelect is "selecting" the grid row I choose. If I scroll down to a sword, I can obtain all the cells within that row. Obviously, something in the last draw_text line isn't quite working as planned.
My goal for that string is to do this:
Draw: the name of Upg A from invSword by grabbing the name of the itemSelected
In theory, it should function like so:
If (in inv) itemSelect = "Long Sword", upgrade name should be "Pumpkin Eater" (from invSword)
My goal is to simplify this accessor code down so that it can function for any weapon without a million IF statements (weapon list is expected to be ~ 100 items).
Was hoping that someone could see where I'm going wrong. I've even tested just using...
GML:
//For Grid Ele UPG A
...string(invSword[# 1, itemSelected]);
You can see that after picking up those three swords that were in the middle, the last item "Short Sword" has a Grid Ele UPG A value of -4. This is because in my invSword list, it's pulling from row 5 of that list instead of noticing "hey this item is called Short Sword so let's see what the value 1 of of Short Sword is in this invSword list". I know I could just have it be all in inv but we're talking at least like 10+ arguments - even for items that aren't weapons - so I wanted to differentiate the two inventories.
Maybe I'm wrong on that, tho. Wanted to get some help with this situation before I lose my mind, aha.