Blockland Forums > Modification Help
containerRadiusSearch, code cleaning
ThinkInvisible:
Can someone explain exactly how containerRadiusSearch-es work? I know that they look for all of a specific object in an area, but in what order does it show them?
Also, what are some common mistakes in coding that make it harder to work with?
And how do I 'protect' a looping function (schedule(x, 0, self)) so if it has a copy of itself running it will end said copy?
Port:
--- Quote from: ThinkInvisible on March 11, 2012, 10:08:37 AM ---Can someone explain exactly how containerRadiusSearch-es work? I know that they look for all of a specific object in an area, but in what order does it show them?
--- End quote ---
I believe they show in order of object ID lowest to highest, although I'm not certain.
--- Quote from: ThinkInvisible on March 11, 2012, 10:08:37 AM ---Also, what are some common mistakes in coding that make it harder to work with?
--- End quote ---
Excessive/missing parenthesis, among others.
--- Quote from: ThinkInvisible on March 11, 2012, 10:08:37 AM ---And how do I 'protect' a looping function (schedule(x, 0, self)) so if it has a copy of itself running it will end said copy?
--- End quote ---
--- Code: ---function loop()
{
cancel( $loop );
echo( "Schedule test: " @ getSimTime() - $lastLoopTime );
$lastLoopTime = getSimTime();
$loop = schedule( 480, 0, "loop" );
}
--- End code ---
Headcrab Zombie:
Not sure about your first question
Common mistakes that people make are missing semicolons, parenthesis, etc.
Mistakes that make code "harder to work with" are things like messy formatting. They don't break the code themselves, but they do make it a lot harder to find things that do break the code.
As for the third question, what Port said, though I don't see any point in the middle part other than console spam
ThinkInvisible:
--- Quote from: Headcrab Zombie on March 11, 2012, 02:38:04 PM ---Mistakes that make code "harder to work with" are things like messy formatting. They don't break the code themselves, but they do make it a lot harder to find things that do break the code.
--- End quote ---
This is what I'm talking about. Some things that a lot of people do that you don't really need to.
Headcrab Zombie:
It's more like not doing things you almost need to
I can't really think of anything that people do, but don't need to