Skip to main content

Indie game storeFree gamesFun gamesHorror games
Game developmentAssetsComics
SalesBundles
Jobs
TagsGame Engines

Create a function like this and it can check how many items you have,

function inventory_get_qty(item_id) {
     for(var c = 0; c < global.inventory_items; c++){
         if(global.inventory_item[c] == item_id){
             return global.inventory_qty[c];
         }
     }
     return 0;
}

Sorry i mean i want to draw_text to the amount of item i have. 

This is my code

draw_text(0, 0,tsprint("POTION x", global. Inventory_qty[item_POTION])) 

Are this wrong? 

Yes, it's wrong. The inventory is populated in the order you obtain items, so item_POTION could be placed anywhere in the inventory. inventory_qty[item_POTION] reads inventory slot 0 but ANYTHING could be there.

Oh ok, so i cant use draw_text function for this then ? 

You can, you just need to read out the correct number of items (using the new inventory_get_qty function I suggested)

Oh ok, then how to draw the qty variable ? 

What script i used to draw the number of value for example potion?