Jump to content

Connecting actions and disabeling others


Recommended Posts

Basically how do you connect actions but also disable other actions in the same script. Let's say the player presses a button to lower platform 1, platform 1 lowers, but the button for platform 2 is now unusable, and vice versa. I'm reading the wiki but I'm not grasping this.

 

Using switch/case function:

 

Script 1 (void)
{
 switch(Plat_DownByValue(3,6, 0, 17))
 {
  case 1:
  Plat_DownByValue(3, 6, 0, 17);
  break;
  }
  switch (Plat_DownByValue(4, 6, 0, 17))
  {
  case 1:
  Plat_DownByValue(4, 6, 0, 17);
  }

 

Edited by FearNoEvil

Share this post


Link to post

Ok ok. After some rest and a bit more reading I'm finally getting somewhere. I realize the errors of my ways so I scrapped the above script and made a new one.

 

#include "zcommon.acs"

bool platform1Lowered = false;
bool platform2Lowered = false;

Script 1 (int platformNumber)
{// One platform lowers the other gets disabled permanently, vice versa
    if (platformNumber == 1)
    {
        platform1Lowered = true;
        Plat_DownByValue(1,15,0,17);
    }
    else if (platformNumber == 2)
    {
        platform2Lowered = false;
    }


    if (platformNumber == 2)
    {
        platform2Lowered = true;
        Plat_DownByValue(2,15,0,17);
    }
    else if (platformNumber == 2)
    {
        platform1Lowered = false;
    }
}

 

It works sorta. The platforms lower after pressing their respective switches, but what I want is after pressing one switch, the other switch for the other platform is disabled permanently, i.e. the other switch doesn't flip and its platform does not lower. 

 

 

Edited by FearNoEvil

Share this post


Link to post

How about this? The second switch will still flip, but won't do anything. It would take more tinkering to make it so it doesn't. I just put this together in my head, so hopefully it's correct.

 

#include "zcommon.acs"

bool platform1Lowered = false;
bool platform2Lowered = false;

Script 1 (int platformNumber)
{
    if (platformNumber == 1 && platform1Lowered == false)
    {
        platform1Lowered = true;

        platform2Lowered = true;
        Plat_DownByValue(1,15,0,17);
    }


    else if (platformNumber == 2 && platform2Lowered == false )
    {

        platform1Lowered = true;
        platform2Lowered = true;
        Plat_DownByValue(2,15,0,17);
    }
}

Edited by Rifleman

Share this post


Link to post

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...