Sign in to follow this  
Aph3x

LuaPlus: 'type' is a nil value?

Recommended Posts

Hi all, I got a script that runs fine in basic Lua, but when moving over to LuaPlus it gives the error that the function 'type' is nil (first line of the 'RegisterMod' function). Seeing as the 'type' function is part of the basic Lua lib, I wonder what's gone wrong... is LuaPlus doing something with function environments at a wild guess?!
-- Mods 'namespace' table
Mods =
{
	-- Mod registration table.
	Registry = 
	{
		-- User mods get added here.
	},


	-- Call this fn to register a mod.
	RegisterMod = function(aModInfo)
		if (type(aModInfo) ~= "table") then
			DebugAPI.LogError("Invalid param type to RegisterMod")
			return;
		end		
		if (aModInfo.Name == nil) then
			DebugAPI.LogError("Mod info has no 'Name' entry")
			return;
		end

		table.insert(Mods.Registry, aModInfo)
	end

}


Share this post


Link to post
Share on other sites
Hmmm... seems like *none* of the library functions are available in my function!
The LuaPlus docs say that the Create() function includes the Lua standard library, so am I missing something..?!

Share this post


Link to post
Share on other sites
Oh dear, am I red-faced.
The Create function source gives a small clue...


LuaState* LuaState::Create(bool initStandardLibrary)



/me hides

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this