scripting: Moving object
Moderator: Moderators
scripting: Moving object
I'm a noob at scripting.. don't know anything at all.... i want to know how to make an object (small group of brushes) move back and forth (horizontally), continuesly. nothing too hard. hmm...
oh, Lets say the object is in the Middle, i want it to move 288 units To the right, than back to origin, than 288 units to the left.
X <---288units---- Middle ----288units---> X
Thanks.
oh, Lets say the object is in the Middle, i want it to move 288 units To the right, than back to origin, than 288 units to the left.
X <---288units---- Middle ----288units---> X
Thanks.
.:c|H|EE|TO|H|s|:.

Need a thorough map tester? Shine the Cheetohs signal!

Need a thorough map tester? Shine the Cheetohs signal!
You can make waypoints (wayA and wayB), make the brushes or whatever script_object, and give it a targetname.
brushloop:
$brush time .001
$brush moveto $wayA
$brush waitmove
$brush time 10 // time of movement to next waypoint
$brush moveto $wayB
$brush waitmove
$brush time 10
$brush moveto $wayA
$brush waitmove
goto brushloop
end
or you can do this, not sure if it is right:
brushloop2:
$brush time 10
$brush movex -288 // not sure if movex is a scriptcode
wait 1 // if you want to give it a pauze when moved to a side
$brush time 10
$brush movex 576
wait 1
$brush time 10
$brushe movex -288
goto brushloop2
end
brushloop:
$brush time .001
$brush moveto $wayA
$brush waitmove
$brush time 10 // time of movement to next waypoint
$brush moveto $wayB
$brush waitmove
$brush time 10
$brush moveto $wayA
$brush waitmove
goto brushloop
end
or you can do this, not sure if it is right:
brushloop2:
$brush time 10
$brush movex -288 // not sure if movex is a scriptcode
wait 1 // if you want to give it a pauze when moved to a side
$brush time 10
$brush movex 576
wait 1
$brush time 10
$brushe movex -288
goto brushloop2
end
Last edited by At0miC on Sat Jan 01, 2005 1:11 am, edited 2 times in total.
-
Green Beret
- Major General
- Posts: 746
- Joined: Mon Apr 19, 2004 12:21 pm
- Contact:
yup,and make sure u make the group of brush's a script object
and the $wayA and $wayB ect....make sure they are info>waypoint
but i would make 3 of them
$wayC $wayA $wayB
then--> $wayA moveto $wayB
then--> $wayB moveto $wayA
then--> $wayA moveto $wayC
then--> goto brushloop
but im not exactly sure what ur tryin to do
and the $wayA and $wayB ect....make sure they are info>waypoint
but i would make 3 of them
$wayC $wayA $wayB
then--> $wayA moveto $wayB
then--> $wayB moveto $wayA
then--> $wayA moveto $wayC
then--> goto brushloop
but im not exactly sure what ur tryin to do
-
Green Beret
- Major General
- Posts: 746
- Joined: Mon Apr 19, 2004 12:21 pm
- Contact:
or you can try
if you do it like this you wont need info>waypoint's
but still will need to make the brush's a script>object
$brush = targetname of brush's

Code: Select all
brushloop:
$brush time 4
$brush moveEast 200
move
wait 3
$brush time 4
$brush moveWest 200
move
wait 3
$brush time 4
$brush moveWest 200
move
wait 3
$brush time 4
$brush moveEast 200
move
wait 3
goto brushloop
but still will need to make the brush's a script>object
$brush = targetname of brush's
Ill give this one a try, thanx guys... but i noticed one thing... It says move west and east, now, in MOHRadiant, on the topview graph, if we were to "apply" the compass onto it and north would be the Upper part, I would want it to move 'north' and 'south'... Up and down, according to the topview graph (xy). Would i change the easts and wests to Norths and souths?
Code: Select all
brushloop:
$brush time 4
$brush moveEast 200
move
wait 3
$brush time 4
$brush moveWest 200
move
wait 3
$brush time 4
$brush moveWest 200
move
wait 3
$brush time 4
$brush moveEast 200
move
wait 3
goto brushloop .:c|H|EE|TO|H|s|:.

Need a thorough map tester? Shine the Cheetohs signal!

