Lua


スクリプト>Lua

  • ブラジル

LuaSDL
http://tulrich.com/geekstuff/index.html

wxLua
http://www.luascript.thersgb.net/

http://www.gorlice.net.pl/~rybak/luaide/

Lua用開発環境 QDE version 0.6

Lua for Delphi

Calua
http://calua.sourceforge.net/

サンプルコード

int errno;	// (リンクエラー対策。errno.cppとして別ファイルにしておく。)
extern "C" {
	#include "lua.h"
	#include "lualib.h"
	#include "lauxlib.h"
}

lua_State *L;

	L = lua_open();
	luaopen_base(L);
	luaopen_string(L);
	luaopen_table(L);
	luaopen_math(L);
	luaopen_io(L);

	lua_register(L, "foo", do_foo); // fooというfunctionを登録

	lua_dofile(L, "startup.lua"); // スクリプトを読み込んで実行
	lua_dostring(L, "foo()"); // fooというfunctionを実行

	lua_close(L);
// foo() 
static int do_foo(lua_State *L) {
  int n = lua_gettop(L); /* 引数の数 */

  return 0;
}

Luaで定義した変数をCから読む

lua_getglobal(L, 変数名); // 変数名の値がスタックに積まれる
int val = (int)lua_tonumber(L, -1); // スタックから取り出す

External links

備考

  • アクセス
    • 041005--041008--041019--041023--041027--041030--041031
    • 041107--041108--041109--041117--041119--041124--041126--041127--041128--041129
    • 041206--041207--041213--041214--041220--041224
    • 050217--050218

索引