scripting: Moving object

Post your scripting questions / solutions here

Moderator: Moderators

Grassy
First Lieutenant
Posts: 221
Joined: Sun Aug 22, 2004 11:36 am

Post by Grassy »

Howdy,

Firstly I would put the lines that call the threads _below_ level waittill spawn. Only things that need precaching should be above prespawn.

Secondly, your movement thread.

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 
In the above you have two move commands here "movenorth" & "move" on it's own. Also to keep track of the moving object you need something like a "waitmove"

Code: Select all

brushloop2:
  //only need to specify an objects speed once if not changing it 
  $brush2 time 4
while (1)
  {
       $brush2 movenorth 200 
       $brush2 waitmove   //wait till move is done 
       wait 3
       $brush2 movesouth 200 
       $brush4 waitmove 
       wait 3 
       $brush2 movesouth 200 
       $brush2 waitmove 
       wait 3 
       $brush2 movenorth 200 
       $brush2 waitmove 
       wait 3 
  }
end 
Another way to keep your script more compact is to re-use a thread;
I understand in your case the objects are moving in opposit directions but if you wanted more than one object moving the same way you could do it this way.

$brush thread movebrush
$brush2 thread movebrush

Code: Select all

movebrush:
  //only need to specify an objects speed once if not changing it 
  self time 4
while (self)
  {
       self movenorth 200 
       self waitmove   //wait till move is done 
       wait 3
       self movesouth 200 
       self waitmove 
       wait 3 
       self movesouth 200 
       self waitmove 
       wait 3 
       self movenorth 200 
       self waitmove 
       wait 3 
  }
end 
User avatar
Cheetohs
Brigadier General
Posts: 569
Joined: Sun Jan 04, 2004 6:01 am
Location: Minnesota
Contact:

Post by Cheetohs »

Alright thanks guys, Lizard your the greatest... Grassy... you too man. Ill go test it out quick. Im down to only a few strands of hair.
.:c|H|EE|TO|H|s|:.
Image
Need a thorough map tester? Shine the Cheetohs signal!
User avatar
Cheetohs
Brigadier General
Posts: 569
Joined: Sun Jan 04, 2004 6:01 am
Location: Minnesota
Contact:

Post by Cheetohs »

Omg... this is making me angry! Ive tried everything i could possibly try that i know to make ONE of these things work.... but alas, i cant. I quadruple checked everything over and over, looked for spelling and everything.... just not cut out for this!

I switched all the names to lowercase letters in both radiant and in the .scr, so that shouldn't be the problem. If anyone is willing, i could send them the .pk3 of the .map and .scr.... gah.

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"
setcvar "g_obj_axistext3" "It?"

setcvar "g_scoreboardpic" "none"


level waitTill prespawn 



//*** Precache Dm Stuff
exec global/DMprecache.scr



level.script = maps/dm/bored.scr

level waittill spawn

thread goallight1

thread brushloop2

thread brushloop

end

goallight1: 

level.doTheLight = 1 

while(level.doTheLight == 1) 
{ 
$goallight1 hide 
$goaltrig waittil trigger 
$goallight1 show 
wait 3 
$goallight1 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 »

send it here, porion@bresnan.net, i'd be happy to look it over ;)
Moderator

۞
Abyssus pro sapientia
Olympus pro Ignarus
۞

AND STUFF™ © 2006
User avatar
bdbodger
Moderator
Posts: 2596
Joined: Tue Feb 25, 2003 7:34 am
Location: canada
Contact:

Post by bdbodger »

You can try putting some debug lines in your script like

$goaltrig waittil trigger
iprintln "I was triggered"
$goallight1 show

also if you make a script model and give it the model fx/corona_red.tik and put it where the light is you can hide and show it it may show the red light better . When you do this

$brush2 time 4
$brush2 movenorth 200
move
wait 3
$brush2 time 4
$brush2 movesouth 200

the brush starts moveing north but then starts to move south too so it is actually fighting it's self to move maybe even with the wait3 try doing it this way so it does one movement then the other also I don't think you need to keep useing time4 I think you just need to do that once unless you want to change it . I think anyway . I don't like goto either I would but it in a while(1) loop .

$brush2 time 4
$brush2 movenorth 200
waitmove
wait 3
$brush2 movesouth 200
Image
jv_map
Site Admin
Posts: 6521
Joined: Tue Sep 03, 2002 2:53 pm
Location: The Netherlands
Contact:

Post by jv_map »

Sorry if this has been said before, I just looked over the thread really quickly and to me it seems that

move

must be

$brush2 move

:)
Image
Grassy
First Lieutenant
Posts: 221
Joined: Sun Aug 22, 2004 11:36 am

Post by Grassy »

OMG. did anyone actually read me post ???
:evil: :?:
User avatar
wacko
Field Marshal
Posts: 2085
Joined: Fri Jul 05, 2002 8:42 pm
Location: Germany

Post by wacko »

isnt it 'waittill' (with 2 l's)? in goallight1, there is a 'waittil' :?
Green Beret
Major General
Posts: 746
Joined: Mon Apr 19, 2004 12:21 pm
Contact:

Post by Green Beret »

here ya go.

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"
setcvar "g_obj_axistext3" "It?"

setcvar "g_scoreboardpic" "none"


level waitTill prespawn

thread goallight1//call after prespawn

thread brushloop2

thread brushloop

//*** Precache Dm Stuff
exec global/DMprecache.scr



level.script = maps/dm/bored.scr

level waittill spawn


end

//goal_light------------------------------------------------------------------------

goallight1:

level.doTheLight = 1

while(level.doTheLight == 1)
{
$goallight1 hide
$goaltrig waittil trigger
$goallight1 show
wait 3
$goallight1 hide
}

end

//brusgloop2-----------------------------------------------------------------------

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

//brushloop1-----------------------------------------------------------------------

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


this works for me,i did a quick test :wink:
Image
User avatar
Cheetohs
Brigadier General
Posts: 569
Joined: Sun Jan 04, 2004 6:01 am
Location: Minnesota
Contact:

Post by Cheetohs »

Arg. Even that .scr didnt work...meaning the problem has got to be in MOHRadiant with my map?

Oh, and in that script Green... shouldnt:

Code: Select all

$goaltrig waittil trigger
be

Code: Select all

$goaltrig waittill trigger
kinda like wacko said....

Probably a stupid question, but what do the dollar signs do? and why use theM?
.: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 »

yea,i just copied and pasted,didnt notice it. :lol:
but yea,add it with two l's waittill


so is it the goal light that dont work?
Image
User avatar
Cheetohs
Brigadier General
Posts: 569
Joined: Sun Jan 04, 2004 6:01 am
Location: Minnesota
Contact:

Post by Cheetohs »

neither. same thing. Nets don't move and the goal light is on from the start.
.: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 »

well,when i took out the goallight script,the other worked :?
Image
Green Beret
Major General
Posts: 746
Joined: Mon Apr 19, 2004 12:21 pm
Contact:

Post by Green Beret »

try this for the gaol light
(make sure you use a script_model. model=fx/dummy.tik

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"
setcvar "g_obj_axistext3" "It?"

setcvar "g_scoreboardpic" "none"

level waitTill prespawn

thread goallight_on

thread brushloop

//*** Precache Dm Stuff
exec global/DMprecache.scr

level.script = maps/dm/bored.scr

level waittill spawn

$brush bind $light
$light bind $goallight1

end

//goallight-----------------------------------------------------------------------

goallight_on:

               $goaltrig waittill trigger
               $light light 1 0 0 706
               wait 3
               $light light 0 0 0 706
               goto goallight_on

//brushloop1-----------------------------------------------------------------------

brushloop:

                $brush movesouth 200
                move
                wait 3
                $brush movenorth 200
                move
                wait 3
                $brush movenorth 200
                move
                wait 3
                $brush movesouth 200
                move
                wait 3
                goto brushloop

end
i couldnt get the brush's to move,i think its because the trigger is in the middle of the brush's.im not sure im still testing it different ways,but this goal light does work
Last edited by Green Beret on Sun Jan 02, 2005 8:42 pm, edited 1 time in total.
Image
lizardkid
Windows Zealot
Posts: 3672
Joined: Fri Mar 19, 2004 7:16 pm
Location: Helena MT

Post by lizardkid »

the $ sign is the entity operator, it means "i'm talking about an entity wit hthis name." as opposed to a class like local or level which mean "I'm talking about a variable with this name."
Moderator

۞
Abyssus pro sapientia
Olympus pro Ignarus
۞

AND STUFF™ © 2006
Post Reply