It kills the ScriptThread listener (the thread) stored in local.waitfacethread. Remove or delete would do the same thing. It's like doing:
local end
for the current thread, but it's pointless as end on its own does the same thing. But in your example it can be very useful.
Also, I don't think I saw group scope/thread groups explained anywhere? This could be useful too . It also ties in with what you've already explained. For example, waitexec doesn't necessarily run all the code, just the code in the starting thread group.
E.g. if you changed your example to:
startLoop:
//this simply starts a loop in a diferent thread
$player thread someLoop
end
someLoop:
//this loop runs forever
while( 1 )
{
waitframe
}
end
it would finish with waitexec because defining the self object for a new thread (in this case, using the player entity) creates a new thread group for the someLoop function.
If you are passing the self object that the previous thread has, you don't need to explicitly include it in the next thread call:
main:
$player thread DoStuff1
end
DoStuff1:
self.done_stuff1 = 1
thread DoStuff2
end
DoStuff2:
self.done_stuff2 = 1
end
It will pass the self object of the current thread group into all other threads unless you redefine the self object again. Essentially, threads belong to the same thread group as long as they are in the same file and self is implicitly equal to the parent thread.
And in regards to variables in general, I like to view them as just adding properties to an object (so, essentially the scripting language doesn't really have 'true' variables). local, level, group and game are all just a type of entity/object that you add properties to, just like player objects. local is always the ScriptThread object its called in, group is the ScriptClass object, and so on... Which means $player.something is pretty much the same as local.something or group.something etc... They are all properties defined on a specific object/entity. Obviously they aren't the same type of entity/listener/object, but it's an easy way to view it. Which leads me onto the question of whether entity types should be at least noted? E.g. Entity vs SimpleArchivedEntity (players vs player starts, for example). One eats into the server entity limit and the other doesn't. 'maxentities' can be changed to increase the server entity limit btw.
Oh, and quick question, with the table on the previous page:
exec myFolder/myFile.scr::myFunction | thread myFolder/myFile.scr
I assume you mean exec myFolder/myFile.scr ?