GML [Solved] Need alternative to with (other) or failure

R

Red Phantom

Guest
Code:
if place_meeting(x,y,obj_3x3_Houses) and global.exterior_doors_open = false and !instance_exists(obj_Door_Opened)

  {
  city_front_house = 0
  with (other)
    {
    if house_number = city_front_house
        {
        //with (obj_Controls) instance_destroy()
        instance_create(0,0,obj_Door_Opened)
        global.inconversation = true
        green_door_opened = 0
        image_index = green_door_opened
        }
    }
  }
Here I try to use with (other) to refer to the specific instance ID of obj_3x3_Houses that is within the function place_meeting.
I understand that using 'other' in this way does not work. So how can I refer to the specific instance of obj_3x3_Houses which is the third argument of the called function place_meeting?

Context (Shouldn't be necessary to solving the problem but may help)
There are multiple instances of obj_3x3_Houses in the room.
Originally I had separate objects for each house. But now I am condensing my resources to minimize the data, i.e. megabytes of my downloadable game to make it load and run faster and more smoothly.
So I am trying to merge my 3x3 (96x96pixel) houses into one object.
In the room I give each individual house object index a unique house number under local variable house_number, inside the creation code(in the room) of the object (i.e. not under the regular creation event)
Capture21.PNG
 

FrostyCat

Redemption Seeker
See: What's the difference: Objects and Instances
Collision-checking functions: instance_place() and instance_position() are the instance-ID-oriented analogues of place_meeting() and position_meeting(). Functions that start with collision_ all return instance IDs. Save that instance ID into a variable (e.g. var inst_enemy = instance_place(x, y, obj_enemy);), then use that as the subject to work with (e.g. inst_enemy.hp -= 10;). Note that these functions return noone upon not finding a collision. Always account for this special case whenever you handle collisions this way.
Code:
var inst_3x3_Houses = instance_place(x, y, obj_3x3_Houses);
if (inst_3x3_Houses != noone and !global.exterior_doors_open and !instance_exists(obj_Door_Opened))
{
  city_front_house = 0
  with (inst_3x3_Houses)
 
R

Red Phantom

Guest
I just tried this and it worked.
Thank you!
Can you explain this part of the code for me? What is it essentially saying?
Code:
if inst_3x3_Houses != noone
 
Last edited by a moderator:
I just tried this and it worked.
Thank you!
Can you explain this part of the code for me? What is it essentially saying?
Code:
if inst_3x3_Houses != noone
@Danei already answered your question, but I wanted to point out that the answer was in the manual all along. Under both "instance_place" and "Keywords" -> "noone". Next time you don't know what a piece of code given to help you out means, try searching it in the manual first. You might be surprised to find you don't have to ask any more questions!
 
Top