rotating a brush

Post your scripting questions / solutions here

Moderator: Moderators

M&M
General
Posts: 1427
Joined: Sun Sep 14, 2003 1:03 am
Location: egypt
Contact:

rotating a brush

Post by M&M »

well,here is my problem:
i want 2 rotate a bar with an on/off switch around its y-axis ,upwards direction with an angle 60 then down again

general idea:this bar should be something like those metal bars that block the passage of ur car when u want 2 park it in a parking lot ,so u have 2 pay the fee of parking then some1 rotates it upwards that bar so ur car can pass ,then he rotates is back down.

so lets treat this as a mathimatical equation :wink:

GIVEN:bars targetname=rotatingbar
switch targetname=switch
rotation angle=60
rotation direction=upwards when switch is on and downwards when switch is off(switch default is off)
speed =enough so it looks normal :wink:

R.T.F:
The script that satisfies the idea above

solution:

...........thats where u can help me........


i tried reading all the scripting tutorials here but i still cant decrypt mohaas language into something i can understand,i know the commands im looking 4 is rotateYupto and rotateydownto but i cant combine those with the ones of a switch ,id be really grateful 4 any help i can get :)
Image
User avatar
bdbodger
Moderator
Posts: 2596
Joined: Tue Feb 25, 2003 7:34 am
Location: canada
Contact:

Post by bdbodger »

To start with it depends on the way that the bar is faceing . When you make a script_object it's angles are ( 0 0 0 ) 0 is on the right side of the editor . so if your bar looks like this | then make sure you have a brush at the rotation point that is part of the bar and has the origin texture on it .
then you can rotate on the z axis . The z axis is side rotation if you are faceing 0 and looking at the bar and the origin brush is on your left then positive z is counterclock wise starting point is 0 so . $bar rotatezupto 60 will rotate it up to 60 degrees . $bar rotatezdownto 0 brings it down again . If your bar look like this --- then if the rotation point is towards 180 like this o---- then you rotate on the x axis . In this case x is forward and down so to rotate it up you can rotatexdownto -60 and rotatexupto 0

Just remember angles ( 0 0 0 ) -> pitch yaw roll
User avatar
tltrude
Chuck Norris
Posts: 4774
Joined: Sun Jul 07, 2002 4:03 am
Location: Oklahoma, USA
Contact:

origin

Post by tltrude »

Yep, you are going to need a small common/origin textured brush at the end of the bar (at the hinge point). Make both the bar and the origin brush a single script_object. Then try to script it and post your script, or thread, here.
Tom Trude,

Image
M&M
General
Posts: 1427
Joined: Sun Sep 14, 2003 1:03 am
Location: egypt
Contact:

Post by M&M »

hmmm...,i think i understand but u still havent solved the problem ,im trying 2 combine this motion with the switchs on/off .1st of all the brush i want 2 rotate looks like this from the top view (xy)

Code: Select all

------O
where the o is the fixed point that shouldnt be moving ,so according 2 what u said i should use $rotatingbar rotatezupto 60 .if the previous is correct how do i combine these with an on off switch

edit:tltrude,u posted just seconds b4 i clicked the submit button,anyways i made both of the brush and the origin brush and have the switch somewhere else,im a total scripting newbie.im trying 2 put my 1st script 2gether here so i cant exactly tell u what i have because i dont have anything,i just know the command i dont know how 2 use it.hopefully if i c how its done ill learn how it should be done
Image
User avatar
tltrude
Chuck Norris
Posts: 4774
Joined: Sun Jul 07, 2002 4:03 am
Location: Oklahoma, USA
Contact:

switch

Post by tltrude »

Is it an animated model switch? The correct word to make it move depends on the type of switch it is. If you look at its entity proporties (key N), the "Anim:" +/- buttons will tell you the command words to use.

$switch anim on
$switch anim off
Tom Trude,

Image
M&M
General
Posts: 1427
Joined: Sun Sep 14, 2003 1:03 am
Location: egypt
Contact:

Post by M&M »

well,i cant say anything more than im just confused :? :? :? :?: .ill try 2 fiddle about in mohradient with them 4 a while,but what im strying 2 do is rotate the bar with the switch is on and rotate it back when switch is off
the switch model name is static item switch 1from what ur saying i think i have the wrong model :oops:
Image
User avatar
tltrude
Chuck Norris
Posts: 4774
Joined: Sun Jul 07, 2002 4:03 am
Location: Oklahoma, USA
Contact:

try this

Post by tltrude »

Try animate > equipment > electric-switch-nopulse.

If you use that one, the script lines for it will be:

$switch anim on
$switch playsound alarm_switch

$switch anim off
$switch playsound alarm_switch

You will also need a small trigger_use brush around the switch--with a targetname ("rotatingbar_trigger" would work for the name).
Tom Trude,

