Massassi Forums Logo

This is the static archive of the Massassi Forums. The forums are closed indefinitely. Thanks for all the memories!

You can also download Super Old Archived Message Boards from when Massassi first started.

"View" counts are as of the day the forums were archived, and will no longer increase.

ForumsCog Forum → I need cogs... or lots of help :-)
I need cogs... or lots of help :-)
2004-05-31, 1:20 AM #1
Hello again, dear massassians.

I am again needing some help for cogs.

This time I have an elevator, a door above it and two switches. When the door above the elevator is closed, the elevator isn't supposed to move, and when you'd press the switch to move the elevator, it wouldn't move. However, when you press the other switch to open the door above the elevator, the elevator would now move as the door above it is open. So it's quite simple.

But I don't have skills to do that. So basically I need to know how to make the cog understand that the elevator can't move when the door is closed, but when it's open, it's able to move.

Thank you.

------------------
"Tickets, please."
"You don't have to see our tickets."
"What?"
"These are not the tickets you're loking for."
"Tickets, please."
"You don't have to see our tickets."
"What?"
"These are not the tickets you're loking for."
2004-05-31, 9:00 PM #2
anyone?

------------------
"Tickets, please."
"You don't have to see our tickets."
"What?"
"These are not the tickets you're loking for."
"Tickets, please."
"You don't have to see our tickets."
"What?"
"These are not the tickets you're loking for."
2004-05-31, 10:30 PM #3
Here comes Edward with the spur-of-the-moment COGs.

Code:
# The door that blocks the elevator.
#
# By Edward
symbols

message    activated
message    startup

thing      elevator
thing      door

surface    switchelev
surface    switchdoor

flex       doorspeed
flex       elevspeed

int        open=0    local

end
#
code
startup:
        MoveToFrame(door,0,100);
        MoveToFrame(elevator,0,100);
        // Making sure the door is closed and the elevator is on the bottom floor.
return;
activated:
        if(GetSenderRef()==switchelev)
        {
          SetWallCel(switchelev,1);
          if(open==0)
          {
            MoveToFrame(elevator,1,elevspeed);
            sleep(0.1);
            StopThing(elevator);
            MoveToFrame(elevator,0,elevspeed);
            print("Unable to proceed to level 2!");
            SetWallCel(switchelev,0);
          }
          else
          {
            MoveToFrame(elevator,1,elevspeed);
          }
        }
        else if(GetSenderRef()==switchdoor)
        {
          if(open==1) return;
          SetWallCel(switchdoor,1);
          MoveToFrame(door,1,doorspeed);
          open=1;
        }
return;
end

Hope it works... And you may replace "level 2" with anything you like. If you want, you could replace the whole string with something else.

/Edward
Edward's Cognative Hazards
2004-05-31, 11:12 PM #4
yeah it works...

But I noticed that you can only press those buttons once, I'd like it to be so that you're able to call the elevator back from the frame 1, and also open/close the door. And that also needs to be made that when the elevator is on frame 1, the door can't be closed until the elevator is back on the first frame.

Sorry to disturb you again. [http://forums.massassi.net/html/smile.gif]

------------------
"Tickets, please."
"You don't have to see our tickets."
"What?"
"These are not the tickets you're loking for."
"Tickets, please."
"You don't have to see our tickets."
"What?"
"These are not the tickets you're loking for."
2004-06-01, 2:10 AM #5
OK...
Code:
# The door that blocks the elevator.
#
# By Edward
symbols

message    activated
message    startup

thing      elevator
thing      door

surface    switchelev
surface    switchdoor

flex       doorspeed
flex       elevspeed

int        open=0    local
int        up=0      local

end
#
code
startup:
        MoveToFrame(door,0,100);
        MoveToFrame(elevator,0,100);
        // Making sure the door is closed and the elevator is on the bottom floor.
        SetWallCel(switchelev,0);
        SetWallCel(switchdoor,0);
return;
activated:
        if(GetSenderRef()==switchelev)
        {
          SetWallCel(switchelev,1);
          if(open==0)
          {
            MoveToFrame(elevator,1,elevspeed);
            sleep(0.1);
            StopThing(elevator);
            MoveToFrame(elevator,0,elevspeed);
            print("Unable to proceed to level 2!");
            SetWallCel(switchelev,0);
          }
          else
          {
            if(up==0)
            {
              MoveToFrame(elevator,1,elevspeed);
              up=1;
            }
            else
            {
              MoveToFrame(elevator,0,elevspeed);
              up=0;
              SetWallCel(switchelev,0);
            }
          }
        }
        else if(GetSenderRef()==switchdoor)
        {
          if(up==1) return;
          if(open==1)
          {
            SetWallCel(switchdoor,0);
            MoveToFrame(door,0,doorspeed);
            open=0;
          }
          else
          {
            SetWallCel(switchdoor,1);
            MoveToFrame(door,1,doorspeed);
            open=1;
          }
        }
return;
end

That should do it... I think. Untested, unchecked, but do credit!

/Edward
Edward's Cognative Hazards
2004-06-01, 2:56 AM #6
Works exactly like it should. I made a few modifications, but it works! [http://forums.massassi.net/html/biggrin.gif]

Thanks alot.

------------------
"Tickets, please."
"You don't have to see our tickets."
"What?"
"These are not the tickets you're loking for."
"Tickets, please."
"You don't have to see our tickets."
"What?"
"These are not the tickets you're loking for."

↑ Up to the top!