Gamestudio Links
Zorro Links
Newest Posts
Zorro 2.70
by jcl. 09/29/25 09:24
optimize global parameters SOLVED
by dBc. 09/27/25 17:07
ZorroGPT
by TipmyPip. 09/27/25 10:05
assetHistory one candle shift
by jcl. 09/21/25 11:36
Plugins update
by Grant. 09/17/25 16:28
AUM Magazine
Latest Screens
Rocker`s Revenge
Stug 3 Stormartillery
Iljuschin 2
Galactic Strike X
Who's Online Now
4 registered members (NewbieZorro, Grant, TipmyPip, AndrewAMD), 13,346 guests, and 5 spiders.
Key: Admin, Global Mod, Mod
Newest Members
krishna, DrissB, James168, Ed_Love, xtns
19168 Registered Users
Previous Thread
Next Thread
Print Thread
Rate Thread
Page 1 of 3 1 2 3
Multi-Stage-Elevator #63908
02/15/06 00:46
02/15/06 00:46
Joined: Mar 2005
Posts: 725
USA
TeutonicDarkness Offline OP
User
TeutonicDarkness  Offline OP
User

Joined: Mar 2005
Posts: 725
USA
Hello,


I decided I would contribute my latest work....
Its a Unique elevator code calucating for
6 different stops on each stage of the level.

Unlike most which just stop at 1 set place...
Mine uses buttons...


* Now it is not perfect by any means!
There is a flaw when going down:
It occurs instantly rather than gradual
like going up.


Anyways here it is:

Code:
  
////////////////////////////////



var 1current;
var 2current;
var 3current;
var 4current;
var 5current;
var 6current;

entity* elevator_pnt; // pointer to the elevator
entity* button_6; // pointer to button6
entity* button_5; // pointer to button5
entity* button_4; // pointer to button4
entity* button_3; // pointer to button3
entity* button_2; // pointer to button2
entity* button_1; // pointer to button1
////////////////////////////////////////////////////////


function to_6() // called from button 6 being hit

{

if(event_type == event_impact && you == player)
{
exclusive_global;
button_6.ENABLE_IMPACT = Off; //disables player impact
button_6.ENABLE_PUSH = Off;

my.ambient = 0;
6current =1;
TD_6_ele();

}
}



ACTION button6 // push me to go to stage 6 ///////////
//////////////// the position defined in this line//////////
/////////////// elevator_pnt.z= 4010.667 ;/////////////////
////////////// located in :TD_6_ele(); /////////////////

{
button_6 =me;
while (6current ==1){my.passable=on;} // so its not possible to re- trigger
while (5current ==1){my.passable=on;} // while we are moving
while (4current ==1){my.passable=on;} // as a re-trigger during move could
while (3current ==1){my.passable=on;} // cause a elevator malfunction
while (2current ==1){my.passable=on;}
while (1current ==1){my.passable=on;}



my.ENABLE_IMPACT = on;
my.ENABLE_PUSH = On;
my.event = to_6;
my.ambient = 100;

}




function TD_6_ele() // I'm the function that moves the elevator


{
elevator_pnt._speed = 2; // does nothing not implemented
exclusive_global;
while(6current ==1) // Use while here or platform only moves 1 click
{

player.x=-32.000; // We once again ensure buttons cant be re-triggered
player.y= 674.000; // because now as long as I'm moving
//beep(); // the player will be in the center of elevator
wait(1);
IF (player.x > -32.000) {player.x=-32.000;} // to abosutely make sure
IF (player.x < -32.000) {player.x=-32.000;} // player is where we want
IF (player.y > 674.000) {player.y= 674.000;} // him for the duration
IF (player.y < 674.000) {player.y= 674.000;} // of elevator movement


elevator_pnt.z= 4010.667 ; // This is where the elevator is going

elevator_pnt.z = player.z - (player.max_z - player.min_z) / 2; // keep the player onboard

if (elevator_pnt.z >= 4010.667) {elevator_pnt.z =4010.667;6current =0; //don't pass target
player.z = elevator_pnt.z + (player.max_z - player.min_z) / 2;
button_6.ENABLE_IMPACT = on;
button_6.ENABLE_PUSH = On;
}

}
6current =0;


}



//elevator_pnt.z= 4010.667 ;
//////////////////////////////////////////////

function to_5()

{

if(event_type == event_impact && you == player)
{
exclusive_global;
button_5.ENABLE_IMPACT = Off; //disables player impact
button_5.ENABLE_PUSH = Off;
my.ambient = 0;
5current =1;

TD_5_ele();

}
}



ACTION button5

{
button_5 =me;
while (6current ==1){my.passable=on;}
while (5current ==1){my.passable=on;}
while (4current ==1){my.passable=on;}
while (3current ==1){my.passable=on;}
while (2current ==1){my.passable=on;}
while (1current ==1){my.passable=on;}


MY.ENABLE_IMPACT = on;
MY.ENABLE_PUSH = On;
my.event = to_5;
my.ambient = 100;
}




function TD_5_ele()


{


elevator_pnt._speed = 2;
exclusive_global;
while(5current ==1)
{

player.x=-32.000;
player.y= 674.000;
//beep();
wait(1);
IF (player.x > -32.000) {player.x=-32.000;}
IF (player.x < -32.000) {player.x=-32.000;}
IF (player.y > 674.000) {player.y= 674.000;}
IF (player.y < 674.000) {player.y= 674.000;}
elevator_pnt.z= 3169.667;
elevator_pnt.z = player.z - (player.max_z - player.min_z) / 2; // keep the player onboard
if (elevator_pnt.z >= 3169.667) {elevator_pnt.z =3169.667;5current =0;
player.z = elevator_pnt.z + (player.max_z - player.min_z) / 2;
button_5.ENABLE_IMPACT = on;
button_5.ENABLE_PUSH = On;
}


}
5current =0;

}

//elevator_pnt.z= 3161.667 ;

/////////////////////////////////////////////

function to_4()

{

if(event_type == event_impact && you == player)
{
exclusive_global;
button_4.ENABLE_IMPACT = Off; //disables player impact
button_4.ENABLE_PUSH = Off;

my.ambient = 0;
4current =1;
TD_4_ele();

}
}



ACTION button4

{
button_4 =me;
while (6current ==1){my.passable=on;}
while (5current ==1){my.passable=on;}
while (4current ==1){my.passable=on;}
while (3current ==1){my.passable=on;}
while (2current ==1){my.passable=on;}
while (1current ==1){my.passable=on;}


MY.ENABLE_IMPACT = on;
MY.ENABLE_PUSH = On;
my.event = to_4;
my.ambient = 100;
}




function TD_4_ele()


{


elevator_pnt._speed = 2;
exclusive_global;
while(4current ==1)
{

player.x=-32.000;
player.y= 674.000;
//beep();
wait(1);
IF (player.x > -32.000) {player.x=-32.000;}
IF (player.x < -32.000) {player.x=-32.000;}
IF (player.y > 674.000) {player.y= 674.000;}
IF (player.y < 674.000) {player.y= 674.000;}


elevator_pnt.z= 2326.667 ;

elevator_pnt.z = player.z - (player.max_z - player.min_z) / 2; // keep the player onboard

if (elevator_pnt.z >= 2326.667) {elevator_pnt.z =2326.667;4current =0;
player.z = elevator_pnt.z + (player.max_z - player.min_z) / 2;
button_4.ENABLE_IMPACT = on;
button_4.ENABLE_PUSH = On;
}

}
4current =0;

}


//elevator_pnt.z= 2318.667;
////////////////////////////////////////////

function to_3()

{
if(event_type == event_impact && you == player)
{
exclusive_global;
button_3.ENABLE_IMPACT = Off; //disables player impact
button_3.ENABLE_PUSH = Off;

my.ambient = 0;
3current =1;
TD_3_ele();

}
}



ACTION button3

{
button_3 =me;
while (6current ==1){my.passable=on;}
while (5current ==1){my.passable=on;}
while (4current ==1){my.passable=on;}
while (3current ==1){my.passable=on;}
while (2current ==1){my.passable=on;}
while (1current ==1){my.passable=on;}



my.ENABLE_IMPACT = on;
my.ENABLE_PUSH = On;
my.event = to_3;
my.ambient = 100;

}



function TD_3_ele()


{


elevator_pnt._speed = 2;
exclusive_global;
while(3current ==1)
{

player.x=-32.000;
player.y= 674.000;
//beep();
wait(1);
IF (player.x > -32.000) {player.x=-32.000;}
IF (player.x < -32.000) {player.x=-32.000;}
IF (player.y > 674.000) {player.y= 674.000;}
IF (player.y < 674.000) {player.y= 674.000;}


elevator_pnt.z= 1482.667 ;

elevator_pnt.z = player.z - (player.max_z - player.min_z) / 2; // keep the player onboard

if (elevator_pnt.z >= 1482.667) {elevator_pnt.z =1482.667;3current =0;
player.z = elevator_pnt.z + (player.max_z - player.min_z) / 2;
button_3.ENABLE_IMPACT = on;
button_3.ENABLE_PUSH = On;
}

}
3current =0;

}

//elevator_pnt.z= 1474.667;
/////////////////////////////////////


function to_2()

{
if(event_type == event_impact && you == player)
{
exclusive_global;
button_2.ENABLE_IMPACT = Off; //disables player impact
button_2.ENABLE_PUSH = Off;

my.ambient = 0;
2current =1;
TD_2_ele();

}



}



ACTION button2

{
button_2 =me;
while (6current ==1){my.passable=on;}
while (5current ==1){my.passable=on;}
while (4current ==1){my.passable=on;}
while (3current ==1){my.passable=on;}
while (2current ==1){my.passable=on;}
while (1current ==1){my.passable=on;}



my.ENABLE_IMPACT = on;
my.ENABLE_PUSH = On;
my.event = to_2;
my.ambient = 100;
}




function TD_2_ele()


{
elevator_pnt._speed = 2;
exclusive_global;
while(2current ==1)
{

player.x=-32.000;
player.y= 674.000;
//beep();
wait(1);
IF (player.x > -32.000) {player.x=-32.000;}
IF (player.x < -32.000) {player.x=-32.000;}
IF (player.y > 674.000) {player.y= 674.000;}
IF (player.y < 674.000) {player.y= 674.000;}


elevator_pnt.z= 639.667 ;

elevator_pnt.z = player.z - (player.max_z - player.min_z) / 2; // keep the player onboard

if (elevator_pnt.z >= 639.667) {elevator_pnt.z =639.667;2current =0; // don't pass target
player.z = elevator_pnt.z + (player.max_z - player.min_z) / 2;
button_2.ENABLE_IMPACT = on;
button_2.ENABLE_PUSH = On;
}

}
2current =0;

}

//elevator_pnt.z= 631.667;
/////////////////////////////////////////////////////////////

function to_1()

{
if(event_type == event_impact && you == player)
{
exclusive_global;


button_1.ENABLE_IMPACT = Off; //disables player impact
button_1.ENABLE_PUSH = Off;

my.ambient = 0;
1current =1;

TD_1_ele();

}

}



ACTION button1

{
button_1 =me;
while (6current ==1){my.passable=on;}
while (5current ==1){my.passable=on;}
while (4current ==1){my.passable=on;}
while (3current ==1){my.passable=on;}
while (2current ==1){my.passable=on;}
while (1current ==1){my.passable=on;}


MY.ENABLE_IMPACT = on;
MY.ENABLE_PUSH = On;
my.event = to_1;
my.ambient = 100;
}




function TD_1_ele()


{

elevator_pnt._speed = 2;
exclusive_global;
while(1current ==1)
{
player.x=-32.000;
player.y= 674.000;

//beep();
wait(1);
IF (player.x > -32.000) {player.x=-32.000;}
IF (player.x < -32.000) {player.x=-32.000;}
IF (player.y > 674.000) {player.y= 674.000;}
IF (player.y < 674.000) {player.y= 674.000;}


elevator_pnt.z= -204.333;


elevator_pnt.z = player.z - (player.max_z - player.min_z) / 2; // keep the player onboard up
player.z = elevator_pnt.z + (player.max_z - player.min_z) / 2;



if (elevator_pnt.z >= -204.333) {elevator_pnt.z =-204.333;1current =0;
player.z = elevator_pnt.z + (player.max_z - player.min_z) / 2;
button_1.ENABLE_IMPACT = on;
button_1.ENABLE_PUSH = On;
}
}
}
//elevator_pnt.z= -212.333;



////////////////////////
///////////////////////////////////////////////////////////////






Action TD_elevator

{
elevator_pnt =me;

//elevator_pnt.z = MY.Z + (0.9*(MY.MAX_Z - MY.MIN_Z));



}

////////////////////////////////








Hopefully it will help somebody out.

Now you will have to figure your own positions/stops.
( change this value: elevator_pnt.z=2326.667 ;
Look for TD_1_ele()- TD_6_ele()
change the corresponding value to the floor your
working on.

any questions or comments feel free.



*** Teutonic Darkness ***

Re: Multi-Stage-Elevator [Re: TeutonicDarkness] #63909
02/15/06 14:02
02/15/06 14:02

A
Anonymous
Unregistered
Anonymous
Unregistered
A



Hi!

Would you please describe the idea behind this code.
It's difficult to read and analyse the code without an idea what's the basic concept behind.
Some docu-lines within the code would help also.
:-)
You don't use time to handle the speed?

mercuryus

Re: Multi-Stage-Elevator [Re: ] #63910
02/15/06 17:17
02/15/06 17:17
Joined: Oct 2004
Posts: 75
Netherlands..
Anubis Offline
Junior Member
Anubis  Offline
Junior Member

Joined: Oct 2004
Posts: 75
Netherlands..
the idea is...

a snippet .. to make an elevator that is able to stop at certain positions
floor 1 2 3 4 5 blabla...

(edit: what it should have been :P)

Last edited by Anubis; 02/15/06 17:18.
Re: Multi-Stage-Elevator [Re: Anubis] #63911
02/15/06 18:32
02/15/06 18:32
Joined: Dec 2000
Posts: 4,608
mk_1 Offline

Expert
mk_1  Offline

Expert

Joined: Dec 2000
Posts: 4,608
You should use arrays. It would shorten your script a lot.


Follow me on twitter
Re: Multi-Stage-Elevator [Re: mk_1] #63912
02/15/06 21:11
02/15/06 21:11

A
Anonymous
Unregistered
Anonymous
Unregistered
A



Yaeh - arrays and variables for the stop-points!
That would make the script reusable!
(and more command-lines, that would make it more readable ;-))

mercuryus

Re: Multi-Stage-Elevator [Re: ] #63913
02/15/06 21:56
02/15/06 21:56
Joined: Mar 2005
Posts: 725
USA
TeutonicDarkness Offline OP
User
TeutonicDarkness  Offline OP
User

Joined: Mar 2005
Posts: 725
USA
Quote:

Hi!

Would you please describe the idea behind this code.
It's difficult to read and analyse the code without an idea what's the basic concept behind.
Some docu-lines within the code would help also.
:-)
You don't use time to handle the speed?

mercuryus




The idea? Not sure presisely what you mean?
I does as stated the buttons move the elevator
to the cooresonding stage position.
However...

I will document it better!



I did try using *time several different ways and all were
totally unsucessful!
The Elevator wouldn't move at all or it occured
instantly going Up or Down .

I admit I'm not the greatest scripter...
Probally something I overlooked .


*** Teutonic Darkness ***



[edit] I just went back and documented all of the
stage 6 Action/functions....
The others will be all the same principal
so I won't document them [/edit]


Last edited by TeutonicDarkness; 02/15/06 22:17.
Re: Multi-Stage-Elevator [Re: ] #63914
02/15/06 22:00
02/15/06 22:00
Joined: Mar 2005
Posts: 725
USA
TeutonicDarkness Offline OP
User
TeutonicDarkness  Offline OP
User

Joined: Mar 2005
Posts: 725
USA
Quote:

Yaeh - arrays and variables for the stop-points!
That would make the script reusable!
(and more command-lines, that would make it more readable ;-))

mercuryus




@ MK_1
@ mercuryus


I'm sure your both probally correct...
However I just did what I know...
and how I know.

Its not perfect by any means ....
just thought It might at least give somebody
a starting point


*** Teutonic Darkness ***

Re: Multi-Stage-Elevator [Re: TeutonicDarkness] #63915
02/16/06 06:41
02/16/06 06:41

A
Anonymous
Unregistered
Anonymous
Unregistered
A



Hi!

Antwort auf:

I did try using *time several different ways and all were
totally unsucessful!
The Elevator wouldn't move at all or it occured
instantly going Up or Down .




The "problem" with time is, that you multiply you distances with a varying value (depending at the framerate) and you will never get the exact stoppoint (e.g obj.y=1200, but obj.y=1200.04). So you have to stop at the position, the lift is higher/lower your stop-position (depending of the direction).

The most important thing why you have to use time*speed_constant is: on you pc it looks cool - on an other the elevator maybe needs 10 times longer or 30 timer less time.

Re: Multi-Stage-Elevator [Re: ] #63916
02/16/06 10:24
02/16/06 10:24
Joined: Apr 2005
Posts: 3,815
Finland
Inestical Offline
Rabbit Developer
Inestical  Offline
Rabbit Developer

Joined: Apr 2005
Posts: 3,815
Finland
well.. I got idea that would work or then not. make blocks top of the floor, passable if not the floor selected. that works if going up.

at going down, put the block as the floor, passable if going up or not the floor.

much code? nope, readable? yes, fps? low.


"Yesterday was once today's tomorrow."
Re: Multi-Stage-Elevator [Re: TeutonicDarkness] #63917
02/16/06 13:27
02/16/06 13:27

A
Anonymous
Unregistered
Anonymous
Unregistered
A



Look at this:

The concept is to move an entity up/down to the given position (gc_elestop[], ._destination), when activated (._moving=on) with it's speed (._speed).

Code:

// elevator_entity
entity* ent_elevator;

// Stop-positions (z-positions)
var gc_elestop[5] = 0, 200, 400, 600, 800;

// Speedfactor
var gc_ele_speed = 10;

define _moving, flag1;
define _speed, skill1;
define _destination, skill20;
define _direction, skill21;
//uses: _moving, flag1;
//uses: _speed, skill1;
action elevator{
// set the handle
ent_elevator=me;

while(1){
// wait for activating...
while(my._moving==off){wait(1);}

// direction (up or down?)
my._direction=1-2*(my.z>gc_elestop[my._destination]); // go up if not my.z>my._destination (over the dest.point)

// move elevator (in the direction until the stoppoint is reached)
while((my._direction==1 && my.z<gc_elestop[my._destination]) || (my._direction==-1 && my.z>gc_elestop[my._destination])){
my.z+=time*gc_ele_speed*my._direction;
wait(1);
}

// at Stop-position
my.z=gc_elestop[my._destination]; // set the exact point
my._moving=off; // stop moving

wait(1);
}
}

//-------------------------------------------------------------------------------------------------------------------------------
function ele_goto_1{while(ent_elevator._moving==on){wait(1);} ent_elevator._destination=0; ent_elevator._moving=on;} // wait till stop and move on
function ele_goto_2{while(ent_elevator._moving==on){wait(1);} ent_elevator._destination=1; ent_elevator._moving=on;} // wait till stop and move on
function ele_goto_3{while(ent_elevator._moving==on){wait(1);} ent_elevator._destination=2; ent_elevator._moving=on;} // wait till stop and move on
function ele_goto_4{while(ent_elevator._moving==on){wait(1);} ent_elevator._destination=3; ent_elevator._moving=on;} // wait till stop and move on
function ele_goto_5{while(ent_elevator._moving==on){wait(1);} ent_elevator._destination=4; ent_elevator._moving=on;} // wait till stop and move on


// Keys for levels
on_1 = ele_goto_1;
on_2 = ele_goto_2;
on_3 = ele_goto_3;
on_4 = ele_goto_4;
on_5 = ele_goto_5;



Page 1 of 3 1 2 3

Moderated by  adoado, checkbutton, mk_1, Perro 

Gamestudio download | Zorro platform | shop | Data Protection Policy

oP group Germany GmbH | Birkenstr. 25-27 | 63549 Ronneburg / Germany | info (at) opgroup.de

Powered by UBB.threads™ PHP Forum Software 7.7.1