Image
M&M
General
Posts: 1427
Joined: Sun Sep 14, 2003 1:03 am
Location: egypt
Contact:

Post by M&M »

i think i understand now how 2 turn the switch on/off but i have a few question,
*whats the difference between the no pule switch and the pulse one
*what does the script button in the entity window do,can i enter the script there or do i have 2 put it in the .scr file
*after placing the trigger_use with targetname rotatingbar_trigger,what do i do?
Image
User avatar
tltrude
Chuck Norris
Posts: 4774
Joined: Sun Jul 07, 2002 4:03 am
Location: Oklahoma, USA
Contact:

Script

Post by tltrude »

1. Whats the difference between the no pulse switch and the pulse one.
One pulses red in the game and the other doesn't. The pulses helps the player to see where it is, but it is normally only used in a singleplayer map.

2. What does the script button in the entity window do, can I enter the script there or do i have 2 put it in the .scr file.
Don't use that button--you'll have to make a thread for it in your map's main script file.

3. After placing the trigger_use with targetname rotatingbar_trigger, what do i do?
Do you have a script for your map? If you have the switch model, script_object bar, and trigger in place (all with targetnames), you can compile the map.

------------------------

First thing to do in your script is to start the rotating bar thread under "level waittill prespawn".

level waittill prespawn

thread rotatingbar_mover


Now go to the bottom of your script and add the thread.

rotatingbar_mover:

$rotatingbar_trigger waittill trigger //<-- waits for someone to hit the use key.
$switch anim on
$switch playsound alarm_switch
// Rotatate the bar up line goes here.
$rotatingbar waitmove

$rotatingbar_trigger waittill trigger //<-- waits for someone to hit the use key again.
$switch anim off
$switch playsound alarm_switch
// Rotatate the bar down line goes here.
$rotatingbar waitmove
goto rotatingbar_mover

end



I hope that helps!
Tom Trude,

Image
omniscient
Major General
Posts: 694
Joined: Tue Sep 16, 2003 12:02 am

Post by omniscient »

silly question, i think

why not make it a rotating door that opens up and closes witha trigger?
Image
User avatar
tltrude
Chuck Norris
Posts: 4774
Joined: Sun Jul 07, 2002 4:03 am
Location: Oklahoma, USA
Contact:

up

Post by tltrude »

He wants it to rotate upwards, and you can't do that with a door!
Tom Trude,

Image
omniscient
Major General
Posts: 694
Joined: Tue Sep 16, 2003 12:02 am

Post by omniscient »

uh, oops.
Image
M&M
General
Posts: 1427
Joined: Sun Sep 14, 2003 1:03 am
Location: egypt
Contact:

Post by M&M »

very neat,thankx alot 4 ur help.ill test that now and see what comes up and tell u the results
Image
User avatar
tltrude
Chuck Norris
Posts: 4774
Joined: Sun Jul 07, 2002 4:03 am
Location: Oklahoma, USA
Contact:

sounds

Post by tltrude »

We can also add a sound to the bar while it moves, if you like.

To control the speed of the bar, you need a line like this.

$rotatingbar time 3 // three seconds travel time

You can put that just above the thread starting line in prespawn.
Tom Trude,

Image
M&M
General
Posts: 1427
Joined: Sun Sep 14, 2003 1:03 am
Location: egypt
Contact:

Post by M&M »

that will come in handy later,1st i still have 2 get it 2 work.i tried the scrupt and it didnt work,the console gives an error like this

Code: Select all

0 teams with 0 entities
bad token:
TOKEN_SWITCH:
switch

$switch anim on  (maps/dm/test.scr, 39)
$^

^~^~^ Script file compile error:  Couldn't parse 'maps/dm/test.scr'
ScriptMaster::GetScript: Script 'maps/dm/test.scr' was not properly loaded

3 entities spawned
4 simple entities spawned
0 entities inhibited
the map name is test,and i sure i target named the switch model ,switch(cause that error came up b4 i targetnamed it and now after it).
when i removed the lines $switch anim on and $switch playsound alarm_switch ,the script worked but it only works in the up direction,doesnt work in the down dircetion
the lines i used were

Code: Select all

$rotatingbar rotatexup 60 
(upwards)

Code: Select all

$rotatingbar rotatexdown 60
(downwards) which doesnt seem 2 work,i think due 2 the line

Code: Select all

$rotatingbar waitmove
not sure but i havent tried 2 remove it.since this was my 1st script i kept getting problems everywhere until i solved most of them but now i have 2 sslleeeeeepppp,im still awake from yesterday u c and my brain power is diminishing gradually.i hope u can tell me whats wrong so i can work on it 2morow
oh one more thing,if i want 2 make this bar go up with the on switch and give it a small amount of time say 11 secs b4 it goes down again (5 sec + 3x2 for rotation up and down)and also make the switch go of automatically how should that be done?
Image
Post Reply