lua-users home
lua-l archive

[Date Prev][Date Next][Thread Prev][Thread Next] [Date Index] [Thread Index]


>From my reading Lua doesn't support booleans. No problem I thought; I'll just
define TRUE and FALSE and typedef unsigned char to be my own boolean type, and
then expose them using ToLua.

So this is my C++ code:

namespace Habitat
{
	namespace Core
	{
		typedef		unsigned char		HBboolean;
		#define		HB_TRUE				1
		#define		HB_FALSE			0
	}
}

And this is my package file:

module Habitat
{
	module Core
	{
		typedef		unsigned char		HBboolean;
		#define		HB_TRUE				1
		#define		HB_FALSE			0
	}
}

Now when I try to use these in my Lua scripts, nothing works:

	flag = HB_FALSE
	flag2 = HB_TRUE

	Log:Print(type(HB_FALSE))
	Log:Print(type(HB_TRUE))

	Log:Print(type(flag))
	Log:Print(type(flag2))


These all display:

nil

Am I missing something really obvious? Any help greatly appreciated.

Thanks
Mike