天天看點

Lua for Windows 開始學習Lua程式設計

        Lua for Windows is a 'batteries included environment' for the Lua scripting language on Windows.這是在Windows上學習Lua的整套開發環境,包含Installer Lua Interpreter, Lua Reference Manual, Quick Lua Tour Sample, Examples directory, Libraries with documentation. Lua Compiler (luac) Text Editors (SciTE and I think maybe wxLua editors too) C header files/libraries/etc. for building C module

項目位址: http://code.google.com/p/luaforwindows/

目前版本:5.1.4-45

Lua for Windows 開始學習Lua程式設計
        下載下傳之後,在安裝目錄" ...\Lua\5.1\SciTE"下,打開 SciTE.exe檔案,建立一個文檔,儲存為" hello.lua",文檔内容如下:

1 print( "hello,lua")

按下F5,在下面的輸出視窗将會有如下内容: 

2

3

>lua -e "io.stdout:setvbuf 'no'" "hello.lua"  

hello,lua

>Exit code: 0

運作結果圖如下所示:

Lua for Windows 開始學習Lua程式設計

在" ...\Lua\5.1\examples"目錄下,有個" quickluatour.lua"是一些快速入門的示例。其中有個例子,是利用 IupLua顯示對話框的,建立一個" test.lua"檔案,内容如下: 

4

5

6

7

8

9

10

11

require(  "iuplua" )

ml = iup.multiline

    {

    expand= "YES",

    value= "Quit this multiline edit app to continue Tutorial!",

    border= "YES"

    }

dlg = iup.dialog{ml; title= "IupMultiline", size= "QUARTERxQUARTER",}

dlg:show()

print( "Exit GUI app to continue!")

iup.MainLoop()

儲存。在指令提示符下輸入" lua test.lua",回車,效果如下所示:

Lua for Windows 開始學習Lua程式設計

繼續閱讀