QuestionluaL_loadfile and luaL_loadstring

Posts 1–15 of 26 · Page 1 of 2
luaL_loadfile and luaL_loadstring
I got luaL_loadfile and luaL_loadstring working all fine but when i try to load a "larger" string or file it crash the game..
I can load the "larger" file or string using the normal lua_run_cl and lua_openscript_cl just fine...

Anyone know why that is the case and maybe a way to fix it?
Any feedback would be greatly appreciated
How big, exactly? Where is the code you are using to get luaL_loadfile and luaL_loadstring?
Quote Originally Posted by tdsx View Post
How big, exactly?
Allready at around 100 lines of simple "print('test')"

Quote Originally Posted by tdsx View Post
Where is the code you are using to get luaL_loadfile and luaL_loadstring?
Code:
lua_gettop = (int(*)(lua_State*))(DWORD)GetProcAddress(GetModuleHandle("lua_shared.dll"), "lua_gettop");
luaL_loadstring = (int(*)(lua_State*, const char*))(DWORD)GetProcAddress(GetModuleHandle("lua_shared.dll"), "luaL_loadstring");
lua_pcall = (int(*)(lua_State*, int, int, int))(DWORD)GetProcAddress(GetModuleHandle("lua_shared.dll"), "lua_pcall");

if(!lua_gettop(luaState)) {
	luaL_loadstring(luaState, string);
	lua_pcall(luaState, 0, 0, 0);
}
I just don't understand why running the lua normaly would work but not this way?
It should be the same thing? Right?
It's also pretty odd that it works fine if the string or file is small.. Like if it only has 1 line or 10..
It also dosen't matter if i put it on multiple lines or one line... I think it just don't like doing that many "actions"
I'll test your code and see if I crash later on today.
Quote Originally Posted by tdsx View Post
I'll test your code and see if I crash later on today.
You ever got to test it?
Quote Originally Posted by kasperbjerby View Post
You ever got to test it?
nah I got lazy. Go look at dis.

https://github.com/tdsx/gmcl_externa...uxiliary.h#L46

It's a shitty way to do it, though. You should do if (!luaL_loadbuffer call) then LUA->Call. I fucked that part up.
Quote Originally Posted by TroubleMakers View Post
use runstring you dumbfuck
Be nice? I am not making a module.. But if you can tell me how to use runstring without the gmod headers i am open for it
Add me on steam for it 功能 - OC
Quote Originally Posted by Function - OC View Post
Add me on steam for it 功能 - OC
Don't keep helping cheaters.
If you guys could get on my level you could figure it out.
Quote Originally Posted by Function - OC View Post
Add me on steam for it 功能 - OC
paster detected

Quote Originally Posted by z346etn56jzd7egth View Post
If you guys could get on my level you could figure it out.
you're not even @BigBadWilly 's level so you can stop bragging about your nonexisting skills :willythumb:
Code:
	void RunString(const char* string)
	{
		int code = luaL_loadbuffer(m_luaState, string, strlen(string), "=RunString");
		if(code)
		{
			const char* szError = lua_tostring(m_luaState, -2);
			pCvar->ConsoleColorPrintf(Color(192, 57, 43, 255), "[COMPILE ERROR] %s\n", szError);
			lua_pop(m_luaState, 2);
			return;
		}
		code = lua_pcall(m_luaState, 0, 0, m_iError);
		if(code != LUA_SUCCESS) 
		{
			lua_pop(m_luaState, 1);
		}
	}
is what i use
Quote Originally Posted by MeepDarknessMeep View Post
Code:
	void RunString(const char* string)
	{
		int code = luaL_loadbuffer(m_luaState, string, strlen(string), "=RunString");
		if(code)
		{
			const char* szError = lua_tostring(m_luaState, -2);
			pCvar->ConsoleColorPrintf(Color(192, 57, 43, 255), "[COMPILE ERROR] %s\n", szError);
			lua_pop(m_luaState, 2);
			return;
		}
		code = lua_pcall(m_luaState, 0, 0, m_iError);
		if(code != LUA_SUCCESS) 
		{
			lua_pop(m_luaState, 1);
		}
	}
is what i use
It works 1 in 5 times..
Others it runs the lua and then crash..
Just to be sure what is m_iError and LUA_SUCCESS?
skids are helping skids wtf is that shit
Posts 1–15 of 26 · Page 1 of 2

Post a Reply

Similar Threads

Tags for this Thread

None

Talk with us