Page 1 of 1
Making a switch animate...?
Posted: Sat Jun 07, 2003 3:05 am
by FoShizzle
Hey, I was fooling around with using a func_door to function as a switch for a door in my map, and having it slide into the wall. I ran into some problems with it which are rather irritating, so I'm wondering if I should use the models for switches that came with the game. If I do, how do I animate it? I've never done anything with scripting at all before, I've never really had a need to. So if someone could just give me a quick walkthrough of what I will have to do to make a script / get it to run in my map, I would be forever in your debt! Thanks

Posted: Sat Jun 07, 2003 9:02 am
by bdbodger
Put an "models/animate/electical_switch.tik" or "models/animate/electical_pulse_switch.tik" into your map . Give it a $targetname and then in your script put a thread into your script like this
main:
$myswitch thread elevatorswitches_anim
end
elevatorswitches_anim:
self anim turn
self anim waittill animdone
self anim on
self anim waittill animdone
wait .5
self anim off
end
Posted: Sat Jun 07, 2003 7:02 pm
by FoShizzle
Right... well, like I said, I've never done anything
at all that involves scripting, so I don't really know what you mean. I can't find any good tutorials on it, so I need to know a brief walkthrough of how to script before I know the script I need to get it to run.

Posted: Sat Jun 07, 2003 7:43 pm
by Zip
How about this....
http://www.planetmedalofhonor.com/rjuka ... l#language
....should get you started on scripting. I'll have to learn at some point myself too

.
Posted: Sat Jun 07, 2003 8:20 pm
by FoShizzle
Thanks, Zip. I'll browse through that and see if I can pick up anything

Posted: Sun Jun 08, 2003 11:19 am
by bdbodger
It is not as hard as it looks . This is rather simple and a good way to start .
first right click on the 2dwindow to open the menu choose animate then eqipment then electric-switch-pulse . second press n to open the entity window set a
key: $targetname
value: myswitch
close the entity window by pressing n again then press esc to deselect the switch
now make a box around the switch 32x32 is ok then right click on the 2d window again this time choose trigger then use . Press n again to open the entity window and set the key /value as follows
key: setthread
value: switchthread (this is the name of you thread in the script)
now open notepad and put this text in it or copy and paste it in
main:
end
switchthread:
$myswitch anim turn
$myswitch anim waittill animdone
$myswitch anim on
$myswitch anim waittill animdone
wait .5
$myswitch anim off
end
save that with a name the same as your map example mymap.txt
then change its name in windows to mymap.scr and put it in the mohaa/maps/ folder or if it is a dm game mohaa/maps/dm folder
compile your map put it in the same folder and run it maybe make a test map and try it out first not too hard was it ? The key setthread tells the game what thread to run when the trigger is used . The trigger_use runs the thread and the thread turns the switch that you gave a $targetname to .
Posted: Sun Jun 08, 2003 11:32 am
by Zip
......but how do you link the lights in your room to the switch?
Posted: Sun Jun 08, 2003 12:51 pm
by bdbodger
well what you need to do is not use the light in the mohradiant . You make a script_model give it a
key: $targetname
value: mylight
and
key: model
value: fx/dummy.tik
then in your script
switchthread:
$myswitch anim turn
$myswitch anim waittill animdone
$myswitch anim on
$myswitch anim waittill animdone
$mylight light(1 1 1)
$mylight lightRadius 300
$mylight notsolid
if (level.lightswitch1==0 )
{
$mylight lighton
level.lightswitch1=1
}
else
{
$mylight lightoff
level.lightswitch1=0
}
wait .5
$myswitch anim off
end
Posted: Sun Jun 08, 2003 12:59 pm
by Zip
I see. Thanks. I'll give it go some time.

Posted: Sun Jun 08, 2003 1:33 pm
by bdbodger
One other thing you should put level.lightswitch1=0 somewhere at the top of your script other wise nothing will happen the first time you try to use the switch you will have to press it twice to get it to work . Actually a better Idea is to do this at the top
$mylight light(1 1 1)
$mylight lightRadius 300
$mylight notsolid
level.lightswitch1=0
$mylight lightoff
then this thread
switchthread:
$myswitch anim turn
$myswitch anim waittill animdone
$myswitch anim on
$myswitch anim waittill animdone
if (level.lightswitch1==0 )
{
$mylight lighton
level.lightswitch1=1
}
else
{
$mylight lightoff
level.lightswitch1=0
}
wait .5
$myswitch anim off
end
Posted: Sun Jun 08, 2003 1:46 pm
by Zip
if (level.lightswitch1==0 )
is that a typo? Should it just be = ?
Posted: Mon Jun 09, 2003 2:55 am
by mohaa_rox
no, == are sometimes used, like in this case, where we check the player's dmteam.
if($player.dmteam == allies)
//blah blah
but we have to define $player in MP maps.
Posted: Mon Jun 09, 2003 4:07 am
by bdbodger
In the syntax for mohaa
local.i=1 says local.i is equal to 1
local.i==1 equality is local.i = to 1 boolean true or false outputs 0 or 1
if (level.lightswitch1==0 ) says if true they are equal do the next few lines from "{ " to " }"
also != inequality not equal
if (level.lightswitch1 !=0 ) is level.lightswitch "not" equal to 0 is that true if so do the next few lines
The if statement tests to see if what is in the brackets if true . In the second example it tests to see if the two item are not equal . If they are not the if statement is true so do the lines if the if statement is not true do the else statement if there is one . If no else statement do nothing .
Posted: Mon Jun 09, 2003 10:17 am
by Zip
Thanks
