Advertisement

Creating Global Accessable variables in Lua

Started by August 27, 2003 05:05 AM
2 comments, last by Toolmaker 21 years, 2 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.

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]

Advertisement
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