• 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!

GameMaker Problem with a place_meeting code

S

slmephi

Guest
Hi,
I programmed a save system for my game and have now a little problem. I have build places in the room on which i can build towers for a tower defense game. When the tower is build on it the build place gets invisible and does not react anymore to build clicks. until this point it works all correctly. Now i want to save this. i trigger through the build palces and ask the game with an parent object collision if the buildplace is colliding with an tower. Then i want to save the tower data. the problem is now i made an palce_meeting but it always gets 0 /false as return . I read out the x y data of the buildplace and of the tower and both are exact the same but the place_meeting still returns 0.
Here is the code i use:

Code:
number_of_buildplaces = instance_number(obj_towerbuildplace);
key = 0;
ini_open("autosave/data_2.ini");
ini_write_real("data_2", "data_2", global.mapid ); //MAP ID
while(key < number_of_buildplaces)
{
chosen_buildplace = instance_find(obj_towerbuildplace,key);
if(place_meeting(chosen_buildplace.x,chosen_buildplace.y,obj_tower_parent))
{
tower_on_buildplace = instance_nearest(chosen_buildplace.x, chosen_buildplace.y, obj_tower_parent);
tower_type = 0;
temp_tower_lvl = 0;
temp_damage_lvl = 0;
temp_critchance_lvl = 0;
temp_critmulti_lvl = 0;
temp_attackspeed_lvl = 0;
temp_bulletspeed_lvl = 0;
with(tower_on_buildplace)
{
other.tower_type = towertype;
other.temp_tower_lvl = tower_lvl;
other.temp_damage_lvl = damage_lvl;
other.temp_critchance_lvl = critchance_lvl;
other.temp_critmulti_lvl = critmulti_lvl;
other.temp_attackspeed_lvl = attackspeed_lvl;
other.temp_bulletspeed_lvl = bulletspeed_lvl;
}
}
else
{
tower_type = 0;
temp_tower_lvl = 0;
temp_damage_lvl = 0;
temp_critchance_lvl = 0;
temp_critmulti_lvl = 0;
temp_attackspeed_lvl = 0;
temp_bulletspeed_lvl = 0;
}
ini_write_real("data_2", "data_2_" + string(key) + "_1", tower_type ); //tower_type
ini_write_real("data_2", "data_2_" + string(key) + "_2", temp_tower_lvl ); //temp_tower_lvl
ini_write_real("data_2", "data_2_" + string(key) + "_3", temp_damage_lvl ); //temp_damage_lvl
ini_write_real("data_2", "data_2_" + string(key) + "_4", temp_critchance_lvl ); //temp_critchance_lvl
ini_write_real("data_2", "data_2_" + string(key) + "_5", temp_critmulti_lvl ); //temp_critmulti_lvl
ini_write_real("data_2", "data_2_" + string(key) + "_6", temp_attackspeed_lvl ); //temp_attackspeed_lvl
ini_write_real("data_2", "data_2_" + string(key) + "_7", temp_bulletspeed_lvl ); //temp_bulletspeed_lvl
key++;
}
ini_close();

can someone find the error? The code always reacts like there would be no collision but its there. I also already checked the parent object and it has definitively all towers in it as child objects. Also i tried to check for a specific tower and it also always returns 0

I have the same place_meeting in the build_place to look if there is already an tower on it and make it visible or not and react to clicks or not. this working correctly.
 
Last edited by a moderator:

TheouAegis

Member
Does the object running this code have a sprite_index set? You find the IDs of obj_towerbuildplace and the locations, but you don't set the place_meeting() to apply to those objects, so the code is running place_meeting() in the scope of the instance calling this code, which will not work if the instance calling this code does not have a sprite_index value.
 
Top