Page 1 of 1

Were do I put this wrapper? [Resolved]

Posted: Fri Nov 04, 2011 11:20 pm
by THe Floating Brain
I have a class ( WSL::Member_Components::Lightning_Sprite ). The inheritance for it goes

Code: Select all

      Render_Functonal -> Render_Base <T> -> SFMLType<sfmlType> -> Lightning_Sprite
I wrote the following wrapper for it:

Code: Select all

//I open luabind before I write this.//
luabind::module( WSL::Scripting::Lua.State )[
luabind::class_<WSL::Member_Components::Rendering_System::Base::Render_Functonal>( "RenderFunctonal" )
	.def( luabind::constructor<>() )
];
luabind::module( WSL::Scripting::Lua.State )[
	luabind::class_<WSL::Member_Components::Rendering_System::Base::Render_Base<sf::Sprite>, WSL::Member_Components::Rendering_System::Base::Render_Functonal>( "RenderBase" )
	.def( luabind::constructor<>() )
];
luabind::module( WSL::Scripting::Lua.State )[
	luabind::class_<WSL::Member_Components::Rendering_System::Base::SubBase::SFMLType<sf::Sprite>, WSL::Member_Components::Rendering_System::Base::Render_Base<sf::Sprite>>( "SFMLType" )
	.def( luabind::constructor<>() )
];
//Just the rotate method because im still testing.
luabind::module( WSL::Scripting::Lua.State )[
luabind::class_<WSL::Member_Components::Lightning_Sprite, WSL::Member_Components::Rendering_System::Base::SubBase::SFMLType<sf::Sprite> >( "Lightning_Sprite" )
	.def( luabind::constructor<>() )
	.def( "Rotate", &WSL::Member_Components::Lightning_Sprite::Rotate )
];
In one of the classes in my framework I have the following code:

Code: Select all

luabind::globals( WSL::Scripting::Lua.State )[ "sprite" ] = spr[0].MakePointer( refrence[0] );
Basically it registers a global with Lua (a global Lightning_Sprite to be exact).
Now, I know the wrapper and this code is good because I got it to work before, but I had to put the wrapper in the constructor of my Positional class ( the class the code above is from ) and multiple instantiation did not like that very much. So, I have tried to put this wrapper all over the place and it just keeps being stubborn, I either get compiler errors or when I do the line above I get a unreferenced pointer and the IDE brings me either to class_registry.hpp or class_cache.hpp. PLEASE HELP!

Thanks for reading :mrgreen:

P.s I know I can sometimes have trouble getting my point across if any clarification is needed please let me know.


-----EDIT-----:
FIXED!
I was half asleep when I wrote this but I will explain what happened so anyone with this problem can know.
I was reconstruction the lua_State in every .obj file so when I made my wrapper it was being allocated to a different lua stack then the file was being run in.
Here is the solution. Make a pointer to the lua state in main or whatever then pass it into the object were the script is going to be run and do the following code:

Code: Select all

//I have a class containing my lua pointer.//
//I also have a singleton with a pointer to the container.//
luabind::globals( engine->lua->State )[ "sprite" ] = &mySprite;

Re: Were do I put this wrapper? [Resolved]

Posted: Sat Nov 05, 2011 10:51 am
by GroundUpEngine
Coding late at night has it's advantages and disadvantages lol... ;) I did the same thing with vertex buffers and kept making new ones every time but didn't notice, tested the program in college the next day and badly segfault/crashed a computer :lol:

Re: Were do I put this wrapper? [Resolved]

Posted: Mon Nov 07, 2011 8:04 am
by Falco Girgis
Holy JESUS, you like namespaces... It's like being at work...

Re: Were do I put this wrapper? [Resolved]

Posted: Thu Nov 10, 2011 5:22 pm
by Obscurity
GyroVorbis wrote:Holy JESUS, you like namespaces... It's like being at work...
You forgot your name-space there. :twisted:

Re: Were do I put this wrapper? [Resolved]

Posted: Sat Nov 12, 2011 5:30 pm
by EccentricDuck
GyroVorbis wrote:Holy JESUS, you like namespaces... It's like being at work...
It's like programming in Java again.

Re: Were do I put this wrapper? [Resolved]

Posted: Sat Nov 19, 2011 9:36 pm
by THe Floating Brain
GyroVorbis wrote:Holy JESUS, you like namespaces...
That I do :mrgreen:
EccentricDuck wrote:It's like programming in Java again.
**Starts rapidly deleting namespaces** :lol: