Please help read the post

I dont know why but when i attach script to two of my object they both need to stand on plate to trigger it.
But when script is attached to only one of them only one needs to stand on plate to trigger it.
Please help!

Code:
///scr_preshureplate(PreshurePlateID,ActivatedObjectID,ActivatedObjectID2)

/*
pp - Preshure Plate
ao - Activated Object
ao2 - Seccond Activted Object
*/

pp = argument0;
ao = argument1;
ao2 = argument2;

lift = 1;

pressed = false;


if(place_meeting(x,y,pp))
{ 
    //Press PreshurePlate
    while(pp.y < pp.mx)
    {
       pp.y += lift;
    }

    if(ao.aot == "door" and ao2.aot == "door")
    {
        //Open door
        //Up
        while(ao.y > ao.mx)
        {
            ao.y -= lift;
        }
        ao.i.image_speed = 0.2;
        
        //Down
        while(ao2.y < ao2.mx)
        {
            ao2.y += lift;
        }
        ao2.i.image_speed = 0.2;
    }
}
else
{
    //Relese PreshurePlate
    while(pp.y > pp.st)
    {
        pp.y -= lift;
    }
    
    if(ao.aot == "door" and ao2.aot == "door")
    {
        //Close door
        //Up
        while(ao.y < ao.st)
        {
            ao.y += lift;
        }
        ao.i.image_index = -0.2;
        
        //Down
        while(ao2.y > ao2.st)
        {
            ao2.y -= lift;
        }
        ao2.i.image_index = -0.2;
      } 
}
 

woods

Member
not looking at your code,

if obj_1 is on plate then do stuff else dont do stuff
if obj_2 on on plate do stuff else dont do stuff

logic says to me that if either obj_1 or obj_2 is not on the plate, it wont do stuff because of the else

Code:
if(place_meeting(x,y,pp))
{
   //Press PreshurePlate
}

else
{
   //Relese PreshurePlate
}
 

YoSniper

Member
If the common denominator is the pressure plate, then you should check from the plate's perspective if both objects are on it.

Code:
var activate = false;
with(pp) {
    if place_meeting(x, y, ao) and place_meeting(x, y, ao2) {
        activate = true;
    }
}

if activate {
    //Do stuff with the pressure plate
}
 
Top