Sign in to follow this  
derek7

I want number type in lua

Recommended Posts

derek7    100
void Lua::tableInStack(lua_State * L , int tableIndex)
{
	lua_pushnil(L);

	// pop nil and put first key/value at step 1
	while(lua_next(L, tableIndex) != 0)
	{
		// value at top and 处理他
		if(lua_isstring(L, -1))
			//printf("%s = %s\n", lua_tostring(L, -2), lua_tostring(L, -1));
			m_strList.push_back( lua_tostring(L, -1));

		else if(lua_isnumber(L, -1))
			//printf("%s = %d\n", lua_tostring(L, -2), lua_tonumber(L, -1));
			m_numList.push_back(lua_tonumber(L, -1));

		else if(lua_istable(L, -1))
			tableInStack(L, tableIndex);

		//pop value , keep key 
		lua_pop(L, 1);
	}
}

==================================here is lua script===================
-- scene descript --
--Mesh "filename" <position> <rotation> "texture"
mesh = {}
mesh["name"] = "filename"
mesh["position"] = {x=01, y=02, z=03}
mesh["rotation"] = {x=02, y=02, z=03, angle=20}
mesh["texture"] = "na"


all variable is string but Is not x=01 number type??

Share this post


Link to post
Share on other sites
Guest Anonymous Poster   
Guest Anonymous Poster
You ask about 2-3 questions a day, derek7. Can't you ever think of the answer yourself?

Share this post


Link to post
Share on other sites
Sneftel    1788
Perhaps you should look at the description of the lua_isstring function. Also, perhaps it would have been better for you to have looked at it BEFORE asking here, since it's the obvious place to look.

Share this post


Link to post
Share on other sites
dawidjoubert    161
Quote:
Original post by Anonymous Poster
You ask about 2-3 questions a day, derek7. Can't you ever think of the answer yourself?


The reason for this is, he always gets the answer since!!

A : The questions arent considered difficult and are mostly technical to the language as opposed to the application

B : He hasnt discovered Google which gives instant answers

C : This forum also consists of his social life

:-)

Have a nice day Derick

Share this post


Link to post
Share on other sites
dawidjoubert    161
Quote:
Original post by Anonymous Poster
You ask about 2-3 questions a day, derek7. Can't you ever think of the answer yourself?


The reason for this is, he always gets the answer since!!

A : The questions arent considered difficult and are mostly technical to the language as opposed to the application

B : He hasnt discovered Google which gives instant answers

C : This forum also consists of his social life

:-)

Have a nice day Derick

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