Need a thorough map tester? Shine the Cheetohs signal!
-
Green Beret
- Major General
- Posts: 746
- Joined: Mon Apr 19, 2004 12:21 pm
- Contact:
generally, an easier, more universal way to go is to make them script_objects and waypoints in the 288 units away and do this.
a few things wrong with the others was no "end" and you guys used goto instead of while, while provides a stopper variable from anywhere in the script so its nicer that way, and more failproof 
oh, and ALWAYS, when applying something akin to a key/value to something, this is how it's done
$thing.thing = thing
note the .
Code: Select all
brushloop:
level.moveBrushes = 1
while(level.moveBrushes == 1)
{
$brush.speed = .01
$brush moveto $wap1
$brush waittil movedone
$brush moveto $wap2
}
endoh, and ALWAYS, when applying something akin to a key/value to something, this is how it's done
$thing.thing = thing
note the .
Moderator
۞
Abyssus pro sapientia
Olympus pro Ignarus
۞
AND STUFF™ © 2006
۞
Abyssus pro sapientia
Olympus pro Ignarus
۞
AND STUFF™ © 2006
-
Green Beret
- Major General
- Posts: 746
- Joined: Mon Apr 19, 2004 12:21 pm
- Contact:
Arg, it didnt work... Here is everything to do with it, i have no clue what is wrong.
The part in the .scr:
I have two 'brushloops' because there are 2 of these nets.

Now, in MOHRadiant.. here is what i have:

And the same for the other 'net' ... but its : targetname - $brush
The yellow arrows are the way they SHOULD be moving.
any ideas?!
The part in the .scr:
Code: Select all
level waitTill prespawn
brushloop2:
$brush2 time 4
$brush2 movenorth 200
move
wait 3
$brush2 time 4
$brush2 movesouth 200
move
wait 3
$brush2 time 4
$brush2 movesouth 200
move
wait 3
$brush2 time 4
$brush2 movenorth 200
move
wait 3
goto brushloop2
brushloop:
$brush time 4
$brush movesouth 200
move
wait 3
$brush time 4
$brush movenorth 200
move
wait 3
$brush time 4
$brush movenorth 200
move
wait 3
$brush time 4
$brush movesouth 200
move
wait 3
goto brushloop
//*** Precache Dm Stuff
exec global/DMprecache.scr
level.script = maps/dm/bored.scr
level waittill spawn
Now, in MOHRadiant.. here is what i have:

And the same for the other 'net' ... but its : targetname - $brush
The yellow arrows are the way they SHOULD be moving.
any ideas?!
.:c|H|EE|TO|H|s|:.

Need a thorough map tester? Shine the Cheetohs signal!

Need a thorough map tester? Shine the Cheetohs signal!
i see it, you're trying to create threads in the main thread 
ok, sort it out like this,
remove the threads and find the end of the DM precache stuff and all that MP jargon.
now, AFTER the "end" in that part, put in your threads. then it should work
ok, sort it out like this,
remove the threads and find the end of the DM precache stuff and all that MP jargon.
now, AFTER the "end" in that part, put in your threads. then it should work
Moderator
۞
Abyssus pro sapientia
Olympus pro Ignarus
۞
AND STUFF™ © 2006
۞
Abyssus pro sapientia
Olympus pro Ignarus
۞
AND STUFF™ © 2006
And put an "end" after each thread like this:
Code: Select all
brushloop2:
$brush2 time 4
$brush2 movenorth 200
move
wait 3
$brush2 time 4
$brush2 movesouth 200
move
wait 3
$brush2 time 4
$brush2 movesouth 200
move
wait 3
$brush2 time 4
$brush2 movenorth 200
move
wait 3
goto brushloop2
end
Last edited by At0miC on Sat Jan 01, 2005 11:43 pm, edited 1 time in total.
LoL. Like i said, Im not very good at scripting. For me to script CORRECTLY, i'd need something equivalent to that of a coloring book for crayons. (and staying IN the lines!). Thanks guys. ill try it out and make myself look like more of an idiot lateri see it, you're trying to create threads in the main thread
.:c|H|EE|TO|H|s|:.

Need a thorough map tester? Shine the Cheetohs signal!

