Elevator scripting

broken avatar :(
Created 558 days ago
by joshs1982
0 Members and 1 Guest are viewing this topic.
574 views
broken avatar :(
×
broken avatar :(
Location: usArkansas
Date Registered: 1 November 2013
Last active: 136 days ago
Posts
5
Respect
Forum Rank
Legless Crawler
Primary Group
Member
×
joshs1982's Groups
joshs1982's Contact & Social Links
Can anyone help me with a script for 3 elevators in my map, i have tried many times and failed but think i'm somewhat close. Any help would be much appreciated.

One elevator is 3 floors the others are 2, i also have a .menu file tombmx helped me with that will function the elevator from a trigger.
broken avatar :(
×
broken avatar :(
Location: usArkansas
Date Registered: 1 November 2013
Last active: 136 days ago
Posts
5
Respect
Forum Rank
Legless Crawler
Primary Group
Member
×
joshs1982's Groups
joshs1982's Contact & Social Links
This is what I have so far, any help would be much appreciated. This is for a 3 floor freight elevator.

main()
{
  level.elevDown=true;
  level.elevUp=true;
  level.elevMove=false;
  level.current_floor=0;
  level.current_floor=1;
  level.current_floor=2;
  switchTOP=getentarray("ups","targetname");
  for(i=0; i<switchTOP.size; i++)
   switchTOP[i] thread elev_think();
}

elev_think()
{
  IdoorLEFT=getent("leftindoor", "targetname");
  IdoorRIGHT=getent("rightindoor", "targetname");
  Odoor2L=getent("2leftdoor", "targetname");
  Odoor2R=getent("2rightdoor", "targetname");
  Odoor1L=getent("1leftdoor", "targetname");
  Odoor1R=getent("1rightdoor", "targetname");
  Odoor0L=getent("0leftdoor", "targetname");
  Odoor0R=getent("0rightdoor", "targetname");
  thread door_open(IdoorLEFT, IdoorRIGHT, OdoorBL, OdoorBR);
  while(1)
  {
   self waittill ("trigger");
   if(level.elevMove==false)
    {
     level.elevMove=true;
     thread elev_move();
    }
  }
}

elev_move()
{
  etime=5;
  zdirec="z";
  zdist1=376;
  zdist2=248;
  zdist3=0;
  IdoorLEFT=getent("leftindoor", "targetname");
  IdoorRIGHT=getent("rightindoor", "targetname");
  Odoor2L=getent("2leftdoor", "targetname");
  Odoor2R=getent("2rightdoor", "targetname");
  Odoor1L=getent("1leftdoor", "targetname");
  Odoor1R=getent("1rightdoor", "targetname");
  Odoor0L=getent("0leftdoor", "targetname");
  Odoor0R=getent("0rightdoor", "targetname");
  Elevator=getent("elevator", "targetname");
  if(level.current_floor==2)
   {
    door_close(IdoorLEFT, IdoorRIGHT, Odoor2L, Odoor2R);
    wait(.1);
    Elevator thread move_func(zdist1, etime, zdirec);
    IdoorLEFT thread move_func(zdist1, etime, zdirec);
    IdoorRIGHT thread move_func(zdist1, etime, zdirec);
    Elevator waittill ("movedone");
    door_open(IdoorLEFT, IdoorRIGHT, Odoor2L, Odoor2R);
    level.elevDown=true;
    level.elevUp=false;
    level.elevMove=false;
   }
   else if(level.current_floor==1)
   {
    door_close(IdoorLEFT, IdoorRIGHT, Odoor1L, Odoor1R);
    wait(.1);
    Elevator thread move_func(zdist2, etime, zdirec);
    IdoorLEFT thread move_func(zdist2, etime, zdirec);
    IdoorRIGHT thread move_func(zdist2, etime, zdirec);
    Elevator waittill ("movedone");
    door_open(IdoorLEFT, IdoorRIGHT, Odoor1L, Odoor1R);
    level.elevDown=true;
    level.elevUp=true;
    level.elevMove=false;
   }
  else(level.current_floor==0)
  {
   door_close(IdoorLEFT, IdoorRIGHT, OdoorTL, OdoorTR);
   wait(.1);
   Elevator thread move_func(zdist3, etime, zdirec);
   IdoorLEFT thread move_func(zdist3, etime, zdirec);
   IdoorRIGHT thread move_func(zdist3, etime, zdirec);
   Elevator waittill ("movedone");
   door_open(IdoorLEFT, IdoorRIGHT, Odoor0L, Odoor0R);
   level.elevDown=false;
   level.elevUp=true;
   level.elevMove=false;
  }
  wait(.1);
}

door_close(leftIN, rightIN, leftOUT, rightOUT)
{
  LDclose=-66.8;
  RDclose=-211.1;
  ydirec="x";
  dtime=1.1;
  leftIN thread move_func(LDclose,dtime, ydirec);
  rightIN thread move_func(RDclose,dtime, ydirec);
  wait(1);
  leftOUT thread move_func(LDclose,dtime, ydirec);
  rightOUT thread move_func(RDclose,dtime, ydirec);
  wait(1);
 }

door_open(leftyIN, rightyIN, leftyOUT, rightyOUT)
{
  LDopen=-26.8;
  RDopen=-251.1;
  ydirec="x";
  dtime=1.1;
  leftyOUT thread move_func(LDopen,dtime, ydirec);
  rightyOUT thread move_func(RDopen,dtime, ydirec);
  wait(1);
  leftyIN thread move_func(LDopen,dtime, ydirec);
  rightyIN thread move_func(RDopen,dtime, ydirec);
 }

move_func(dist,time,direc)
{
  if(direc=="z")
  self movez (dist, time, (time/2), (time/2));
  if(direc=="x")
   self movex (dist, time, (time/2), (time/2));
   self waittill ("movedone");
}

 

Login

or login with an authentication provider below
Sign In with Google
Sign In with Twitter
Sign In with Discord
Sign In with Steam
Sign In with Twitch
Loading ...