Page 1 of 1

object calling from thread to thread

Posted: Sun Dec 12, 2004 8:46 pm
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?

Posted: Sun Dec 12, 2004 9:06 pm
by Green Beret
goto

Posted: Sun Dec 12, 2004 9:11 pm
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?

Posted: Sun Dec 12, 2004 9:20 pm
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

Posted: Sun Dec 12, 2004 9:25 pm
by HDL_CinC_Dragon
green beret, I notice you have "tech support" icon as your avatar :D


what do i type in the scr?

Posted: Sun Dec 12, 2004 9:34 pm
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

Posted: Sun Dec 12, 2004 9:37 pm
by HDL_CinC_Dragon
i dont see anything different...

Posted: Sun Dec 12, 2004 10:06 pm
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

Posted: Sun Dec 12, 2004 11:03 pm
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

Posted: Sun Dec 12, 2004 11:46 pm
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

Posted: Mon Dec 13, 2004 2:54 am
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?

Posted: Mon Dec 13, 2004 7:50 am
by Bjarne BZR
Basically: yes.

Posted: Mon Dec 13, 2004 8:08 pm
by HDL_CinC_Dragon
Thanx! all i ned to do is make sure the map is good and test it.