1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
21:
22:
23:
24:
25:
26:
27:
28:
29:
30:
31:
32:
33:
34:
35:
36:
37:
38:
39:
40:
41:
42:
43:
44:
45:
46:
47:
48:
49:
50:
51:
52:
53:
54:
55:
56:
57:
58:
59:
60:
61:
62:
63:
64:
65:
66:
67:
68:
69:
70:
71:
72:
73:
74:
75:
76:
77:
78:
79:
80:
81:
82:
83:
84:
85:
86:
87:
88:
89:
90:
91:
92:
93:
94:
95:
96:
97:
98:
99:
100:
101:
102:
103:
104:
105:
|
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");
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=440;
zdist2=-440;
IdoorLEFT=getent("leftindoor", "targetname");
IdoorRIGHT=getent("rightindoor", "targetname");
OdoorTL=getent("topleftdoor", "targetname");
OdoorTR=getent("toprightdoor", "targetname");
OdoorBL=getent("bottomleftdoor", "targetname");
OdoorBR=getent("bottomrightdoor", "targetname");
Elevator=getent("elevator", "targetname");
if(level.elevDown==true)
{
door_close(IdoorLEFT, IdoorRIGHT, 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.elevDown=false;
level.elevMove=false;
}
else
{
door_close(IdoorLEFT, IdoorRIGHT, OdoorTL, OdoorTR);
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, OdoorBL, OdoorBR);
level.elevDown=true;
level.elevMove=false;
}
wait(.1);
}
door_close(leftIN, rightIN, leftOUT, rightOUT)
{
LDclose=41;
RDclose=-41;
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=-41;
RDopen=41;
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");
}
|