scripting: Moving object

Post your scripting questions / solutions here

Moderator: Moderators

User avatar
Cheetohs
Brigadier General
Posts: 569
Joined: Sun Jan 04, 2004 6:01 am
Location: Minnesota
Contact:

scripting: Moving object

Post 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.
.:c|H|EE|TO|H|s|:.
Image
Need a thorough map tester? Shine the Cheetohs signal!
User avatar
At0miC
General
Posts: 1164
Joined: Fri Feb 27, 2004 11:29 pm
Location: The Netherlands

Post 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
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:

Post by Green Beret »

yup,and make sure u make the group of brush's a script object :wink:
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 :P
Image
Green Beret
Major General
Posts: 746
Joined: Mon Apr 19, 2004 12:21 pm
Contact:

Post 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
8-)
Image
User avatar
Cheetohs
Brigadier General
Posts: 569
Joined: Sun Jan 04, 2004 6:01 am
Location: Minnesota
Contact:

Post 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 
.:c|H|EE|TO|H|s|:.
Image
Need a thorough map tester? Shine the Cheetohs signal!
Green Beret
Major General
Posts: 746
Joined: Mon Apr 19, 2004 12:21 pm
Contact:

Post by Green Beret »

yes,north and south work also
Image
lizardkid
Windows Zealot
Posts: 3672
Joined: Fri Mar 19, 2004 7:16 pm
Location: Helena MT

Post 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 .
Moderator

۞
Abyssus pro sapientia
Olympus pro Ignarus
۞

AND STUFF™ © 2006
Green Beret
Major General
Posts: 746
Joined: Mon Apr 19, 2004 12:21 pm
Contact:

Post by Green Beret »

:oops:
Image
User avatar
Cheetohs
Brigadier General
Posts: 569
Joined: Sun Jan 04, 2004 6:01 am
Location: Minnesota
Contact:

Post 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.
Image

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

Image

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|:.
Image
Need a thorough map tester? Shine the Cheetohs signal!
lizardkid
Windows Zealot
Posts: 3672
Joined: Fri Mar 19, 2004 7:16 pm
Location: Helena MT

Post by lizardkid »

i see it, you're trying to create threads in the main thread :P

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
User avatar
At0miC
General
Posts: 1164
Joined: Fri Feb 27, 2004 11:29 pm
Location: The Netherlands

Post 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
Last edited by At0miC on Sat Jan 01, 2005 11:43 pm, edited 1 time in total.
User avatar
Cheetohs
Brigadier General
Posts: 569
Joined: Sun Jan 04, 2004 6:01 am
Location: Minnesota
Contact:

Post 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 :lol: :P....
.:c|H|EE|TO|H|s|:.
Image
Need a thorough map tester? Shine the Cheetohs signal!
Green Beret
Major General
Posts: 746
Joined: Mon Apr 19, 2004 12:21 pm
Contact:

Post by Green Beret »

:P
Image
User avatar
Cheetohs
Brigadier General
Posts: 569
Joined: Sun Jan 04, 2004 6:01 am
Location: Minnesota
Contact:

Post 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
.:c|H|EE|TO|H|s|:.
Image
Need a thorough map tester? Shine the Cheetohs signal!
lizardkid
Windows Zealot
Posts: 3672
Joined: Fri Mar 19, 2004 7:16 pm
Location: Helena MT

Post by lizardkid »

an easy mistake even i make sometimes,

Code: Select all

thread goallight
all the names of threads etc are case-sensitive in MOH, means capitals count ;)


Code: Select all

thread goalLight
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. :wink:

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?


Code: Select all

$brush time 4 
should be

Code: Select all

$brush.time 4 
and you dont need to put it after each successive move ;)
Moderator

۞
Abyssus pro sapientia
Olympus pro Ignarus
۞

AND STUFF™ © 2006
Post Reply