UGX-Mods

Call of Duty 5: World at War => Help Desk => Scripting => Topic started by: NaviLlicious on May 28, 2014, 01:49:26 am

Title: Elevator Problem
Post by: NaviLlicious on May 28, 2014, 01:49:26 am
Hey guys I am trying to get an elevator to work like Die Rise but It seems like the script Is skipping the part where It tells the elevator to go up so It just keeps going down, I kept trying to play with It but can't seem to get It to go both up and down this Is the script
Code Snippet
Plaintext
#include common_scripts\utility; 
#include maps\_utility;
#include maps\_zombiemode_utility;

init()
{
level.elevator = getentarray("dierisevator", "targetname");
level. speed = 10;
level.down = -200;
level.up = 200;
thread elevator_think();
}

elevator_think()
{
thread go_down();
wait 10;
thread go_up();
wait 10;
thread elevator_think();
}

go_down()
{
for( i = 0; i < level.elevator.size; i++ )
{
flag_wait( "electricity_on" );
level.elevator[i] movez (level.down, level.speed);
         }
}

go_up()
{
for( i = 0; i < level.elevator.size; i++ )
{
flag_wait( "electricity_on" );
level.elevator movez (level.up, level.speed);
         }
}
Title: Re: Elevator Problem
Post by: PROxFTW on May 28, 2014, 01:56:56 am
This should fix it. Another thing if this doesn't work remove the flag_wait from go_down and go_up and add it to elevator_think instead. I could go further if this doesn't work either.
Code Snippet
Plaintext
#include common_scripts\utility; 
#include maps\_utility;
#include maps\_zombiemode_utility;

init()
{
level.elevator = getentarray("dierisevator", "targetname");
level. speed = 10;
level.down = -200;
level.up = 200;
for( i = 0; i < level.elevator.size; i++ )
level.elevator[i] thread elevator_think();
}

elevator_think()
{
self thread go_down();
wait 10;
self thread go_up();
wait 10;
self thread elevator_think();
}

go_down()
{
flag_wait( "electricity_on" );
                self movez (level.down, level.speed);
}

go_up()
{
flag_wait( "electricity_on" );
               self movez (level.up, level.speed);
}
Title: Re: Elevator Problem
Post by: daedra descent on May 28, 2014, 02:04:26 am
This should fix it. Another thing if this doesn't work remove the flag_wait from go_down and go_up and add it to elevator_think instead. I could go further if this doesn't work either.
Code Snippet
Plaintext
#include common_scripts\utility; 
#include maps\_utility;
#include maps\_zombiemode_utility;

init()
{
level.elevator = getentarray("dierisevator", "targetname");
level. speed = 10;
level.down = -200;
level.up = 200;
for( i = 0; i < level.elevator.size; i++ )
level.elevator[i] thread elevator_think();
}

elevator_think()
{
self thread go_down();
wait 10;
self thread go_up();
wait 10;
self thread elevator_think();
}

go_down()
{
flag_wait( "electricity_on" );
                self movez (level.down, level.speed);
}

go_up()
{
flag_wait( "electricity_on" );
               self movez (level.up, level.speed);
}

Might want to put a loop around elevator_think(); Otherwise the code will go once and then stop.
Title: Re: Elevator Problem
Post by: PROxFTW on May 28, 2014, 02:06:01 am
Might want to put a loop around elevator_think();
In a for or if/else statement if there is only one line of code no brackets are needed.
Title: Re: Elevator Problem
Post by: NaviLlicious on May 28, 2014, 02:06:41 am
This should fix it. Another thing if this doesn't work remove the flag_wait from go_down and go_up and add it to elevator_think instead. I could go further if this doesn't work either.
Code Snippet
Plaintext
#include common_scripts\utility; 
#include maps\_utility;
#include maps\_zombiemode_utility;

init()
{
level.elevator = getentarray("dierisevator", "targetname");
level. speed = 10;
level.down = -200;
level.up = 200;
for( i = 0; i < level.elevator.size; i++ )
level.elevator[i] thread elevator_think();
}

elevator_think()
{
self thread go_down();
wait 10;
self thread go_up();
wait 10;
self thread elevator_think();
}

go_down()
{
flag_wait( "electricity_on" );
                self movez (level.down, level.speed);
}

go_up()
{
flag_wait( "electricity_on" );
               self movez (level.up, level.speed);
}
That got It working but It doesn't wait the 10 seconds It just goes up and down continuously
Title: Re: Elevator Problem
Post by: daedra descent on May 28, 2014, 02:09:16 am
In a for or if/else statement if there is only one line of code no brackets are needed.

No i meant so it would repeat but i see you just called the function on itself after it does its thing. My bad.  :P
Title: Re: Elevator Problem
Post by: PROxFTW on May 28, 2014, 02:11:17 am
I've seen wait(  ); like this before but don't know why. I would recommend trying that also add the 10 in the (). This could just still be useless but still worth a try.
No i meant so it would repeat but i see you just called the function on itself after it does its thing. My bad.  :P
Oh, thought you were talking about the for loop.
Title: Re: Elevator Problem
Post by: NaviLlicious on May 28, 2014, 02:19:01 am
When It goes down It waits 3 seconds instead of 10 then when It hits the top It goes back down without waiting at all now
Title: Re: Elevator Problem
Post by: PROxFTW on May 28, 2014, 02:22:13 am
Here another idea I have is take out the wait 10; and in replace put for( i = 0; i < 10; i++ ) wait 1;
This could still fail but still an attempt.
Title: Re: Elevator Problem
Post by: NaviLlicious on May 28, 2014, 02:25:37 am
Like this?
Code Snippet
Plaintext
elevator_think()
{
self thread go_down();
for( i = 0; i < 10; i++ ) wait 1;
self thread go_up();
for( i = 0; i < 10; i++ ) wait 1;
self thread elevator_think();
}
trying It now
Title: Re: Elevator Problem
Post by: PROxFTW on May 28, 2014, 02:27:33 am
Yep. My last idea if that fails will be using waittill if that doesn't work. If this doesn't work someone else will have to help you as I have to go now.
Waittill Version:
Code Snippet
Plaintext
#include common_scripts\utility; 
#include maps\_utility;
#include maps\_zombiemode_utility;

init()
{
level.elevator = getentarray("dierisevator", "targetname");
level. speed = 10;
level.down = -200;
level.up = 200;
for( i = 0; i < level.elevator.size; i++ )
level.elevator[i] thread elevator_think();
}

elevator_think()
{
self thread go_down();
self waittill( "Down" );
self thread go_up();
self waittill( "Up" );
self thread elevator_think();
}

go_down()
{
flag_wait( "electricity_on" );
        self movez (level.down, level.speed);
        wait 10;
        self notify( "Down" );
}

go_up()
{
flag_wait( "electricity_on" );
        self movez (level.up, level.speed);
        wait 10;
        self notify( "Up" );
}
Title: Re: Elevator Problem
Post by: NaviLlicious on May 28, 2014, 02:32:08 am
It actually threw the elevator In reverse and instead of going down first It went up lol but It still wasn't waiting when It hit the point

Post Merge: May 28, 2014, 02:42:15 am
Still no luck :/ I will keep toying with It but I really appreciate the help
Title: Re: Elevator Problem
Post by: ProGamerzFTW on May 28, 2014, 05:09:44 am
When It goes down It waits 3 seconds instead of 10 then when It hits the top It goes back down without waiting at all now

Well of course it isn't going to wait when it hits the top because your level.speed is the exact same as the wait timer, if you increase the wait timer it should wait. haha

or make the wait timer something like

Code Snippet
Plaintext
wait(level.speed + 10);
Title: Re: Elevator Problem
Post by: NaviLlicious on May 28, 2014, 09:47:56 am
Well of course it isn't going to wait when it hits the top because your level.speed is the exact same as the wait timer, if you increase the wait timer it should wait. haha

or make the wait timer something like

Code Snippet
Plaintext
wait(level.speed + 10);
Ah that may be why xD
Title: Re: Elevator Problem
Post by: ProGamerzFTW on May 31, 2014, 08:11:14 am
Ah that may be why xD

So did this solve your problem? :P
Title: Re: Elevator Problem
Post by: NaviLlicious on May 31, 2014, 04:10:34 pm
Yeah I think It did lol forgot to mark the post as solved