• Hey Guest! Ever feel like entering a Game Jam, but the time limit is always too much pressure? We get it... You lead a hectic life and dedicating 3 whole days to make a game just doesn't work for you! So, why not enter the GMC SLOW JAM? Take your time! Kick back and make your game over 4 months! Interested? Then just click here!

Making RPG chest with specific items

M

Marco Savarese

Guest
So I created my sprite chest, made it react with my player's hitbox and works fine. Now I just have to tell what's inside of it and I have no idea how to do it. How can I use the same object chest for various items?
 
T

Timothy

Guest
Many ways. You can put the data directly in the instance via the creation code. Or maybe use a map with the ids or instance names (Or what ever the identifier you create in the room editor is called) as keys. Really countless ways. How do you intend on representing your items?
 
M

Marco Savarese

Guest
Many ways. You can put the data directly in the instance via the creation code. Or maybe use a map with the ids or instance names (Or what ever the identifier you create in the room editor is called) as keys. Really countless ways. How do you intend on representing your items?
Actually I wanted to put the items in the single chests without creating countless objects with the same chest sprite. I tried with the creation code but I don't know how to use it. Could you explain me how it works?
 
D

Drepple

Guest
That shouldn't happen. The creation event of the object runs before the creation code the object has in a room, so any value that is assigned to a variable in the creation event will be overwritten if the same variable is set to something else in the creation code. Use "show_debug_message(item);" to check what the value of the item variable is while running the game and then check where in your code you have set the variable to that value. Perhaps that way you can fix it.
 
M

Marco Savarese

Guest
That shouldn't happen. The creation event of the object runs before the creation code the object has in a room, so any value that is assigned to a variable in the creation event will be overwritten if the same variable is set to something else in the creation code. Use "show_debug_message(item);" to check what the value of the item variable is while running the game and then check where in your code you have set the variable to that value. Perhaps that way you can fix it.
I'll try that, thanks
 
T

Taddio

Guest
A quick and hacky way to do it would be to not have a chest object at all, but only a chest sprite that overlays the actual item on ground.
Not how I would do it if I needed complex drop calculations, but in cases where the contained items are set, it would work very well.
 
T

Timothy

Guest
A quick and hacky way to do it would be to not have a chest object at all, but only a chest sprite that overlays the actual item on ground.
Not how I would do it if I needed complex drop calculations, but in cases where the contained items are set, it would work very well.
That is no different than having multiple chest objects with the same sprite... Just more annoying to do.
 
T

Taddio

Guest
That is no different than having multiple chest objects with the same sprite... Just more annoying to do.
Having no obj_chest is the same as having multiple ones? Hmmm...okay...
I don't see how "annoying" it can be, you could do it in 1 line of code at the end of your obj_item draw event...
Code:
if(!is_picked_up) { draw_sprite(spr_chest,0,x,y); }
You're free to create instances instead of just drawing sprites, it's just not my style...anyway
 
T

Timothy

Guest
Having no obj_chest is the same as having multiple ones? Hmmm...okay...
I don't see how "annoying" it can be, you could do it in 1 line of code at the end of your obj_item draw event...
Code:
if(!is_picked_up) { draw_sprite(spr_chest,0,x,y); }
You're free to create instances instead of just drawing sprites, it's just not my style...anyway
I'm talking about your "item on the ground" which is a unique instance of your item, so you're still creating instance and drawing a chest sprite. That is absolutely the same as simply having superate chest objects with the added need to draw over it, thus more work. The only way this makes sense at all is if you plan on using your item object for more than just hiding behind a drawn chest. Otherwise it's no different from making multiple chest objects. That was my point.
 
Top