Hi, I'm new to squirrel and ran into some problems.
As the tile says: How do I use it?
Here is some sample code:
void register_entity(HSQUIRRELVM v)
{
sq_pushroottable(v); //on stack 1
sq_pushstring(v, "numbers", -1); //2
sq_newtable(v); //3
// one
sq_pushstring(v, "one", -1); //4
sq_pushinteger(v, 1);//5
sq_newslot(v, -3, SQFalse );//3
// two
sq_pushstring(v, "two", -1);
sq_pushinteger(v, 2);
sq_newslot(v, -3, SQFalse );
// three
sq_pushstring(v, "three", -1);
sq_pushinteger(v, 3);
sq_newslot(v, -3, SQFalse );
sq_newslot(v, -3, SQFalse );//1
sq_pushstring(v, _SC("Entity"), -1);//2
sq_newclass(v, SQFalse);//3
sq_settypetag(v, -1, reinterpret_cast<SQUserPointer>(SQ_ENTITY_TYPE_TAG));
for (SQInteger i = 0; entity_funcs
![Idea [I]](/emoticons/emotion-55.gif)
.name != 0; ++i)
{
SQRegFunction &f = entity_funcs
![Idea [I]](/emoticons/emotion-55.gif)
;
sq_pushstring(v, f.name, -1);//4
sq_newclosure(v, f.f, 0);//5
sq_setparamscheck(v, f.nparamscheck, f.typemask);
sq_setnativeclosurename(v, -1, f.name);
sq_newslot(v, -3, SQFalse);//3
}
sq_newslot(v,-3, SQFalse);//1
sq_pop(v, 1);// pop the root table 0
}
I can create 'Entity' instances but not access the 'numbers table ([the index 'numbers' does not exist]). I'm using the Squirrel 3.0 alpha.