Trying to understand thread initialization

Post your scripting questions / solutions here

Moderator: Moderators

Post Reply
Bjarne BZR
Site Admin
Posts: 3298
Joined: Wed Feb 05, 2003 2:04 pm
Location: Sweden
Contact:

Trying to understand thread initialization

Post 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
Admin .MAP Forums
Image
Head above heels.
User avatar
mohaa_rox
Field Marshal
Posts: 2760
Joined: Mon Nov 11, 2002 7:05 am
Contact:

Post by mohaa_rox »

$a_terrible_choice_of_targetname thread a_funky_method_name will do. The object will do the commands.
Live to map, not map to live.
-mohaa_rox, .map
moderator
Bjarne BZR
Site Admin
Posts: 3298
Joined: Wed Feb 05, 2003 2:04 pm
Location: Sweden
Contact:

Post 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?
Admin .MAP Forums
Image
Head above heels.
User avatar
mohaa_rox
Field Marshal
Posts: 2760
Joined: Mon Nov 11, 2002 7:05 am
Contact:

Post by mohaa_rox »

Check the console for errors.
Live to map, not map to live.
-mohaa_rox, .map
moderator
jv_map
Site Admin
Posts: 6521
Joined: Tue Sep 03, 2002 2:53 pm
Location: The Netherlands
Contact:

Post 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.
Image
Bjarne BZR
Site Admin
Posts: 3298
Joined: Wed Feb 05, 2003 2:04 pm
Location: Sweden
Contact:

Post 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?
Admin .MAP Forums
Image
Head above heels.
jv_map
Site Admin
Posts: 6521
Joined: Tue Sep 03, 2002 2:53 pm
Location: The Netherlands
Contact:

Post by jv_map »

Yes to all questions, except 'no' for the last :(.
Image
Bjarne BZR
Site Admin
Posts: 3298
Joined: Wed Feb 05, 2003 2:04 pm
Location: Sweden
Contact:

Post by Bjarne BZR »

No to the sound beeing localized or no to the .scr documentation?
Admin .MAP Forums
Image
Head above heels.
jv_map
Site Admin
Posts: 6521
Joined: Tue Sep 03, 2002 2:53 pm
Location: The Netherlands
Contact:

Post by jv_map »

No to the documentation.
Image
Bjarne BZR
Site Admin
Posts: 3298
Joined: Wed Feb 05, 2003 2:04 pm
Location: Sweden
Contact:

Post by Bjarne BZR »

Damn.... that can only mean....I'm getting the hang of this.... :shock:




:D
Admin .MAP Forums
Image
Head above heels.
Post Reply