随笔分类 -  lua相关

遇到大段ifelse不要慌,先分层让条件正交
摘要:因为一直在写Lua所以会遇到很多if else的逻辑。 遇到大段大段的else if逻辑会很难理解。 这让我想起了和else if 比较相似的语法switch 在语法上switch后判断的是某一个参量的条件 比如 switch(a) { case a满足条件1: case a满足条件2: } 而if 阅读全文

posted @ 2021-07-08 18:20 毛尹航 阅读(126) 评论(0) 推荐(0)

一个可以用的Lua的Class函数
摘要:function SetMetaTableIndex(t, index) if t == nil or index == nil then error return end local mt = getmetatable(t) if not mt then mt = {} end if not mt 阅读全文

posted @ 2021-07-08 18:06 毛尹航 阅读(179) 评论(0) 推荐(0)

写一个可以用的Lua打印Table的函数
摘要:function PrintTable(node) if not node or type(node) ~= "table" then return tostring(node) end local depthBufferHelper = {} local function tab(amt) if 阅读全文

posted @ 2021-07-08 18:05 毛尹航 阅读(626) 评论(0) 推荐(0)