All pastes #214229 Raw Edit

Something

public text v1 · immutable
#214229 ·published 2006-10-21 22:29 UTC
rendered paste body
// test.lua :
ch1 = solace.Habba
print("ch1 type: " .. type(ch1))
print("ch1 swigtype: " .. swig_type(ch1))

ch2 = solace.char_data();
print("ch2 type: " .. type(ch2))
print("ch2 swigtype: " .. swig_type(ch2))

ch3 = ...
print("ch3 type: " .. type(ch3))
print("ch3 swigtype: " .. swig_type(ch3))

//output
ch1 type: userdata
ch1 swigtype: _p_char_data
ch2 type: userdata
ch2 swigtype: _p_char_data
ch3 type: userdata

And then everything crashes =)

// comm.c :

CHAR_DATA *Habba; // externed in header and wrapped by SWIG

void do_lua_parse(CHAR_DATA *ch, char *argument)
{
	Habba = ch;
	if (argument[0] == '\0')
	{
		if (luaL_loadfile(luaKernel, "./lua/test.lua"))
		{
			send_to_char("LUA: There was a problem loading file.\n\r", ch);
			return;
		}
	}
	else
	{
		if (luaL_loadstring(luaKernel, argument))
		{
			send_to_char("LUA: There was a problem loading string.\n\r", ch);
			return;
		}
	}
	lua_pushlightuserdata(luaKernel, ch);
	lua_call(luaKernel, 1, 0);
}