例子1 : ableprint = function(data,cstring,deepIndex) --第二个参数可以为空,第三个参数不要手动添加,它是用来进行打印深度控制的. if data == nil then print("core.print data is nil"); end end if cstring == nil then cstring = "" end local cs = cstring .. " "; print(c
lua中打印所以类型功能实现 本人測试 number.string.bool.nil.table嵌套table.userdata没问题 共享一下有什么问题请拍砖 代码例如以下 cclog = function( ... ) local tv = "\n" local xn = 0 local function tvlinet(xn) -- body for i=1,xn do tv = tv.."\t" end end local function printTab
为方便调试lua程序,往往想以树的形式打印出一个table,以观其表内数据.以下罗列了三种种关于树形打印lua table的方法;法一 local print = print local tconcat = table.concat local tinsert = table.insert local srep = string.rep local type = type local pairs = pairs local tostring = tostring local next = nex
lua的很多语法跟matlab很像 最基本的赋值是一样的 循环和选择判断后面必须跟一个关键字:do和then ,, do ... end if - then - end table是lua的唯一一种数据结构,但是可以用它来构造数组.链表.字典等. -- Dict literals have string keys by default: t = {key1 ='value1', key2 =false} -- String keys can use js-like dot notation: p
function serialize(obj) local lua = "" local t = type(obj) if t == "number" then lua = lua .. obj elseif t == "boolean" then lua = lua .. tostring(obj) elseif t == "string" then lua = lua .. string.format("%q&q
1 创建lua打飞机项目 cocos new T32Lua -dE:\Installed\cocos2d-x-3.2\cocos2d-x-3.2\projects -l lua 2 项目代码 Common.lua --用于打印日志信息 function cclog(...) print(string.format(...)) end function createBackMenu(node, callback) -- 获得窗口的大小 local winSize = cc.Di
-- lua对象序列化 function serialize(obj) local lua = "" local t = type(obj) if t == "number" then lua = lua .. obj elseif t == "boolean" then lua = lua .. tostring(obj) elseif t == "string" then lua = lua .. string.forma