什么是Lua国家? [英] What is a Lua State?

查看:156
本文介绍了什么是Lua国家?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要知道,因为我应该知道使用lua_setglobal()使Lua成为全局的是什么.

I need to know because I supposedly need to know what it is to make a Lua global using lua_setglobal().

推荐答案

示例可能会有所帮助...

Brief example which may help...

lua_State* L=lua_open();           // create a Lua state
luaL_openlibs(L);                  // load standard libs 

lua_pushstring(L, "nick");         // push a string on the stack
lua_setglobal(L, "name");          // set the string to the global 'name'

luaL_loadstring(L, "print(name)"); // load a script
lua_pcall(L, 0, 0, 0);             // call the script

这篇关于什么是Lua国家?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