Page 1 of 1

Trying to understand thread initialization

Posted: Fri Feb 21, 2003 12:02 am
by Bjarne BZR
What is the difference between:

Code: Select all

$a_terrible_choice_of_targetname thread a_funky_method_name
...and...

Code: Select all

thread a_funky_method_name
is the target a_terrible_choice_of_targetname sent to a_funky_method_name as a parameter? Or what is happening here?
( I'm a software developer, so don't be afraid to be too complicated when answering :wink: )

Thanx
/Bjarne

Posted: Fri Feb 21, 2003 6:25 am
by mohaa_rox
$a_terrible_choice_of_targetname thread a_funky_method_name will do. The object will do the commands.

Posted: Fri Feb 21, 2003 10:34 am
by Bjarne BZR
Check this out:

Code: Select all

main:
	level waittill prespawn
	exec global/DMprecache.scr
	level.script = maps/obj/script.scr
	exec global/ambient.scr script
	level waittill spawn
	level waittill roundstart
	// This works:
	$a_targetname thread method
	// This does not work:
	thread method
end

method:
	self playsound a_sound_with_alias_in_ubersound
end
...one works one doesn't...

My guess is using $a_targetname thread method sets the environment of the thread to be executed... or? Can anyone clarify the differance?

Posted: Fri Feb 21, 2003 11:35 am
by mohaa_rox
Check the console for errors.

Posted: Fri Feb 21, 2003 11:44 am
by jv_map
When using

Code: Select all

$a_targetname thread method
$a_targetname will be the 'self' of the thread:

Code: Select all

self playsound a_sound_with_alias_in_ubersound 
If you just type

Code: Select all

thread method
'self' will be set equal to the self of the parent thread (main:) which is NULL. Therefore, this code doesn't work. You'll notice 'cannot cast NULL to listener' in console.

Posted: Fri Feb 21, 2003 12:36 pm
by Bjarne BZR
So... lets see if I'm getting this right:

Code: Select all

$a_targetname thread method
...combined with...

Code: Select all

method: 
   self playsound a_sound_with_alias_in_ubersound 
end
...is the same ( except that it does not run in a separate thread ) as writing:

Code: Select all

$a_targetname playsound a_sound_with_alias_in_ubersound
...in the main method? Correct?

Should I read this as "OK, $a_targetname... you play this sound now: a_sound_with_alias_in_ubersound"?
Does this mean that the sound is localized around the $a_targetname entity?

/Bjarne
PS: Another Q: Is there another ( more detailed ) .scr language definition than the one in the files supplied with Radiant?

Posted: Fri Feb 21, 2003 1:23 pm
by jv_map
Yes to all questions, except 'no' for the last :(.

Posted: Fri Feb 21, 2003 5:58 pm
by Bjarne BZR
No to the sound beeing localized or no to the .scr documentation?

Posted: Fri Feb 21, 2003 6:36 pm
by jv_map
No to the documentation.

Posted: Fri Feb 21, 2003 11:29 pm
by Bjarne BZR
Damn.... that can only mean....I'm getting the hang of this.... :shock:




:D