Page 1 of 3
scripting: Moving object
Posted: Sat Jan 01, 2005 12:24 am
by Cheetohs
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.
Posted: Sat Jan 01, 2005 12:52 am
by At0miC
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
Posted: Sat Jan 01, 2005 12:56 am
by Green Beret
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

Posted: Sat Jan 01, 2005 1:07 am
by Green Beret
or you can try
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
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

Posted: Sat Jan 01, 2005 2:56 am
by Cheetohs
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
Posted: Sat Jan 01, 2005 4:22 am
by Green Beret
yes,north and south work also
Posted: Sat Jan 01, 2005 5:31 am
by lizardkid
generally, an easier, more universal way to go is to make them script_objects and waypoints in the 288 units away and do this.
Code: Select all
brushloop:
level.moveBrushes = 1
while(level.moveBrushes == 1)
{
$brush.speed = .01
$brush moveto $wap1
$brush waittil movedone
$brush moveto $wap2
}
end
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 .
Posted: Sat Jan 01, 2005 5:45 am
by Green Beret
Posted: Sat Jan 01, 2005 9:07 pm
by Cheetohs
Arg, it didnt work... Here is everything to do with it, i have no clue what is wrong.
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
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?!
Posted: Sat Jan 01, 2005 11:20 pm
by lizardkid
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

Posted: Sat Jan 01, 2005 11:29 pm
by At0miC
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
Posted: Sat Jan 01, 2005 11:35 pm
by Cheetohs
i see it, you're trying to create threads in the main thread
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 later

....
Posted: Sun Jan 02, 2005 12:54 am
by Green Beret
Posted: Sun Jan 02, 2005 1:05 am
by Cheetohs
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".
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
Posted: Sun Jan 02, 2005 1:21 am
by lizardkid
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.
Code: Select all
level waittil prespawn
thread goallight
thread brushloop2
thread brushloop
level waittil spawn
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
Code: Select all
level waittil spawn
thread goallight
thread brushloop2
thread brushloop
end
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
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
end
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
