🎉 Celebrating 25 Years of GameDev.net! 🎉

Not many can claim 25 years on the Internet! Join us in celebrating this milestone. Learn more about our history, and thank you for being a part of our community!

Creating Global Accessable variables in Lua

Started by
2 comments, last by Toolmaker 20 years, 10 months ago
I am developing a C++ game with uses Lua for it''s scripting. However, in all my scripts I need some variables to be the same to keep the scripts easy. For instance, I want to define a global NewLine variable containing \r\n. I tried to do this in my OnGameStart script function but it doesn''t seem to work. Toolmaker -Earth is 98% full. Please delete anybody you can.

Advertisement
Actually, I want to do it from within my code. I tried pushing 2 values onto the stack, but that didn't quite work. So I am confused now.... Any ideas?


-Earth is 98% full. Please delete anybody you can.

[edited by - toolmaker on September 1, 2003 8:20:56 PM]

Just out of curiosity, have you tried tolua? It''s the automatic binding utility I use for my game, and it makes exposing extern''ed global variables in the host program to script pretty simple.



Josh
vertexnormal AT linuxmail DOT org

Check out Golem at:
My cheapass website

lua_pushnumber( luaState, Value );
lua_setglobal( luaState, "Name" );

or

lua_pushstring( luaState, "String" );
lua_setglobal( luaState, "Name" );

Fruny: Ftagn! Ia! Ia! std::time_put_byname! Mglui naflftagn std::codecvt eY'ha-nthlei!,char,mbstate_t>

This topic is closed to new replies.

Advertisement