Jump to content
  • 0

Back at it again with these damn doors


Skemech

Question

why will the door open no problem, but it won't close back? (I added the Delay (2); because I didn't know what else to do)

 

========================

 

 

931051245_damndoor.png.19fef7d09b83c8cc8d2ddf855774e5b4.png

Share this post


Link to post

9 answers to this question

Recommended Posts

  • 1

Read your own code back to yourself; On line 54, you set leftDoor to 2, then on line 57, you check if leftDoor is set to 2 regardless of the previous if statement.

Also you want to use TagWait.

Edited by Edward850

Share this post


Link to post
  • 1

You still aren't reading your code correctly,  which is infuriating because you already discussed this in another thread and explicitly know the answer.

 

The website explicitly tells you what tagwait is, it makes the script wait for the sector to stop performing its action. It even gives you an example that matches your code.

 

You are spending way too much time asking for fish when you should be asking how to fish, it seems.

Edited by Edward850

Share this post


Link to post
  • 1

No that's the silly thing,  you know the answer,  you have the knowledge from a previous thread,  you're just refusing to put it together and I don't know why.

 

So fine, here's the answer. I'm disappointed though.

 

script 3 (void)
{
  if (leftDoor == 1)
  {
    Door_open (4, 128, 0);
    leftDoor = 2;
  }
  // Else goes here otherwise you pointlessly run the block immediatly after, resetting leftDoor to 1
  else if(leftDoor == 2)
  {
    Door_close (4, 128, 0);
    leftDoor = 1;
  }
  TagWait(4); // prevent script from running again until door finishes action, otherwise the door state could be set out of sync.
}

 

Share this post


Link to post
  • 1
11 hours ago, Skemech said:

The door will only open if equal to 1, once open equals to 2

 

door will only close if equal to 2, once closed equal to 1

 

on paper it sounds correct, and that site does a piss poor job describing what a tagwait is. wtf is a tagwait

 

Edward covered the else if part, but I wanted to point out that this is a faulty description of what the code is doing, which is another part of why you were confused. 

 

Trying to preserve your phrasing order, it's more like: 

 

- The door will attempt to open if (the variable is) equal to 1, then will be set equal to 2.

- The door will attempt to close if equal to 2, then will be set equal to 1


The code invokes functions Door_open() and Door_close() that try to open or close the door. Those functions don't guarantee that the doors will be opened or closed. They can still fail, which will happen for example if the door is still moving when one is invoked.

 

Additionally, there's no "once open equals to 2" or "once closed equal to 1" going on; the blocks will set the variables as you've written regardless of whether the doors actually open or close properly; there's no logical need in place for the door to open/close in order for the variable to be changed.

 

That's why it's possible in the original code to (for example) fail to close the door but still end up with the variable set to 1. 

 

An important idea is that computers are very literal and don't innately grasp your human intent. You have to be really pedantic because even slight discrepancies between what you mean and what the code is truly doing can lead to bugs or you not understanding how something is working. And layering misunderstanding on top of a bug can be a nasty combination because now you're hopeless to debug it except by chance until you correct the misunderstanding. 

Share this post


Link to post
  • 1

If the "leftDoor" variable is only used by this script, then this script could be made simpler by just using Suspend instead.

script 3 (void)
{
  Door_Open(4, 128, 0);
  TagWait(4);
  
  Suspend;
  
  Door_Close(4, 128, 0);
  TagWait(4); // prevent script from running again until door finishes action, otherwise the door state could be set out of sync.
}

 

Share this post


Link to post
  • 0

they go from the floor and touch the ceiling, because as far as I know it's the only way to not have that weird texture slide when doors open

Share this post


Link to post
  • 0

The door will only open if equal to 1, once open equals to 2

 

door will only close if equal to 2, once closed equal to 1

 

on paper it sounds correct, and that site does a piss poor job describing what a tagwait is. wtf is a tagwait

Share this post


Link to post
  • 0

alright, how do I fish? Can you think of a string of acs that (when the player presses a button) a door opens, and when you press it again ONLY THEN the door closes?

Share this post


Link to post
Guest
This topic is now closed to further replies.
×
×
  • Create New...