May 28, 2018, 02:20:13 AM

Author Topic: Making a working elevator?  (Read 68980 times)

WinCat

  • Founder
  • ***
  • Posts: 1094
  • Karma: 86
    • View Profile
    • My Site
Re: Making a working elevator?
« Reply #105 on: November 03, 2014, 12:24:36 AM »
Yuo should still do it simular to how i said, keeping track what floor you are on.

instead of all this level.0 level.1 stuff you have, which is not even valid.

joshs1982

  • Infected
  • ***
  • Posts: 161
  • Karma: 0
    • View Profile
Re: Making a working elevator?
« Reply #106 on: November 03, 2014, 03:22:58 PM »
I just don't understand what your getting at. I'm trying to make it from what your saying. I don't know anything about this except what you thought me. I don't know what way to make it know what floor I'm on, that's why I thought you was saying to make level.1 not level.elevDown==true. I don't know I'm stuck for now I guess. :-[

Are you saying it should be if(0,2) or if(0==true, 2==true)
That would be for the 1st floor, floor 1.
« Last Edit: November 03, 2014, 04:17:41 PM by joshs1982 »

joshs1982

  • Infected
  • ***
  • Posts: 161
  • Karma: 0
    • View Profile
Re: Making a working elevator?
« Reply #107 on: November 03, 2014, 03:23:56 PM »
I'll write a example tomorrow.
Can you post that example? I'll try to go from that.
« Last Edit: November 03, 2014, 09:49:34 PM by joshs1982 »

joshs1982

  • Infected
  • ***
  • Posts: 161
  • Karma: 0
    • View Profile
Re: Making a working elevator?
« Reply #108 on: November 05, 2014, 01:56:29 PM »
I'm still trying. I hope this will work but I'm sure it won't since it's level.blah blah blah..
If this will not work, will you please post me an example that would? Thanks.

Code: [Select]
main()
{
  level.elevDown=true;
  level.elevMove=false;
  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");
  OdoorTL=getent("topleftdoor", "targetname");
  OdoorTR=getent("toprightdoor", "targetname");
  OdoorML=getent("middleleftdoor", "targetname");
  OdoorMR=getent("middlerightdoor", "targetname");
  OdoorBL=getent("bottomleftdoor", "targetname");
  OdoorBR=getent("bottomrightdoor", "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");
  OdoorTL=getent("topleftdoor", "targetname");
  OdoorTR=getent("toprightdoor", "targetname");
  OdoorML=getent("middleleftdoor", "targetname");
  OdoorMR=getent("middlerightdoor", "targetname");
  OdoorBL=getent("bottomleftdoor", "targetname");
  OdoorBR=getent("bottomrightdoor", "targetname");
  Elevator=getent("elevator", "targetname");
  if(level.1==true, level.0==true)
   {
    door_close(IdoorLEFT, IdoorRIGHT, OdoorML, OdoorMR, OdoorBL, OdoorBR);
    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, OdoorTL, OdoorTR);
    level.1=true;
    level.0=true;
    level.elevMove=false;
   }
  else if(level.0==true, level.2==true)
   {
    door_close(IdoorLEFT, IdoorRIGHT, OdoorTL, OdoorTR, OdoorBL, OdoorBR);
    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, OdoorML, OdoorMR);
    level.0=true;
    level.2=true;
    level.elevMove=false;
   }
  else
  {
   door_close(IdoorLEFT, IdoorRIGHT, OdoorTL, OdoorTR, OdoorML, OdoorMR);
   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, OdoorBL, OdoorBR);
   level.1=true;
   level.2=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");
}
« Last Edit: November 05, 2014, 02:02:13 PM by joshs1982 »

WinCat

  • Founder
  • ***
  • Posts: 1094
  • Karma: 86
    • View Profile
    • My Site
Re: Making a working elevator?
« Reply #109 on: November 05, 2014, 08:14:46 PM »
Just have one var and assign it a integer.

Code: [Select]

main()
{
   level.current_floor = 0;

}

Then you can check this var.

Code: [Select]
if(level.current_floor == 1) // are we one floor one?

set the current floor:
Code: [Select]
level.current_floor = 2;

joshs1982

  • Infected
  • ***
  • Posts: 161
  • Karma: 0
    • View Profile
Re: Making a working elevator?
« Reply #110 on: November 06, 2014, 06:24:14 PM »
Just have one var and assign it a integer.

Code: [Select]

main()
{
   level.current_floor = 0;

}

Then you can check this var.

Code: [Select]
if(level.current_floor == 1) // are we one floor one?

set the current floor:
Code: [Select]
level.current_floor = 2;
Thanks Tom. I'll work on it some in a few and post what I got.

joshs1982

  • Infected
  • ***
  • Posts: 161
  • Karma: 0
    • View Profile
Re: Making a working elevator?
« Reply #111 on: November 06, 2014, 07:02:44 PM »
This is what I got now. Looking better?

