An error and a question
#7
Setting the player on fire is not yet possible through the API (and even MCServer does a really poor job, especially of un-setting the fire). We haven't yet reached a consensus on where exactly to put the fire handling, whether into cEntity or cPawn.

(05-01-2013, 06:02 AM)xoft Wrote: Definitely NOT. Do NOT compare boolean values, that's bad practice in C++ and makes the code less readable.

To elaborate on that a bit, although I'm gonna be talking C/C++ here, it might be different in Lua: Imagine you have two bool values and want to compare them. An unsuspecting victim might try a simple code like
if (BoolVal1 == BoolVal2)
However, this won't work. The compiler is free to use zero for false and nonzero for true, which means two values that are logically true needn't be actually equal. "5" is true, "7" is true, but 5 != 7.
Doing a comparison like
if (BoolVal == true)
you're comparing BoolVal's value (which could be a number, really) with "1" or "-1" or even "255", depending on the compiler.

From another point of view, using code like this is somewhat misleading:
if (ShouldDoIt == false)

So the best practice is to use bool values directly:
if (ShouldDoIt)
{
  DoIt();
}
if (!ShouldExit)
{
  DoIt();
}
Reply
Thanks given by:


Messages In This Thread
An error and a question - by tonibm19 - 05-01-2013, 04:29 AM
RE: An error and a question - by NiLSPACE - 05-01-2013, 04:54 AM
RE: An error and a question - by xoft - 05-01-2013, 06:02 AM
RE: An error and a question - by NiLSPACE - 05-01-2013, 06:04 AM
RE: An error and a question - by tonibm19 - 05-01-2013, 04:23 PM
RE: An error and a question - by xoft - 05-01-2013, 06:06 AM



Users browsing this thread: 1 Guest(s)