Sign in to follow this  

I want number type in lua

This topic is 4403 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

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
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
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
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
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

This topic is 4403 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

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