T
Tyler Ratliff
Guest
Ill try to keep this short and simple as I am relatively new and eager to learn. For reference, I have built my inventory based on GM Wolf's design on YouTube. I am customizing and attempting to improve it for a game I am building as well as to understand GML a little bit better. I have everything fully functional except getting the items to appear in the game world once they are dropped from the inventory. I can post any code needed and will try to provide useful resources. The player clicks on an item with the middle mouse button and the inventory goes down by one. I am just not sure what array or design I need to use/write to convert the inventory items to a dropped object item in the game world. The first code section here is the inventories CREATE event which stores the item information (could I use these to reference the dropped item?):
This is also listed under Create and serves the purpose of having items in the inventory on game start:
This is from the global middle mouse button pressed (drops one of the item)
and its referenced script:
slot_n is where the amount of the item is stored.
Am I able to use my existing codes to be able to drop the items into the overworld? Or do I have to set more things up? If so, what direction should I look into? I am new but willing to research and learn. I can also again post any or all of the code I am using if this would not be enough! Thank you!
Code:
///Define Items and Items Sprites
enum items
{
health_potion, ///ID 0
bones, ///ID 1
feathers, ///ID 2
raw_chicken ///iD 3
}
sprite[items.health_potion] = spr_health_potion;
sprite[items.bones] = spr_bones;
sprite[items.feathers] = spr_feathers;
sprite[items.raw_chicken] = spr_raw_chicken;
script[items.health_potion] = scr_use_health_potion;
script[items.bones] = noone;
script[items.feathers] = noone;
script[items.raw_chicken] = noone;
Code:
for(var i = 0; i < slot_number; i++)
{
slot[i]=noone;
slot_n[i] = 0;
}
slot[10]=items.health_potion;
Code:
if (slot[slot_clicked] != noone) {
slot[slot_clicked] = dropping;
scr_drop_item(slot_clicked, 1)
}
}
Code:
///scr_remove_item(slot, number);
slot_n[argument0] -= argument1;
if slot_n[argument0] = 0
{
slot[argument0] = noone;
} else {
instance_create_layer(obj_player.x+30, obj_player.y+30, obj_inventory_drop)
}
Am I able to use my existing codes to be able to drop the items into the overworld? Or do I have to set more things up? If so, what direction should I look into? I am new but willing to research and learn. I can also again post any or all of the code I am using if this would not be enough! Thank you!