Need a thorough map tester? Shine the Cheetohs signal!
-
Green Beret
- Major General
- Posts: 746
- Joined: Mon Apr 19, 2004 12:21 pm
- Contact:
Ugh. It still isn't working. I'm HORRIBLE at this! The net things still don't move at all or do anything.
Here is the entire .scr.... Oh, and im sure you've seen my other scripting problem with the nade activating the light.. that isn't working either... it's like a Motel 6 and their "leaving the light on for me".
Here is the entire .scr.... Oh, and im sure you've seen my other scripting problem with the nade activating the light.. that isn't working either... it's like a Motel 6 and their "leaving the light on for me".
Code: Select all
// Bored
// ARCHITECTURE: Cheetohs
// SCRIPTING: Cheetohs
main:
// set scoreboard messages
setcvar "g_obj_alliedtext1" "Made By:"
setcvar "g_obj_alliedtext2" "Cheetohs"
setcvar "g_obj_alliedtext3" ""
setcvar "g_obj_axistext1" ""
setcvar "g_obj_axistext2" "Or was it?"
setcvar "g_obj_axistext3" ""
setcvar "g_scoreboardpic" "none"
level waitTill prespawn
thread goallight
thread brushloop2
thread brushloop
//*** Precache Dm Stuff
exec global/DMprecache.scr
level.script = maps/dm/bored.scr
level waittill spawn
end
goalLight:
level.doTheLight = 1
while(level.doTheLight == 1)
{
$goalLight1 hide
$goalTrig waittil trigger
$goalLight show
wait 3
$goalLight hide
}
end
brushloop2:
$brush2 time 4
$brush2 movenorth 200
move
wait 3
$brush2 time 4
$brush2 movesouth 200
move
wait 3
$brush2 time 4
$brush2 movesouth 200
move
wait 3
$brush2 time 4
$brush2 movenorth 200
move
wait 3
goto brushloop2
end
brushloop:
$brush time 4
$brush movesouth 200
move
wait 3
$brush time 4
$brush movenorth 200
move
wait 3
$brush time 4
$brush movenorth 200
move
wait 3
$brush time 4
$brush movesouth 200
move
wait 3
goto brushloop
end.:c|H|EE|TO|H|s|:.

Need a thorough map tester? Shine the Cheetohs signal!

Need a thorough map tester? Shine the Cheetohs signal!
an easy mistake even i make sometimes,
all the names of threads etc are case-sensitive in MOH, means capitals count 
that's the name of the thread you're trying to call. 
also, you're trying to make them go just after prespawn.
i think you need to wait until everything is properly in place and the level starts before you tell it to move and hide stuff 
this doesnt mean you suck at scripting, it means you're missing the shift key or dont yet know some of the mechanics of how MOH works.
it comes with time. 
EDIT: oh, and i noted one other thing
remember how i said when you make something liek a key/value that affects how something works or whatever?
should be
and you dont need to put it after each successive move 
Code: Select all
thread goallightCode: Select all
thread goalLightalso, you're trying to make them go just after prespawn.
Code: Select all
level waittil prespawn
thread goallight
thread brushloop2
thread brushloop
level waittil spawnCode: Select all
level waittil spawn
thread goallight
thread brushloop2
thread brushloop
endEDIT: oh, and i noted one other thing
Code: Select all
brushloop2:
$brush2 time 4
$brush2 movenorth 200
move
wait 3
$brush2 time 4
$brush2 movesouth 200
move
wait 3
$brush2 time 4
$brush2 movesouth 200
move
wait 3
$brush2 time 4
$brush2 movenorth 200
move
wait 3
goto brushloop2
end
brushloop:
$brush time 4
$brush movesouth 200
move
wait 3
$brush time 4
$brush movenorth 200
move
wait 3
$brush time 4
$brush movenorth 200
move
wait 3
$brush time 4
$brush movesouth 200
move
wait 3
goto brushloop
endCode: Select all
$brush time 4 Code: Select all
$brush.time 4 Moderator
۞
Abyssus pro sapientia
Olympus pro Ignarus
۞
AND STUFF™ © 2006
۞
Abyssus pro sapientia
Olympus pro Ignarus
۞
AND STUFF™ © 2006
