Jump to content

how to properly reloading Level with script objects (frameWork)


flachdrache
 Share

Recommended Posts

Hi, i want to convert my sceneLoader C source to c++ and hit a wall with retrieving the lua state for using its transparency script settings ... this is/should all be frameWork.

 

The entities in question are not handled within ProcessScene(), are the usual suspects firepit, waterplane and the atmosphere but loading fine first time around.

 

from the engine.log

Loading script "c:/devlab01/le23sample/vs2008_proto_arena_01/media/engine/models/props/firepit/firepit.lua"...
Lua error: c:/devlab01/le23sample/vs2008_proto_arena_01/media/engine/models/props/firepit/firepit.lua:25: attempt to index field 'transparency' (a nil value)

 

I init lua like this :

// --
// Set Lua framework object	  
SetGlobalObject( "fw", fw );
// Set Lua framework variable	  
BP lua = GetLuaState();	  
lua_pushobject( lua, fw );	  
lua_setglobal( lua, "fw" );	  
lua_pop( lua, 1 );
// ...

 

i brute force reLoading in the main loop like this :

  // --
  // Prepare App for new sceneLoad
  if( KeyHit(KEY_F5) )
  {
FreeFramework(fw);
			fw = CreateFramework();
// Set Lua framework object	  
SetGlobalObject( "fw", fw );
// GfxSetup
// --
SetBloom( true );
SetHDR( true );
SetGodRays( false);
SetSSAO( false );
SetAntialias( true );
SetReflectionElements(ENTITY_MESH | ENTITY_MODEL | ENTITY_TERRAIN);
playerIndex01.~cController();
// --
// recreate layer_world for new framework
TLayer _layer_main;
TLayer _layer_background;
TLayer _layer_transparency;
_layer_main = GetFrameworkLayer(0);
_layer_background = GetFrameworkLayer(-1);
_layer_transparency = GetFrameworkLayer(1);
// Set its global vars for lua ...
SetGlobalObject ("main.world", _layer_main );
SetGlobalObject ("transparency.world", _layer_transparency );
SetGlobalObject ("background.world", _layer_background );
playerIndex01.SetCamera( GetLayerCamera(_layer_main) );
playerIndex01.CreatePlayer();
// --
scene.~cScene();
scene.Load( "abstract::SceneParaTropique_GTownCamp.sbx" );
// add camera from scene
PositionEntity( playerIndex01.GetCamera(), scene.GetCameraPos() );	  
RotateEntity( playerIndex01.GetCamera(), scene.GetCameraRot() );
// add controller from scene camera
PositionEntity( playerIndex01.GetPlayer(), scene.GetCameraPos() );
  }

 

As you can see i even tried to pass framework layers with "SetGlobalObject" - however, i just want to assign/get the previous lua state back to use fw.transparency etc ...

 

hint&help appreciated

AMD 64 X2 Dual 5k - 4GB - XFX GForce9800GT - nv196.21 - WinXP Sp3

zBrush4R2 - Silo2Pro - Unwrap3DPro - Gile - MaPZone2.5

 

adv_banner-april2012_720x150_tex01.png

 

Xxploration FPS in progress ...

Link to comment
Share on other sites

FYI :

 

Because its not quickload but scene change i dont know if clearing the world will do ... or what happens with the data if its memory isnt free`d.

 

that is from some lua engine.exe fps-sample

 

if KeyHit(KEY_F1)==1 then
   FreeFramework(fw)
   fw=CreateFramework()
   SetGlobalObject("fw",fw) 

   g_playerstart = nil	 
   scene=LoadScene("abstract::SceneParaTropique_GTownCamp.sbx")
   g_playerstart = scene:FindChild("playerstart")
   playercreation()
   dofile("sample_Player_Fps.lua") 
end

if KeyHit(KEY_F2)==1 then
   FreeFramework(fw)
   fw=CreateFramework()
   SetGlobalObject("fw",fw)

   g_playerstart = nil	 
   scene=LoadScene("abstract::SceneParaTropique_GTownCamp.sbx")
   g_playerstart = scene:FindChild("playerstart")
   playercreation()
   dofile("sample_Player_Fps.lua") 
end

 

... which works because of the differance of who`s client<>host.

AMD 64 X2 Dual 5k - 4GB - XFX GForce9800GT - nv196.21 - WinXP Sp3

zBrush4R2 - Silo2Pro - Unwrap3DPro - Gile - MaPZone2.5

 

adv_banner-april2012_720x150_tex01.png

 

Xxploration FPS in progress ...

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

 Share

×
×
  • Create New...