|
@@ -3518,7 +3518,8 @@ tnsLight *tnsCreateLight(tnsObject *under, char *Name, real AtX, real AtY, real
|
|
|
l->Strength = Strength;
|
|
|
l->UniDirectional = UniDirectional;
|
|
|
|
|
|
- if (root && UniDirectional && !root->ParentObject) memAssignRef(root, &root->ParentObject,l);
|
|
|
+ // ?????????? WTF
|
|
|
+ //if (root && UniDirectional && !root->ParentObject) memAssignRef(root, &root->ParentObject,l);
|
|
|
return l;
|
|
|
}
|
|
|
|
|
@@ -3742,7 +3743,7 @@ void tnsEvaluateThisObject(tnsObject *o, tnsEvaluateData* ed){
|
|
|
}
|
|
|
|
|
|
void tnsClearPlayDuplicate(tnsObject* o){
|
|
|
- if(!o->PlayDuplicate) return;
|
|
|
+ if(!o || !o->PlayDuplicate) return;
|
|
|
while(lstPopPointer(&o->PlayDuplicate->ChildObjects));
|
|
|
for(laListItemPointer* lip=o->ChildObjects.pFirst;lip;lip=lip->pNext){
|
|
|
tnsObject*co=lip->p; tnsClearPlayDuplicate(co);
|
|
@@ -3787,7 +3788,13 @@ void tnsFreePlayDuplicate(tnsObject* o){
|
|
|
o->PlayDuplicate=0;
|
|
|
}
|
|
|
|
|
|
-void tnsLuaInit(lua_State* L){ lua_settop(L,0);
|
|
|
+void tnsLuaSetObject(lua_State* L, tnsObject*o){
|
|
|
+ lua_getglobal(L,"ffi"); lua_getfield(L,-1,"cast"); lua_pushstring(L,"struct tnsObject *"); lua_pushlightuserdata(L,o);
|
|
|
+ lua_call(L,2,1); lua_remove(L,-2); lua_setfield(L,-2,"object");
|
|
|
+}
|
|
|
+void tnsLuaInit(lua_State* L){
|
|
|
+ if(luaL_loadstring(L, LA_TNS_LIB_COMMON) || lua_pcall(L, 0, 0, 0)){ logPrint(" Error loading tns lua libs\n"); };
|
|
|
+ lua_settop(L,0);
|
|
|
lua_newtable(L); lua_setglobal(L,"scene");
|
|
|
lua_getglobal(L,"scene"); lua_pushstring(L,"nodes"); lua_newtable(L); lua_settable(L,1);
|
|
|
lua_pushnil(L); lua_setfield(L,1,"node"); lua_pop(L,1);
|
|
@@ -3795,8 +3802,11 @@ void tnsLuaInit(lua_State* L){ lua_settop(L,0);
|
|
|
void tnsLuaEnsureNode(lua_State* L,int index){ lua_settop(L,0);
|
|
|
lua_getglobal(L,"scene"); lua_getfield(L,1,"nodes");
|
|
|
lua_pushinteger(L,index); lua_gettable(L,2); if(lua_isnil(L,3) || (!lua_istable(L,3))){
|
|
|
- lua_pushinteger(L,index); lua_newtable(L); lua_settable(L,2); lua_pop(L,2);
|
|
|
+ lua_pushinteger(L,index); lua_newtable(L); lua_settable(L,2); lua_pop(L,1);
|
|
|
+ lua_pushinteger(L,index); lua_gettable(L,2);
|
|
|
+ lua_pushlightuserdata(L,0); lua_setfield(L,3,"object");
|
|
|
}
|
|
|
+ lua_pop(L,3);
|
|
|
}
|
|
|
void tnsLuaRemoveNode(lua_State* L,int index){ lua_settop(L,0);
|
|
|
lua_getglobal(L,"scene"); lua_pushstring(L,"nodes"); lua_gettable(L,1);
|
|
@@ -3805,7 +3815,8 @@ void tnsLuaRemoveNode(lua_State* L,int index){ lua_settop(L,0);
|
|
|
void tnsLuaRunNode(lua_State* L, tnsEvaluatedNode* en, char* func, tnsObject* root){ lua_settop(L,0); int index=en->LuaID;
|
|
|
lua_getglobal(L,"scene"); lua_getfield(L,1,"nodes");
|
|
|
lua_pushinteger(L,index); lua_gettable(L,2); lua_setfield(L,1,"node"); lua_pop(L,1);
|
|
|
- lua_getfield(L,1,"node"); lua_getfield(L,2,"scripts");
|
|
|
+ lua_getfield(L,1,"node"); tnsLuaSetObject(L,root);
|
|
|
+ lua_getfield(L,2,"scripts");
|
|
|
if(lua_isnil(L,3) || (!lua_istable(L,3))){
|
|
|
lua_pop(L,1); lua_newtable(L); lua_setfield(L,2,"scripts"); lua_getfield(L,2,"scripts");
|
|
|
}
|
|
@@ -3962,7 +3973,7 @@ void tnsEvaluateObjectTree(tnsObject* from, tnsEvaluateData* UseED, int Evaluate
|
|
|
|
|
|
if(ed->SceneEvaluateMode){ tnsEvaluateSyncNode(ed, 0); ed->Scene->CurrentParent=CP; ed->Scene->CurrentChild=CC; }
|
|
|
if(!UseED){ ed->Done=1;
|
|
|
- if(ed->Scene){ tnsPrintEvaluatedNode(ed->Scene->Root,0);}
|
|
|
+ //if(ed->Scene){ tnsPrintEvaluatedNode(ed->Scene->Root,0);}
|
|
|
}
|
|
|
}
|
|
|
void tnsDrawLayer(tnsEvaluateData* ed,int Layer,void* CustomData){
|