//argument0 = global.invpos
//argument1 = object
//argument2 = weight of objects
var closest_obj;
closest_obj = 0;
if place_meeting(o_inv_back.x + global.inv_array[0,1],o_inv_back.y + global.inv_array[0,2],argument1)
{
closest_obj = 1;
}
if place_meeting(o_inv_back.x + global.inv_array[1,1],o_inv_back.y + global.inv_array[1,2],argument1)
{
closest_obj = 2;
}
if place_meeting(o_inv_back.x + global.inv_array[2,1],o_inv_back.y + global.inv_array[2,2],argument1)
{
closest_obj = 3;
}
if argument0 > 0
{
if (global.inv_array[closest_obj-1,0] > argument2)
{
global.inv_array[closest_obj-1,0] -= argument2;
global.inv_array[closest_obj-1,3] += 1;
draw_text(o_inv_back.x + global.inv_array[closest_obj-1,1] + 32,o_inv_back.y + global.inv_array[closest_obj-1,2],global.inv_array[closest_obj-1,3]);
}
}
else
{
instance_create(o_inv_back.x+global.inv_array[argument0,1],o_inv_back.y+global.inv_array[argument0,2],argument1);
global.invnum += 1;
}
- Game Maker Community
- → Viewing Profile: Posts: fragfest09
fragfest09
Member Since 26 Jul 2009Offline Last Active Feb 12 2011 12:56 AM
Community Stats
- Group New Member
- Active Posts 31
- Profile Views 1132
- Member Title GMC Member
- Age Age Unknown
- Birthday Birthday Unknown
-
Gender
Not Telling
Posts I've Made
In Topic: negative array index
11 July 2010 - 09:18 PM
ok so i got rid of the error but it wont draw the number now, here's the new code:
In Topic: negative array index
11 July 2010 - 09:00 PM
exactly, so those lines i used to figure out the closest obj, first its not complete but should work, and that is where it is messing up.it should say "negative array index or index out of bounds", no?
Your probably trying to access an index that's out of bounds of your array.
Also:
closest_obj-1
if closest_obj is 0, then you will be accessing a negative array index.
In Topic: inventory array screwing up on third collect
07 July 2010 - 04:53 AM
nvm i figured it out, if a mod would close this topic that would be good.
In Topic: drawing inventory failing
06 July 2010 - 01:57 AM
You don't delete the sprite when you're done drawing it. You just let it be, and don't draw it. So get rid of all the parts in there about deleting the sprite, and you should be fine.
could you explain this a little more, what i want to do is draw a sprite when i press "i" and delete it when i press "escape".
yeah, I bet you have an object for the inventory as well, so you dont need to delete the sprite...
When an object is destroyed, all the sprites it was drawing are deleted. So dont bother.
Just have a central inventory object, have that spawn all of the slots, and when its destroyed destroy all the slots. Why do you need to draw a sprite in the first place?
because im not using an object for them.
In Topic: drawing inventory failing
06 July 2010 - 12:10 AM
You don't delete the sprite when you're done drawing it. You just let it be, and don't draw it. So get rid of all the parts in there about deleting the sprite, and you should be fine.
could you explain this a little more, what i want to do is draw a sprite when i press "i" and delete it when i press "escape".
- Game Maker Community
- → Viewing Profile: Posts: fragfest09
- Privacy Policy
- GMC Rules and Forum Rules ·



Find content