zdist1 is the 2nd floor
zdist2 is the 1st floor
zdist3 is the basement ground floor

The game starts on the basement ground floor "zdist3"

Code: [Select]
main()
{
  level.current_floor = 0;
  level.elevMove=false;
  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");
  OdoorTL=getent("topleftdoor", "targetname");
  OdoorTR=getent("toprightdoor", "targetname");
  OdoorML=getent("middleleftdoor", "targetname");
  OdoorMR=getent("middlerightdoor", "targetname");
  OdoorBL=getent("bottomleftdoor", "targetname");
  OdoorBR=getent("bottomrightdoor", "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");
  OdoorTL=getent("topleftdoor", "targetname");
  OdoorTR=getent("toprightdoor", "targetname");
  OdoorML=getent("middleleftdoor", "targetname");
  OdoorMR=getent("middlerightdoor", "targetname");
  OdoorBL=getent("bottomleftdoor", "targetname");
  OdoorBR=getent("bottomrightdoor", "targetname");
  Elevator=getent("elevator", "targetname");
  if(level.current_floor == 2)
   {
    door_close(IdoorLEFT, IdoorRIGHT, OdoorML, OdoorMR, OdoorBL, OdoorBR);
    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, OdoorTL, OdoorTR);
    level.current_floor = 2;
    level.elevMove=false;
   }
  else if(level.current_floor == 1)
   {
    door_close(IdoorLEFT, IdoorRIGHT, OdoorTL, OdoorTR, OdoorBL, OdoorBR);
    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, OdoorML, OdoorMR);
    level.current_floor = 1;
    level.elevMove=false;
   }
  else
  {
   door_close(IdoorLEFT, IdoorRIGHT, OdoorTL, OdoorTR, OdoorML, OdoorMR);
   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, OdoorBL, OdoorBR);
   level.current_floor = 0;
   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");
}

Question, can I remove the line below from elev_think() to make all doors closed on the elevator until the trigger outside has been triggered?
From what I see in the script the doors on the bottom floor would be wide open. Correct?

Code: [Select]
   thread door_open(IdoorLEFT, IdoorRIGHT, OdoorBL, OdoorBR);
« Last Edit: November 06, 2014, 09:46:58 PM by joshs1982 »

WinCat

  • Founder
  • ***
  • Posts: 1094
  • Karma: 86
    • View Profile
    • My Site
Re: Making a working elevator?
« Reply #112 on: November 10, 2014, 09:17:54 PM »
Why don't you test it in game?

You still have a few logic errors, meaning it won't work how you want currently, but if you test it in game should make it more clear to you what's wrong.

joshs1982

  • Infected
  • ***
  • Posts: 161
  • Karma: 0
    • View Profile
Re: Making a working elevator?
« Reply #113 on: November 10, 2014, 10:11:06 PM »
Why don't you test it in game?

You still have a few logic errors, meaning it won't work how you want currently, but if you test it in game should make it more clear to you what's wrong.
So I build the elevator and Add the .gsc's for the elevator and the menu to my mod_map_name then compile. I don't know what kvp's to give the triggers to call the menu. I been working on this map for a ling time was scared I would screw it up if I just start trying things I don't fully understand. Sorry for all the questions. :-[

joshs1982

  • Infected
  • ***
  • Posts: 161
  • Karma: 0
    • View Profile
Re: Making a working elevator?
« Reply #114 on: December 09, 2014, 07:22:14 PM »
Why don't you test it in game?

You still have a few logic errors, meaning it won't work how you want currently, but if you test it in game should make it more clear to you what's wrong.
I'm trying to test in game but when I run the game the doors are closed to the elevator just how I have them in radiant. Do I need to make them be open instead? I'm so confused and have no idea what to do. I've been trying though. I guess I'm at a stand still with this elevator so I'll just detail the map more I guess.

If I can't get it to work I may just release it with Out of Order posted on the elevator doors. Really would like to have one though that works so I can understand and make more for the other elevator shafts.

joshs1982

  • Infected
  • ***
  • Posts: 161
  • Karma: 0
    • View Profile
Re: Making a working elevator?
« Reply #115 on: December 15, 2014, 08:00:09 PM »
I give up. I can't make it do anything, I'm trying and trying to do what you have told me and what it says at the top of the thread but still nothing. I can't understand by trying in game like you said because it does nothing every time. If anyone would like to help me with the elevator let me know here or pm me. Thanks.

joshs1982

  • Infected
  • ***
  • Posts: 161
  • Karma: 0
    • View Profile
Re: Making a working elevator?
« Reply #116 on: May 16, 2018, 07:19:05 PM »
It's been a while but i'm trying again. Here is what I have so far for main script. Can anyone tell me if I'm in the rite direction. I made a line level.elevUp=true;
Would that even work? I assume what ever I make up for the main is what the rest functions off of, I know thats probably wrong though.
Heres what I got for main.

Code: [Select]
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();
}