1. Hey! Guest! The 34th GMC Jam will take place between August 22nd, 12:00 UTC (Thursday noon) and August 26th, 12:00 UTC (Monday noon). Why not join in! Click here to find out more!
    Dismiss Notice

Please help read the post

Discussion in 'Programming' started by WhyNotUsePaper, Apr 21, 2019.

  1. WhyNotUsePaper

    WhyNotUsePaper Member

    Joined:
    Apr 21, 2019
    Posts:
    5
    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;
          } 
    }
        
    
     
  2. woods

    woods Member

    Joined:
    Jun 21, 2016
    Posts:
    223
    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
    }
    
    
     
  3. YoSniper

    YoSniper Member

    Joined:
    Jun 24, 2016
    Posts:
    418
    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
    }
     

Share This Page

  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice