object calling from thread to thread

Post your scripting questions / solutions here

Moderator: Moderators

Post Reply
User avatar
HDL_CinC_Dragon
Brigadier General
Posts: 574
Joined: Mon Dec 22, 2003 8:32 pm

object calling from thread to thread

Post by HDL_CinC_Dragon »

Here is what I have

Code: Select all

main:
	level waittill presawn

setcvar "g_obj_alliedtext1" "" 
setcvar "g_obj_alliedtext2" "" 
setcvar "g_obj_alliedtext3" ""
setcvar "g_obj_axistext1" "" 
setcvar "g_obj_axistext2" "" 
setcvar "g_obj_axistext3" "" 
setcvar "g_scoreboardpic" "" 

	level waittill spawn

thread thing_ops
	local.switch = $ts
	local.trigger = $tt
	local.thing = $thing
	local.redlight = $rl
	local.bluelight = $bl
	local.way1 = $way1
	local.way2 = $way2
	local.way3 = $way3
	local.way4 = $way4
	local.way5 = $way5
	local.way6 = $way6
	local.thing time 3
	local.switch bind local.thing
	local.trigger bind local.thing
	local.redlight bind local.thing
	local.bluelight bind local.thing
end

thing_ops:
while(1)
      }
	local.trigger waittill trigger
	local.switch anim turn
	local.trigger nottriggerable
	wait 2
	local.thing moveto local.way1
	local.thing waitmove
	local.thing moveto local.way2
	local.thing waitmove
	local.thing moveto local.way3
	local.thing waitmove
	local.thing moveto local.way4
	local.thing waitmove
	local.thing moveto local.way5
	local.thing waitmove
	local.thing moveto local.way6
	local.thing waitmove
	iprintlnbold_noloc "End of the line. Now what?"

	waitframe
      {
end
What I want to do is have another thread under that for local.redlight and local.bluelight. How do I tell "light_ops" thread call local.redlight and local.bluelight so that my script is like this:

Code: Select all

main:
	level waittill presawn

setcvar "g_obj_alliedtext1" "What The" 
setcvar "g_obj_alliedtext2" "Heck Is" 
setcvar "g_obj_alliedtext3" "That Thing!?" 
setcvar "g_obj_axistext1" "What The" 
setcvar "g_obj_axistext2" "Heck Is" 
setcvar "g_obj_axistext3" "That Thing!?" 
setcvar "g_scoreboardpic" "" 

	level waittill spawn

thread thing_ops
	local.switch = $ts
	local.trigger = $tt
	local.thing = $thing
	local.redlight = $rl
	local.bluelight = $bl
	local.way1 = $way1
	local.way2 = $way2
	local.way3 = $way3
	local.way4 = $way4
	local.way5 = $way5
	local.way6 = $way6
	local.thing time 3
	local.switch bind local.thing
	local.trigger bind local.thing
	local.redlight bind local.thing
	local.bluelight bind local.thing
	local.redlight hide
	local.bluelight hide
end

thing_ops:
while(1)
      }
	local.trigger waittill trigger
	local.switch anim turn
	local.trigger nottriggerable
	wait 2
	local.redlight show
	local.bluelight show
	local.thing moveto local.way1
	local.thing waitmove
	local.thing moveto local.way2
	local.thing waitmove
	local.thing moveto local.way3
	local.thing waitmove
	local.thing moveto local.way4
	local.thing waitmove
	local.thing moveto local.way5
	local.thing waitmove
	local.thing moveto local.way6
	local.thing waitmove
	iprintlnbold_noloc "End of the line. Now what?"

	waitframe
      {
end

light_ops:
while(1)
       }
	local.redlight _color 0.000000 0.000000 1.000000 //to change it to blue
	local.bluelight _color 1.000000 0.000000 0.000000 //to change it to red
	wait 1
	local.redlight _color 1.000000 0.000000 0.000000 //to change it back to red
	local.bluelight _color 0.000000 0.000000 1.000000 //to change it back to blue

	waitframe
       }
end
So the lights are changing colors all the time so the light_ops thread will be looping over and over. Is this enough info or do u need more?
Image
Green Beret
Major General
Posts: 746
Joined: Mon Apr 19, 2004 12:21 pm
Contact:

Post by Green Beret »

goto
Image
User avatar
HDL_CinC_Dragon
Brigadier General
Posts: 574
Joined: Mon Dec 22, 2003 8:32 pm

Post by HDL_CinC_Dragon »

no thats not what I mean, I want thing_ops to be running the same time as light_ops. goto would basically tell light_ops to start up after thing_ops is done... am I right?
Image
Green Beret
Major General
Posts: 746
Joined: Mon Apr 19, 2004 12:21 pm
Contact:

Post by Green Beret »

if u want it to run the same time then call the thread in prespawn
and they wil be active at same time
Image
User avatar
HDL_CinC_Dragon
Brigadier General
Posts: 574
Joined: Mon Dec 22, 2003 8:32 pm

Post by HDL_CinC_Dragon »

green beret, I notice you have "tech support" icon as your avatar :D


what do i type in the scr?
Image
Green Beret
Major General
Posts: 746
Joined: Mon Apr 19, 2004 12:21 pm
Contact:

Post by Green Beret »

Code: Select all


//after level waittill prespawn

   thread thing_ops

   local.switch = $ts
   local.trigger = $tt
   local.thing = $thing
   local.redlight = $rl
   local.bluelight = $bl
   local.way1 = $way1
   local.way2 = $way2
   local.way3 = $way3
   local.way4 = $way4
   local.way5 = $way5
   local.way6 = $way6
   local.thing time 3
   local.switch bind local.thing
   local.trigger bind local.thing
   local.redlight bind local.thing
   local.bluelight bind local.thing 

         level waittill spawn

end

thing_ops:
while(1)
      }
   local.trigger waittill trigger
   local.switch anim turn
   local.trigger nottriggerable
   wait 2
   local.thing moveto local.way1
   local.thing waitmove
   local.thing moveto local.way2
   local.thing waitmove
   local.thing moveto local.way3
   local.thing waitmove
   local.thing moveto local.way4
   local.thing waitmove
   local.thing moveto local.way5
   local.thing waitmove
   local.thing moveto local.way6
   local.thing waitmove
   iprintlnbold_noloc "End of the line. Now what?"

   waitframe
      {
end
Image
User avatar
HDL_CinC_Dragon
Brigadier General
Posts: 574
Joined: Mon Dec 22, 2003 8:32 pm

Post by HDL_CinC_Dragon »

i dont see anything different...
Image
lizardkid
Windows Zealot
Posts: 3672
Joined: Fri Mar 19, 2004 7:16 pm
Location: Helena MT

Post by lizardkid »

you mixed up the braces, { = opening brace, starts, } = closing brace. ends.

Code: Select all

while(1) 
      } 

Code: Select all

waitframe 
      {
call both of them in your main thread. like

// main and level waittil junk

level waittil spawn

thread bluelight
thread redlight
// any other threads

end
Moderator

۞
Abyssus pro sapientia
Olympus pro Ignarus
۞

AND STUFF™ © 2006
Grassy
First Lieutenant
Posts: 221
Joined: Sun Aug 22, 2004 11:36 am

Post by Grassy »

It looks to me that all those local variables are being antisocial.
They need to get together and have a party in the same thread... LOL

For eg; local.trigger in thread thing_ops is undefined as are all the other local variables in that thread. If you keep them local variables then they have to be defined in the same thread that uses them, otherwise make them level variables. Or pass the variable values to the new thread.

Code: Select all

main: 

setcvar "g_obj_alliedtext1" "" 
setcvar "g_obj_alliedtext2" "" 
setcvar "g_obj_alliedtext3" "" 
setcvar "g_obj_axistext1" "" 
setcvar "g_obj_axistext2" "" 
setcvar "g_obj_axistext3" "" 
setcvar "g_scoreboardpic" "" 

 level waittill presawn 

 level waittill spawn 

 thread thing_ops

end  //end of main script - threads below here

//-----------
thing_ops:
//-----------
//define all the variables in the same thread

   local.switch = $ts 
   local.trigger = $tt 
   local.thing = $thing 
   local.redlight = $rl 
   local.bluelight = $bl 
   local.way1 = $way1 
   local.way2 = $way2 
   local.way3 = $way3 
   local.way4 = $way4 
   local.way5 = $way5 
   local.way6 = $way6 
   local.thing time 3 
   local.switch bind local.thing 
   local.trigger bind local.thing 
   local.redlight bind local.thing 
   local.bluelight bind local.thing 

while(1) 
 { 
   local.trigger waittill trigger 
   local.switch anim turn 
   local.trigger nottriggerable 
   wait 2 
   local.thing moveto local.way1 
   local.thing waitmove 
   local.thing moveto local.way2 
   local.thing waitmove 
   local.thing moveto local.way3 
   local.thing waitmove 
   local.thing moveto local.way4 
   local.thing waitmove 
   local.thing moveto local.way5 
   local.thing waitmove 
   local.thing moveto local.way6 
   local.thing waitmove 
   iprintlnbold_noloc "End of the line. Now what?" 

   waitframe 
  } 
end
Bjarne BZR
Site Admin
Posts: 3298
Joined: Wed Feb 05, 2003 2:04 pm
Location: Sweden
Contact:

Post by Bjarne BZR »

any local defined variable is only visible in the local thread, if you want to use variables like you do in your scipt Dragon, you will need to define them in the level scope, like this:

Code: Select all

	level.switch = $ts
	level.trigger = $tt
	level.thing = $thing
	level.redlight = $rl
	level.bluelight = $bl
	level.way1 = $way1
	level.way2 = $way2
	level.way3 = $way3
	level.way4 = $way4
	level.way5 = $way5
	level.way6 = $way6
	level.thing time 3
	level.switch bind local.thing
	level.trigger bind local.thing
	level.redlight bind local.thing
	level.bluelight bind local.thing
	level.redlight hide
	level.bluelight hide
Admin .MAP Forums
Image
Head above heels.
User avatar
HDL_CinC_Dragon
Brigadier General
Posts: 574
Joined: Mon Dec 22, 2003 8:32 pm

Post by HDL_CinC_Dragon »

so if i change only local.redlight and local.bluelight to level.redlight and level.bluelight those 2 things will be know throughout the script? Will they still work if they are under "thread thing_ops" and I call them to "light_ops:"?

Code: Select all

main:
levelwaittill prespawn
...
levelwaittill spawn

thread thing_ops
...
level.redlight
level.bluelight
level.redlight bind local.thing
level.bluelight bind local.thing

thread light_ops

thing_ops:
....
end

light_ops:
level.redlight do this
level.bluelight do this
more stuff
end
Will that basically work?
Image
Bjarne BZR
Site Admin
Posts: 3298
Joined: Wed Feb 05, 2003 2:04 pm
Location: Sweden
Contact:

Post by Bjarne BZR »

Basically: yes.
Admin .MAP Forums
Image
Head above heels.
User avatar
HDL_CinC_Dragon
Brigadier General
Posts: 574
Joined: Mon Dec 22, 2003 8:32 pm

Post by HDL_CinC_Dragon »

Thanx! all i ned to do is make sure the map is good and test it.
Image
Post Reply