The importance of commenting your code
It's not just so other people can make sense of it, although that's nice too, it's also in case you come back and try to read it yourself ten years later. Take this gem:
void main( void ) { if (&secret < 8) sp_active(¤t_sprite, 0); if (&secret > 8) sp_active(¤t_sprite, 11); }

January 26th 2012, 04:38 AM

shevek


in case you come back and try to read it yourself ten years later.
Make that ten hours. Or, in case of DinkC, where you had to torture your brain a lot more than with other languages, perhaps even ten minutes...
The code you show seems buggy, but indeed, if there would be comments they could show that it was done on purpose (which doesn't mean it was sane
) According to the docs, the active attribute can be read back. So you can use it as a variable, as long as you don't set it to 0.
The fact that &secret == 8 is skipped is most likely a real bug, though. If there's on sp_active (..., -1) in this or any other script, then you may conclude that the 11 is a typo and it would have been useless anyway to set it to 1...
Make that ten hours. Or, in case of DinkC, where you had to torture your brain a lot more than with other languages, perhaps even ten minutes...
The code you show seems buggy, but indeed, if there would be comments they could show that it was done on purpose (which doesn't mean it was sane

The fact that &secret == 8 is skipped is most likely a real bug, though. If there's on sp_active (..., -1) in this or any other script, then you may conclude that the 11 is a typo and it would have been useless anyway to set it to 1...
Yeah, I know what you mean.
I used to dislike comments for some reason (no reason), and actually purposefully erased all comments from my scripts. Nowadays that I dabble with Dink once maybe every few months if the mood strikes me, I've repented this decision fully.
Even some really basic organizing (like adding a short description of where the script is used in the beginning) goes a long way at preventing self-induced hairloss.


You either drink fifteen cups of coffee per day, or comment your code. Which ever you'll find easier.

In case anyone is wondering, as best I can tell. The < part is correct (it should not be active until secret is at least eight), and the > part does absolutely nothing, which is probably also correct. But I have no idea why I wrote that, and I can't help worrying that there might have been a reason.
January 26th 2012, 11:57 AM

shevek


But I have no idea why I wrote that, and I can't help worrying that there might have been a reason.
As I wrote, it is a way to store a number. But to use it, you must use sp_active (..., -1); If there is any script using that, it may be using this feature, and you can explore it. Most like there is no script doing that. In that case, if there ever was a reason you wrote it, it no longer exists.
As I wrote, it is a way to store a number. But to use it, you must use sp_active (..., -1); If there is any script using that, it may be using this feature, and you can explore it. Most like there is no script doing that. In that case, if there ever was a reason you wrote it, it no longer exists.
