表
a = { }
b = { x = 1, ["hello, "] = "world!" }
a.astring = "ni, hao!"
a[1] = 100
a["a table"] = b
function foo()
end
function bar()
end
a[foo] = bar
--分别穷举表a和b
for k, v in pairs(a) do
print(k, "=>",...
分类:
其他好文 时间:
2014-07-22 23:00:33
阅读次数:
261
函数环境
function foo()
print(g or "No g defined!")
end
foo()
setfenv(foo, { g = 100, print = print }) --设置foo的环境为表{ g=100, ...}
foo()
print(g or "No g defined!")
--No g defined!
--100
--No g defined!...
分类:
其他好文 时间:
2014-07-22 22:59:54
阅读次数:
338
函数闭包
function createCountdownTimer(second)
local ms=second * 1000;
local function countDown()
ms = ms - 1;
return ms;
end
return countDown;
end
timer1 = createCountdownTimer(1);
for...
分类:
其他好文 时间:
2014-07-22 22:59:53
阅读次数:
307
前段时间认真的看了一下《lua程序设计(第二版)》这本书,每一章写一个lua脚本,诸多注释,相信给初学者有一定帮助。 -- 第一章代码print("hello
Hello");-- 全局函数function face(n) if n == 0 then return 1 else return n ...
分类:
其他好文 时间:
2014-05-06 00:57:20
阅读次数:
339
首先用package system安装android-mode, 然后编辑~/.emacs.d/init.el文件,添加下面几行:(require 'android-mode)
(setq android-mode-sdk-dir "/opt/android-sdk-linux/")现在重新启动emacs,然后M-x 中运行命令android-start-emulator此时会提示输入Androi...
分类:
移动开发 时间:
2014-05-02 22:49:40
阅读次数:
561
“参考Lua游戏开发实践指南”
Lua提供两种控制结构(数字型和通用型)--Lua中的for语句的索引是从1开始的 数字型: 一个简单的示例如下1 for indx = 1, 10 do2
print(indx)3 end do关键字标记程序块的开始,end标记程序块的结束。 ...
分类:
其他好文 时间:
2014-05-02 17:26:51
阅读次数:
702
直接就上代码了:-module(shop).-export([cost/1,total/1]).cost(orange)
-> 5;cost(newspaper) -> 8;cost(apples) -> 2;cost(pears) ->
9;cost(milk) -> 7....
分类:
其他好文 时间:
2014-05-02 12:58:19
阅读次数:
280
将Apache 与modsecurity集成后,启动Apache时,报出的异常:
“..undefined symbol: lua_setglobal”
后来,发现自己安装了两个lua库。一个事手工安装,一个是centOS工具套件安装的。
删除了手工安装的lua后,一切OK。
但是,记得重新编译modsecurity。...
分类:
其他好文 时间:
2014-05-02 10:24:27
阅读次数:
404
下载lua源码包,进入到根目录下1、执行makemacosx2、然后再sudomakeinstall即可
分类:
其他好文 时间:
2014-05-02 08:16:40
阅读次数:
246
编译Lua时,出现这样的错误:
gcc -O2 -Wall -DLUA_COMPAT_ALL -DLUA_USE_LINUX -c -o lua.o lua.clua.c:67:31: error:
查阅了一下,centOS上需要安装readline-devel ncurses-devel
yum install readline-devel ncurses-devel
...
分类:
系统相关 时间:
2014-05-02 07:03:00
阅读次数:
455