scripting newbie

Post your scripting questions / solutions here

Moderator: Moderators

Post Reply
SlasherZ
Colonel
Posts: 433
Joined: Fri Jul 11, 2003 12:55 pm
Contact:

scripting newbie

Post by SlasherZ »

ok, please keep in mind i know no scripting. i know one command, movenorth (orwhat everdicetion) # please tell me how to make this work
this is my script:

moveup 128
waitmove
movedown 128
how do i make this activated by a swich (like in liberation)
Bjarne BZR
Site Admin
Posts: 3298
Joined: Wed Feb 05, 2003 2:04 pm
Location: Sweden
Contact:

Re: scripting newbie

Post by Bjarne BZR »

SlasherZ wrote:ok, please keep in mind i know no scripting. i know one command, movenorth (orwhat everdicetion) # please tell me how to make this work
this is my script:

moveup 128
waitmove
movedown 128
how do i make this activated by a swich (like in liberation)
Make a trigger_use around your switch graphics, give it key/value setthread/up_n_down
Put this in your script...

Code: Select all

up_n_down:
   moveup 128
   waitmove
   movedown 128
end
Admin .MAP Forums
Image
Head above heels.
SlasherZ
Colonel
Posts: 433
Joined: Fri Jul 11, 2003 12:55 pm
Contact:

Post by SlasherZ »

thanks, but it doesn't work right, here is my problem... when map loads door goes up and the doesn't come down.... trigger doesn't work
here is script:
// Door Test
// ARCHITECTURE: SlasherZ
// SCRIPTING: SlasherZ

main:

// set scoreboard messages
setcvar "g_obj_alliedtext1" "Door Test"
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

exec global/DMprecache.scr

exec global/ambient.scr yourmapname
// may want to make your own ambient sounds, read the tut

level.script = "maps/dm/door.scr"
// remember to put in your map name

level waittill spawn

up_n_down:
$door moveup 134
$door waitmove 7
$door movedown 134
end

end
Bjarne BZR
Site Admin
Posts: 3298
Joined: Wed Feb 05, 2003 2:04 pm
Location: Sweden
Contact:

Post by Bjarne BZR »

Try

Code: Select all

up_n_down:
if ($door.moving != 1)
{
    $door.moving = 1
    $door moveup 134
    $door waitmove
    $door movedown 134
    $door waitmove
    $door.moving = 0
}
end
The if stuff is to prevent multiple triggerings of the door.
( The error for you was that you had no move command after the movedown command )
Admin .MAP Forums
Image
Head above heels.
SlasherZ
Colonel
Posts: 433
Joined: Fri Jul 11, 2003 12:55 pm
Contact:

Post by SlasherZ »

ok thanks! this has helped me understand scripting a little more! :D
Bjarne BZR
Site Admin
Posts: 3298
Joined: Wed Feb 05, 2003 2:04 pm
Location: Sweden
Contact:

Post by Bjarne BZR »

Glad to help.
Admin .MAP Forums
Image
Head above heels.
nuggets
General
Posts: 1006
Joined: Fri Feb 28, 2003 2:57 am
Location: U-england-K (england in the UK) :P
Contact:

Post by nuggets »

that will prevent multiple triggerings but it's un-needed with the script you have,

$door moveUp 134
$door speed 3 //will take 3 seconds to move to destination
$door waitmove //executes all directions, angles and speeds set for entity

/*therefore you'll need a $door waitmove or $door move after the
downward settings*/
$door moveDown 134
$door waitmove
hope this helps, prob not cos it's all foreign 2 me :-/
User avatar
tltrude
Chuck Norris
Posts: 4774
Joined: Sun Jul 07, 2002 4:03 am
Location: Oklahoma, USA
Contact:

triggering your thread

Post by tltrude »

The way you have the script, the door will open as soon as the player spawns. Your door thread should be after the "end" line.

---------------------------------------------
level waittill spawn

end

up_n_down:

$door moveup 134 //sets the direction and distance
$door waitmove //tells it to move and stops the script until it is done
wait 7 //wait for 7 seconds
$door movedown 134 //sets the direction and distance
$door move //tells it to move

end
---------------------------------------------

But, something has to tell this thread to run when the door is triggered. There are two ways you can do that. The first is to put the following key/value in the trigger_use:

Key: setthread
Value: up_n_down

That make the trigger run the thread when a player uses it.

The second way is to put the trigger's targetname into the script and start the thread in prespawn like this:

---------------------------------------------
level waittill prespawn

thread up_n_down // starts the thread

level waittill spawn

end

up_n_down:

$door_trigger waittill trigger //script waits here for the trigger event.
$door moveup 134
$door waitmove
wait 7
$door movedown 134
$door move

end
---------------------------------------------

This is a good practice door, but the same thing can be done by just making it a func_door with a targetname and "targeted" set. Then just target the door with the trigger_use.

Key: target
Value: door

A red line will connect the trigger and the door.
Tom Trude,

Image
Post Reply