Advertisement
Guest User

Untitled

a guest
Jun 18th, 2019
93
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.08 KB | None | 0 0
  1. #region Using stuff from the inventory
  2. if(oInput.use){
  3. //
  4. var grid = inventory[# soffset, 0]; // Getting the current position of the selector in the hot-bar
  5.  
  6. //
  7. if(grid != VOID){ // Checking if the slot has an item
  8. // If true:
  9. if(instance_exists(grid[data.ONAME]) and grid[data.ONAME].used != 1){
  10.  
  11. 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
  12. //
  13. with(item){ // Accessing the item itself
  14. //
  15. image_alpha = 0; // We make it invisible just in case
  16. used = 1; // We mark it as being used
  17. pickupable = 1; // We also mark it so the player can't pick it up (not needed but to provent any messiness)
  18. } //
  19. //
  20. if(grid[data.NONUSABLE] == 0){ // If the item can be used BUT won't lower the count in the inventory
  21. // (The example for this is the bow, you can use it but it won't delete it from the inventory)
  22. var loss = grid[data.COUNT]; // Making a var to make things simpler, then assigning the current amount of the item being used
  23. loss--; // Taking one away since its being used
  24. grid[@data.COUNT] = loss; // Setting the new value to the grid
  25. //
  26. if(loss <= 0){ // Checking if its equal or less than 0 in the grid
  27. // If true:
  28. inventory[# soffset, 0] = VOID; // Set the grid to empty
  29. }
  30. }
  31. }
  32.  
  33. if(!instance_exists(grid[data.ONAME])){
  34.  
  35. 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
  36. //
  37. with(item){ // Accessing the item itself
  38. //
  39. image_alpha = 0; // We make it invisible just in case
  40. used = 1; // We mark it as being used
  41. pickupable = 1; // We also mark it so the player can't pick it up (not needed but to provent any messiness)
  42. } //
  43. //
  44. if(grid[data.NONUSABLE] == 0){ // If the item can be used BUT won't lower the count in the inventory
  45. // (The example for this is the bow, you can use it but it won't delete it from the inventory)
  46. var loss = grid[data.COUNT]; // Making a var to make things simpler, then assigning the current amount of the item being used
  47. loss--; // Taking one away since its being used
  48. grid[@data.COUNT] = loss; // Setting the new value to the grid
  49. //
  50. if(loss <= 0){ // Checking if its equal or less than 0 in the grid
  51. // If true:
  52. inventory[# soffset, 0] = VOID; // Set the grid to empty
  53. }
  54. }
  55. }
  56. }
  57. }
  58. #endregion
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement