Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #region Using stuff from the inventory
- if(oInput.use){
- //
- var grid = inventory[# soffset, 0]; // Getting the current position of the selector in the hot-bar
- //
- if(grid != VOID){ // Checking if the slot has an item
- // If true:
- if(instance_exists(grid[data.ONAME]) and grid[data.ONAME].used != 1){
- var item = instance_create_depth(-32, -32, -1, grid[data.ONAME]); // We create the item on a var to access it, -32, -32 makes the item offscreen
- //
- with(item){ // Accessing the item itself
- //
- image_alpha = 0; // We make it invisible just in case
- used = 1; // We mark it as being used
- pickupable = 1; // We also mark it so the player can't pick it up (not needed but to provent any messiness)
- } //
- //
- if(grid[data.NONUSABLE] == 0){ // If the item can be used BUT won't lower the count in the inventory
- // (The example for this is the bow, you can use it but it won't delete it from the inventory)
- var loss = grid[data.COUNT]; // Making a var to make things simpler, then assigning the current amount of the item being used
- loss--; // Taking one away since its being used
- grid[@data.COUNT] = loss; // Setting the new value to the grid
- //
- if(loss <= 0){ // Checking if its equal or less than 0 in the grid
- // If true:
- inventory[# soffset, 0] = VOID; // Set the grid to empty
- }
- }
- }
- if(!instance_exists(grid[data.ONAME])){
- var item = instance_create_depth(-32, -32, -1, grid[data.ONAME]); // We create the item on a var to access it, -32, -32 makes the item offscreen
- //
- with(item){ // Accessing the item itself
- //
- image_alpha = 0; // We make it invisible just in case
- used = 1; // We mark it as being used
- pickupable = 1; // We also mark it so the player can't pick it up (not needed but to provent any messiness)
- } //
- //
- if(grid[data.NONUSABLE] == 0){ // If the item can be used BUT won't lower the count in the inventory
- // (The example for this is the bow, you can use it but it won't delete it from the inventory)
- var loss = grid[data.COUNT]; // Making a var to make things simpler, then assigning the current amount of the item being used
- loss--; // Taking one away since its being used
- grid[@data.COUNT] = loss; // Setting the new value to the grid
- //
- if(loss <= 0){ // Checking if its equal or less than 0 in the grid
- // If true:
- inventory[# soffset, 0] = VOID; // Set the grid to empty
- }
- }
- }
- }
- }
- #endregion
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement