Page 1 of 1

Elevators - Floor call buttons

Posted: Wed Jan 16, 2008 2:13 am
by *GCC*Nigel
On my two floor elevator (trying to keep it simple), I'm trying to add floor call buttons, but everything I've tried is either faulty, or just doesn't work.

** I tried adding 2 additional move threads, and that got me some faulty results and I got "Elevator one - going down" three times...
* My more pathetic attempt was I made the two additional trigger_use 's on the floors and just CTRL+K 'ed them both to the eleone. That didn't work.

Please help, I know there's probably something simple I overlooked...
// SH2 Testing
// ARCHITECTURE:GCC Nigel
// SCRIPTING: Mostly copied from others, but Nigel

main:

// set scoreboard messages
setcvar "g_obj_alliedtext1" ""
setcvar "g_obj_alliedtext2" ""
setcvar "g_obj_alliedtext3" ""
setcvar "g_obj_axistext1" ""
setcvar "g_obj_axistext2" ""
setcvar "g_obj_axistext3" ""

setcvar "g_scoreboardpic" "none" // your score board picture

//////////////////////////////////////////////////////////////////////////////////////////////////////////////
level waittill prespawn
//////////////////////////////////////////////////////////////////////////////////////////////////////////////

$elevator_cab speed 64 //sets the speed to 64 units per second
level.elepos = 1 //starts on floor 1

exec global/SH2.scr

exec global/ambient.scr mohdm4


level.script = "maps/dm/sh2.scr"

//////////////////////////////////////////////////////////////////////////////////////////////////////////////
level waittill spawn
//////////////////////////////////////////////////////////////////////////////////////////////////////////////

thread standby

iprintln_noloc "*GCC*Nigel"

end

standby:
$elevator_cab speed 64

// replace the names with the ones that you used
$eleone bind $elevator_cab

thread move
**thread moveone
**thread movetwo
end

move:
$eleone waittill trigger

if (level.elepos == 1)
{
goto moveup
}
else
{
goto movedown
}
end

**moveone:
** $eleone waittill trigger
**
**if (level.elepos == 1)
** {
** goto moveup
** }
** else
** {
** goto movedown
** }
**end

**movetwo:
** $eleone waittill trigger
**
**if (level.elepos == 1)
** {
** goto moveup
** }
** else
** {
** goto movedown
** }
**end
moveup:

$eleone nottriggerable
$eleoneone nottriggerable
$eleonetwo nottriggerable

iprintlnbold_noloc "Elevator 1 - Going Up"

$elevator_cab loopsound lighthouse_run
$elevator_cab moveto $floor2
$elevator_cab waitmove
$elevator_cab stoploopsound

iprintlnbold_noloc "Elevator 1 - Floor: 2"

level.elepos = 2

$eleone triggerable
$eleoneone triggerable
$eleonetwo triggerable

goto move

end

movedown:

$eleone nottriggerable
$eleoneone nottriggerable
$eleonetwo nottriggerable

iprintlnbold_noloc "Elevator 1 - Going Down"

$elevator_cab loopsound lighthouse_run
$elevator_cab moveto $floor1
$elevator_cab waitmove
$elevator_cab stoploopsound

iprintlnbold_noloc "Elevator 1 - Floor: 1"

level.elepos = 1

$eleone triggerable
$eleoneone triggerable
$eleonetwo triggerable

goto move

end

trigger names

Posted: Wed Jan 16, 2008 9:37 am
by tltrude
I think you have the trigger names confused. First off, its probably not a good idea to use " * " in a name -- the script may see it as a math function. Also, your two floor triggers can target $eleone in the cab.

Key: target
Value: $eleone

They will then become remote triggers. Still need to turn off each floor trigger when the cab is on its floor.

I hope that helps!

Posted: Wed Jan 16, 2008 8:06 pm
by *GCC*Nigel
Sorry, I just threw in asteriks to show where my pathetic attempts at coding were.

I used ctrl+k on both triggers to give them both target = "eleone" and then none of them worked. I have all three triggers as "trigger_use"s. Can "trigger_use"s fire other "trigger_use"s?
I was under the impression that ctrl+K just gave a target to the second selections targetname or gave it a targetname if it didn't have one. I'll try it again with just manual editing.

On a separate idea: Is there a way to get .scr's to open with notepad or something automatically? I figure that actual screensavers would work fine either way (as long as I don't change them). Changing .scr to .txt loses its luster quickly.

On a somewhat similar, nontheless separate idea: Do I need the $elevator_cab speed 64 the first time in the waitill prespawn section or the one in the waitill spawn section? Or neither? Or both...

Just going for the 6 edit mark now: Level.elepos is just a variable name right? or is "level.elepos" something much more technical? If it's a variable, I could change it to "eleonepos" as well as all other references, right?

ele

Posted: Thu Jan 17, 2008 9:50 am
by tltrude
I'm not positive the remote trigger idea will work -- its been a while and I don't have the the editor or the game installed anymore. You could also try...

Key: setthread
Value: move

Setthread runs the thread named in the value when the trigger is used. It would have to be in all three triggers and the line "$eleone waittill trigger" would have to be removed from the "move:" thread. And the "goto move" line would also need to be remove from all threads. Also, "thread move" would no longer be needed in the "standby:" thread.

To get the script to open with notepad, open "my Computer" and go to Tools > Folder Options > File Types. Then scroll down to "scr" and change it to open with Notepad. Doing that will not mess up your screensaver files, although they do use the same extention.

You only need to set the speed one time.

Yes, "Level.elepos" is a variable name and can be any name you wish. But, it must start with "level.", so it can be used in any thread. I always found it useful to not use capital letters in variable names (Level - level).

The line, "exec global/SH2.scr" is not needed in your script, unless you have a script with that name in the global folder. Your map's script will run automatically, if it has the same name as the bsp file and is located in the same folder (dm) as the bsp.

Note: Please re-post your script, with your changes, if you need more help.

Posted: Thu Jan 17, 2008 9:27 pm
by *GCC*Nigel
Everything is working except the sounds, but I remember seeing a tutorial about putting in sounds... I'm eventually going to try to get three separate elevators in a single multiple player map and I'm worried about potential lag. Is my worry well-founded? I also noticed on other maps where sounds are played they can be heard all over the map... Is there a way to localize the sound, maybe with a trigger bound to the elevator so the noise is just inside?

Sounds are working.

Now that I've got the one elevator working perfectly, I've gone and tried to set up a second. Now neither works. I don't know why.

It says somethings wrong with my trigger uses and setthreads...
// SHTech
// ARCHITECTURE:GCC Nigel
// SCRIPTING: Still a fair bit copied, but significantly more Nigel

main:

// set scoreboard messages
setcvar "g_obj_alliedtext1" ""
setcvar "g_obj_alliedtext2" ""
setcvar "g_obj_alliedtext3" ""
setcvar "g_obj_axistext1" ""
setcvar "g_obj_axistext2" ""
setcvar "g_obj_axistext3" ""

setcvar "g_scoreboardpic" "none" // your score board picture

local.master = spawn ScriptMaster

local.master aliascache elesound sound/amb/amb_machineloop_02.wav soundparms 1.0 0.2 1.0 0.2 200 2000 auto loaded maps "obj dm"
local.master aliascache eledoorclose sound/mechanics/m6l3a_slidingdoors_close.wav soundparms 1.0 0.2 1.0 0.2 200 2000 auto loaded maps "obj dm"
local.master aliascache eledooropen sound/mechanics/m6l3a_slidingdoors_open.wav soundparms 1.0 0.2 1.0 0.2 200 2000 auto loaded maps "obj dm"

//////////////////////////////////////////////////////////////////////////////////////////////////////////////
level waittill prespawn
//////////////////////////////////////////////////////////////////////////////////////////////////////////////

level.elepos = 1 //starts on floor 1 (Bottom)
level.elepostwo = 4 //starts on floor 4 (Top)

//Elevator One
$elevator_cab speed 64
$onetopdoor speed 80
$onebottomdoor speed 80
$eleone bind $elevator_cab
$eleonespeaker bind $elevator_cab

//Elevator Two
$elevator_cab2 speed 64
$twotopdoor speed 80
$twobottomdoor speed 80
$eletwo bind $elevator_cab2
$eletwospeaker bind $elevator_cab2

exec global/SH2.scr

exec global/ambient.scr mohdm4


level.script = "maps/dm/shtech.scr"

//////////////////////////////////////////////////////////////////////////////////////////////////////////////
level waittill spawn
//////////////////////////////////////////////////////////////////////////////////////////////////////////////

end

move:

if (level.elepos == 1)
{
goto moveup
}
else
{
goto movedown
}
end

movetwo:

if (level.elepostwo == 3)
{
goto moveuptwo
}
else
{
goto movedowntwo
}
end

moveup:

$eleone nottriggerable
$eleoneone nottriggerable
$eleonetwo nottriggerable

$eleonedoorbottomspeaker loopsound eledoorclose
$onebottomdoor moveto $onebottomclosed
$onebottomdoor waitmove
$eleonedoorbottomspeaker stoploopsound

$eleonespeaker loopsound elesound
$elevator_cab moveto $floor2
$elevator_cab waitmove
$eleonespeaker stoploopsound

$eleonedoortopspeaker loopsound eledooropen
$onetopdoor moveto $onetopopen
$onetopdoor waitmove
$eleonedoortopspeaker stoploopsound

level.elepos = 2

$eleone triggerable
$eleoneone triggerable
$eleonetwo triggerable

end

moveuptwo:

$eletwo nottriggerable
$eletwoone nottriggerable
$eletwotwo nottriggerable

$eletwodoortopspeaker loopsound eledoorclose
$twobottomdoor moveto $twobottomclosed
$twobottomdoor waitmove
$eletwodoortopspeaker stoploopsound

$eletwospeaker loopsound elesound
$elevator_cab2 movetwo $floor3
$elevator_cab2 waitmove
$eletwospeaker stoploopsound

$eletwodoorbottomspeaker loopsound eledooropen
$twobottomdoor moveto $twobottomopen
$twobottomdoor waitmove
$eletwodoorbottomspeaker stoploopsound

level.elepostwo = 3

$eletwo triggerable
$eletwoone triggerable
$eletwotwo triggerable

end

movedown:

$eleone nottriggerable
$eleoneone nottriggerable
$eleonetwo nottriggerable

$eleonedoortopspeaker loopsound eledoorclose
$onetopdoor moveto $onetopclosed
$onetopdoor waitmove
$eleonedoortopspeaker stoploopsound

$eleonespeaker loopsound elesound
$elevator_cab moveto $floor1
$elevator_cab waitmove
$eleonespeaker stoploopsound

$eleonedoorbottomspeaker loopsound eledooropen
$onebottomdoor moveto $onebottomopen
$onebottomdoor waitmove
$eleonedoorbottomspeaker stoploopsound

level.elepos = 1

$eleone triggerable
$eleoneone triggerable
$eleonetwo triggerable

end

movedowntwo:

eletwo nottriggerable
$eletwoone nottriggerable
$eletwotwo nottriggerable

$eletwodoorbottomspeaker loopsound eledoorclose
$twobottomdoor moveto $twobottomclose
$twobottomdoor waitmove
$eletwodoorbottomspeaker stoploopsound

$eletwospeaker loopsound elesound
$elevator_cab2 movetwo $floor4
$elevator_cab2 waitmove
$eletwospeaker stoploopsound

$eletwodoortopspeaker loopsound eledooropen
$twobottomdoor moveto $twobottomopen
$twobottomdoor waitmove
$eletwodoortopspeaker stoploopsound

level.elepostwo = 4

$eletwo triggerable
$eletwoone triggerable
$eletwotwo triggerable

end

Setthread

Posted: Fri Jan 18, 2008 2:52 pm
by tltrude
Recheck your trigger targetnames and setthred values. It would be easier to use numbers in the names, I think. Also, if you seperate the threads for each elevator in the script, it would be easier to work on them. I don't see any thing bad in the script, other than being hard to read, so it must be the triggers.

For the sound range, these numbers (in red) are how it is set.

local.master aliascache elesound sound/amb/amb_machineloop_02.wav soundparms 1.0 0.2 1.0 0.2 200 2000 auto loaded maps "obj dm"

The first distance number (in units) is how far a player will hear the sound at full volume. Then the sound will fade as the player walks away until he reaches the second distance number where it cuts out completly.

Posted: Sat Jan 19, 2008 9:38 pm
by *GCC*Nigel
No dice.

I tried switching setthread to move2 and made changes to the script accordingly and got no result. I checked all my trigger_use setthreads and they all seem fine, but again have the setthread move2 where the value isn't put into the value position for some reason, but it worked fine before.

In the console in MoH I see the 6 trigger_use with setthread errors.

I keep compiling my map with a leak so it goes faster, could that be a problem?

debug

Posted: Sun Jan 20, 2008 9:11 pm
by tltrude
Make a copy of your script as a backup, then remove all the stuff for the second elevator and try to get the first one working again.

You can make a log file for the console by typing logfile 1 in it just before you startup the map. Afterwards, you'll find qconsole.log in main. It can be opened with Notpad, and you can copy and paste the error warnings here.

Posted: Tue Jan 22, 2008 4:20 am
by *GCC*Nigel
I'm in the midst of finals right now, so replies might be staggered, if any...

I greatly appreciate your help and patience!

Posted: Fri Jan 25, 2008 1:58 pm
by *GCC*Nigel
I took all the elevator 2 lines from the script and took all the triggers out and began to re add them. I think when I copied the entire elevator system, the trigger_use may have still been linked somehow.

I did the logfile after I fixed the solo elevator, but it is just full of static model errors, nothing in it is script based.

Posted: Fri Jan 25, 2008 8:42 pm
by erick
*GCC*Nigel wrote:I'm in the midst of finals right now, so replies might be staggered, if any...
I just had midterms. Aced all of them. 8-)

No static won't do anything. Why not have $trigger waittill trigger instead of a setthread?

Posted: Sun Jan 27, 2008 4:31 am
by *GCC*Nigel
No static won't do anything. Why not have $trigger waittill trigger instead of a setthread?
Did not get any of that. :oops:

Posted: Mon Jan 28, 2008 12:34 am
by erick
Instead of giving the trigger a setthread just give it a targetname.

Code: Select all

main:

level waittill spawn
thread elevator1
end

elevator1:

while(1)
{
$mytrigger waittill trigger

//Do stuff here

}
end
The while(1) is so the thing loops and can be used multiple times. Its much cleaner than the "goto" command. Just have your "if(level.elepos == 1)"

Posted: Mon Mar 31, 2008 2:34 pm
by SilentAngel
hi all :lol:
I've spowned an object by scripting and I want make it an elevator.
I mean I want it go up and down automatically(without a call button) is it possible? can someone tell me how to do that or give me a link for a tutorial? I love scripting but it's hard learn!!!
thanx

Posted: Mon Mar 31, 2008 7:05 pm
by ViPER
Silent - search for

"move object" or "moving objects" or "moveup" or "moveto"

there are a couple ways to do what you want - if you need help start a new thread.