
busted : Elegant Lua unit testing, by Olivine-Labs What's busted, precious? busted is a unit testing framework with a focus on being easy to use. busted works with lua >= 5.1, moonscript, terra, and LuaJIT >= 2.0.0. busted test specs read naturally without being too verbose. An extensible assert library allows you to extend and craft your own assert functions specific to your case with method chaining. busted test.lua Usage Installation Install busted through Luarocks. You can also install the latest or a branch by cloning the busted repository, and running luarocks make from the directory. CLI: Running Busted Usage: busted [OPTIONS] [--] [ROOT-1 [ROOT-2 [...]]] Predefined Busted Tasks Busted 1.6 added a concept of "tasks", or predefined busted configuration options. return { _all = { coverage = true }, default = { verbose = true }, apiUnit = { tags = "api", ROOT = {"spec/unit"}, verbose = true } } This allows you to run busted --run=apiUnit, which will run the equivalent of busted --coverage --tags=api --verbose spec/unit. Standalone Pending
Pencil Drawings - Realistic Portrait Art - Sketches and Colored Pencil - Grand Rapids Artist Lua 5.1 Reference Manual by Roberto Ierusalimschy, Luiz Henrique de Figueiredo, Waldemar Celes Copyright © 2006–2012 Lua.org, PUC-Rio. Freely available under the terms of the Lua license. contents · index · other versions · english · português · español Lua is an extension programming language designed to support general procedural programming with data description facilities. Being an extension language, Lua has no notion of a "main" program: it only works embedded in a host client, called the embedding program or simply the host. Lua is free software, and is provided as usual with no guarantees, as stated in its license. Like any other reference manual, this document is dry in places. This section describes the lexis, the syntax, and the semantics of Lua. The language constructs will be explained using the usual extended BNF notation, in which {a} means 0 or more a's, and [a] means an optional a. 2.1 – Lexical Conventions The following keywords are reserved and cannot be used as names: 2.2 – Values and Types
深入Lua-based GUI系統架構與實做細節 >> 猴子靈藥 在前篇「使用Lua實做GUI系統的遊戲實例」中介紹了 Lua 於 GUI 系統的基本用法後,本文開始進入 GUI 的核心功能層面。 一般來說,有數種不同的架構方式能夠結合 Lua 與 C++ 實做 GUI 系統。其一是將 Lua Script 當作純粹資料描述用的程式碼,僅儲存 UI Layout 相關的資料(如前篇文章所示),而由 C++ Code 掌控核心功能並且讀取 Lua Script 進行資料的處理。其二則是於 C++ 端實做出一組完整的 UI Widget 類別,然後再將這組 Widget 的所有函式、甚至所有類別,註冊給 Lua 端自行呼叫使用。 另一種方法則是在 Lua Script 中包含資料描述以及核心功能,將 GUI 系統的全部相關功能全權交由 Lua 端處理。 使用上述的架構,在 C++ 端只需要實現唯一一個類別:GuiManager,做為 Facade 介面與遊戲引擎的其他系統溝通。 對整個 Lua-based GUI 系統的架構有了基礎的概念,並且瞭解 GUI 系統的 C++ 端如何運作之後,接著先看看在遊戲中使用 GUI Script 的實例: Frame { name = "ingame", x = 0, y = 0, width = 20, height = 20, backdrop = "Image/bk.png", Button { name = "ingame_main", x = 0, y = 0, width = 15, height = 20, graphics = StandardButtonGraphics, mouse_up = function() Gui.ShowFrame("main_menu"); Core.SetGameState(GAME_PAUSE); end, }; } 上述這段程式碼,定義了一個名稱為 in_game 的 Frame 元件,位於螢幕座標 (0, 0) 的位置,長度與寬度的大小都是 20 個像素,背景圖片使用 Image/bk.png。 在 Button() 函式中,先利用 Lua 的物件導向設計能力,具現化出一個 ButtonData 物件。 在遊戲主迴圈進行繪圖程序時,由 C++ 端的 GuiManager 物件呼叫 Lua 端的 GuiRender() 函式:
Coxpcall - Coroutine Safe xpcall and pcall LuaFileSystem Overview LuaFileSystem is a Lua library developed to complement the set of functions related to file systems offered by the standard Lua distribution. LuaFileSystem offers a portable way to access the underlying directory structure and file attributes. LuaFileSystem is free software and uses the same license as Lua 5.x (MIT). Status Current version is 1.7.0. Download LuaFileSystem can be installed using LuaRocks: $ luarocks install luafilesystem Its source can be found at its Github page. History Version 1.7.0 [15/Sep/2017] symlinkattributes function now provides 'target' field, containing name of the file that the symlink points to. attributes, symlinkattributes, touch, mkdir, and rmdir functions now return system-dependent error code as the third value on error. Version 1.6.3 [15/Jan/2015] Lua 5.3 support. Version 1.6.2 [?? Full Lua 5.2 compatibility (with Lua 5.1 fallbacks) Version 1.6.1 [01/Oct/2012] fix build for Lua 5.2 Version 1.6.0 [26/Sep/2012] Version 1.5.0 [20/Oct/2009] Credits
LuaDoc: Documentation Generator Tool for the Lua language Overview LuaDoc is a documentation generator tool for Lua source code. It parses the declarations and documentation comments in a set of Lua source files and produces a set of XHTML pages describing the commented declarations and functions. The output is not limited to XHTML. LuaDoc is free software and uses the same license as Lua. Status Current version is 3.0.1. Download LuaDoc can be downloaded from its Lua Forge page. Dependencies LuaDoc depends on two external packages: History Version 3.0.1 [17/Feb/2008] added support to @usage tags (thanks to Rafael Sabbagh Armony) makefile improved to follow kepler standards lualogging dependency is now optional added a rockspec file Version 3.0.0 [13/Aug/2007] update to Lua 5.1 major internal refactoring Version 2.0 [14/Aug/2002] update to Lua 4.0 Version 1.1 [31/Mar/1999] "DOS/Windows"-safe sources (no problems with "\r\n" line-breaks) new usage subsection Version 1.0 [15/Mar/1999] Credits LuaDoc codebase was designed and developed by Tomás Guisasola.
Live coding in Lua with ZeroBrane Studio - ZeroBrane I was working on a lightweight Lua IDE for those who want to learn programming when I came across Bret Victor's Inventing On Principle and Kill Math projects. If you haven't seen them before, I recommend you spend a bit of time listening to his ideas about interactive design. Just don't close this page and come back when you're done as I'll show you how you can do some of it with Lua scripts today. The core part of the message is that designers need an immediate connection to their creations and even a short update-run-use loop may be too long to explore a variety of different options, parameters, and their interactions. Sometimes the relations or dependencies between variables become more obvious when you not only have a way to interact with the object, but also control the interaction. The video shows how you can use live coding with different scripts running in ZeroBrane Studio (you may need to switch the video to 720p to make the text more readable).
ZeroBrane Studio - Lua IDE/editor/debugger for Windows, Mac OSX, and Linux wxLua - homepage lua源码剖析(一) - 但行好事 莫问前程 - ITeye博客 先来看lua中值的表示方式。 #define TValuefields Value value; int tt typedef struct lua_TValue { TValuefields; } TValue; #define TValuefields Value value; int tt typedef struct lua_TValue { TValuefields; } TValue; 其中tt表示类型,value也就是lua中对象的表示。 typedef union { GCObject *gc; void *p; lua_Number n; int b; } Value; typedef union { GCObject *gc; void *p; lua_Number n; int b; } Value; gc用于表示需要垃圾回收的一些值,比如string,table等等。 tvalue这样表示会有空间的浪费.可是由于要完全符合c99,因此只能这么做.否则我们为了效率可以这么做.由于在大多数机器上,指针都是严格对齐(4或者8字节对齐).因此后面的2,3位就是0,因此我们可以将类型存储在这几位,从而极大地压缩了Value的大小. 更新:这里经的老朱同学的提醒,其实tvalue之所以不使用指针的后几位来存储类型,更重要的时候由于和c的交互.因为那样的话,我们就必须强制和lua交互的c模块也必须保持和我们一样的内存模型了. lua_state表示一个lua虚拟机,它是per-thread的,也就是一个协程(多个和lua交互的c程序,那自然也会有多个lua-state)一个lua_state,然后来看它的几个比较重要的域。 StkId top这个域表示在这个栈上的第一个空闲的slot。 在 lstrlib中,基本上所有的str函数都是首先调用luaL_checklstring来得到所需要处理的字符串然后再进行处理。 luaL_checklstring 函数,这个函数只是简单的对lua_tolstring进行了一层简单的封装。 因此我们详细来看index2adr这个函数,这个函数目的很简单,就是通过索引得到对应的值的指针。 我们首先要知道在lua中,索引值可以为负数也可以为正数,当为负数的话,top为-1,当为正数第一个压入栈的元素为1,依此类推. 首先来看TSring:
zeuxcg.org - Lua callstack with C++ debugger 07 Nov 2010 Lua is a very popular scripting language in game development industry. Many games use Lua for various scripting needs (data representation, UI scripting, AI scripting), and some go as far as write the majority of the game in Lua. At CREAT, we used Lua for all of UI scripting, and for AI and other game logic on some projects. While there are probably very few bugs in Lua library code, and the language is safe so you can’t get buffer overruns or other madness only via script code, script code itself is useless, because it can’t do any interaction with the outside world - user, world state, scoreboard servers, etc. Assuming we don’t want to modify C++/Lua code in any way, nor do we want to restart the game with tracing hook enabled - the easily reproducible bugs are often a luxury - we’re left with the following methods: If the external Lua debugger was attached, it’s likely that we’ll be able to get the callstack and the related information from it. You don’t want to do that.
development blog: Fixing memory issues in Lua Garbage collection can be both a blessing and a curse. On the one hand, it frees you from manually managing memory. This saves development time, reduces bugs, and avoids tricky decisions about objects' ownerships and lifetimes. On the other hand, when you do run into memory issues (and you most likely will), they can be a lot harder to diagnose and fix, because you don't have detailed control over how memory is allocated and freed. In this post I'll show some techniques that you can use to address memory issues in Lua (and by extension, in other garbage collected languages). All Lua memory issues essentially boil down to one of two things: Lua uses too much memory On consoles memory is a precious resource and sometimes Lua is just using too much of it. Garbage collection is taking too long Too much garbage collection is (not surprisingly) caused by having too much garbage. Let's look at each issue in turn and see how we can address it. 1. So how do we find out where the memory is going? 2.
Lua IDE: Decoda Today we are very pleased to announce that we’ve released Decoda, our Lua IDE (Integrated Development Environment) and debugger, as open source. You can get the latest version of the source from GitHub and the Windows installer from the download page. We created Decoda in 2007 just as we were starting work on Natural Selection 2 and getting our company off the ground. Since Natural Selection 2 uses Lua heavily we realized that a complete IDE with an integrated debugger would be critical. Although it was initially an internal tool, we quickly realized that other developers would benefit from Decoda as well. Today, after the successful launch of Natural Selection 2, we have the opportunity to re-evaluate our business strategy. We intend to keep on developing Decoda, but we are most excited about what *you* can do to help make it the best IDE out there! Max
Good to know, I will give a more serious look to this pearl or I may bet for HTML5. by x11 Oct 24