随笔分类 - Lua
摘要:ocal a = "喂(你好)吗" local b = "喂(你好)" local s,e = string.find(a,b) print("s "..s) print("e "..e) 这样会提示 attempt to concatenate local 's' (a nil value) local a = "喂你好吗" local b = "喂你好" local s,e = string.find(a,b) print("s "..
阅读全文
摘要:--[[serialize.lua声明序列化接口,并提供serialize和unserialize函数用于对Table对象进行序列化和反序列化操作Exported API:Example:--]]require "base.interface"Serializable = interface(nil, "writeObject", "readObject")----------------------------------------------------------------------------------序列化一个Tab
阅读全文
摘要:local a = 1local b = ","local c = 2local str = tostring(a)..tostring(b)..tostring(c)print(str)1,2
阅读全文
摘要:string to inttonumberprint(tonumber("1234"))
阅读全文
摘要:function FGUtilStringSplit(str,split_char) ------------------------------------------------------- -- 参数:待分割的字符串,分割字符 -- 返回:子串表.(含有空串) local sub_str_tab = {}; while (true) do local pos = string.find(str, split_char); if (not pos) then sub_str_tab[#sub_str_tab + 1] = str; break; end local sub...
阅读全文
摘要:C++代码void CProject1Dlg::OnBnClickedButton2(){ // 打开换为 luaL_newstate lua_State *L = luaL_newstate() ; /* 打开 Lua */ luaL_openlibs(L); /* 加载 .lib 文件 */ // 加载脚本文件,需要放在程序目录 luaL_loadfile( L, "test.lua" ); lua_resume( L, 0 , 0); typedef struct { int a; CString strTest; struct test { int b; }c; }
阅读全文
摘要:http://blog.csdn.net/witch_soya/article/details/7556595
阅读全文
摘要:http://blog.csdn.net/favormm/article/details/5796587http://www.cnblogs.com/osyun/tag/tolua/
阅读全文
摘要:tolua++ 配置看到很多方法将lua和c++结合的办法,由于看到cegui使用的是tolua++,所以决定使用tolua++。1、下载tolua++www.codenix.com/~tolua/2、找到 tolua++-1.0.93\win32\vc7文件夹,编译程序生产tolua++.exe(我用的include和lib都是cegui里的,统一版本比较好)3、测试tolua++(下面是参照他人的http://blog.csdn.net/foruok/archive/2008/04/17/2301751.aspx)创建tarray.pkg文件:$#include "tarray.
阅读全文
摘要:http://blog.csdn.net/lqk1985/article/details/7190971
阅读全文
摘要:Account = {balance = 0}function Account:new (o) o = o or {} setmetatable(o, self) self.__index = self print("This is Base") return oendfunction Account:deposit (v) self.balance = self.balance + vendfunction Account:withdraw (v) if v > self.balance then error"insufficient funds"
阅读全文
摘要:local _class={}function class(super) local class_type={} class_type.ctor=false class_type.super=super class_type.new=function(...) local obj={} do local create create = function(c,...) if c.super then create(c.super,...) end if c.ctor then c.ctor(obj,...) end e...
阅读全文
摘要:逻辑运算符认为false和nil是假(false),其他为真,0也是true.and的优先级比or高其它语言中的and表示两者都为真的时候,才返回为真,而只要有一个假,都返回假.lua虽不仅返回假的语义,还返回导致假的值.也就是说a and b在a为false的时候,返回a,否则返回b.or的处理与之类似,a or b在a为true的时候,返回a,否则返回b.总之,and与or返回的不仅有true/false的语义,还返回了它的值.a = nil b = 1 exp = 1 < 2 and a or b print(exp == a) --fales exp = 1 > 2 and
阅读全文
摘要:local _a1 = {20, 1, key1 = "hello", key2 = "world", lang = "lua"} print("the table _a1:") for _,v in pairs(_a1) do print(v) end local _a2 = { key1 = "hello new", key2 = "world new" } print("\nthe old table _a2:") for _,v in pairs(
阅读全文
摘要:Lua游戏脚本热更新机制 ¶设计要点¶能够在服务器运行期间更新程序逻辑代码以实现修正程序Bug、修改游戏数据的目的。游戏框架代码的热更新暂不考虑。例如:某个业务处理函数逻辑有Bug,服务器运营期间发现,在不停机情况下及时更新代码修复。 技能数值表策划填写出现手误错误,导致玩家战斗异常,在不停机情况下及时更新内存中的数值表。 更新代码时要保护非代码数据,尽量不用重新载入存盘数据。例如:登陆用户列表保存在内存中,用户登录模块出现bug需要跟新代码,此段代码更新后,用户列表依然有效,在线用户不受影响。 常见方案¶lua的module机制¶require 会阻止
阅读全文
摘要:在线参考手册:http://www.osctools.net/apidocs/apidoc?api=lua博客:http://blog.csdn.net/linkerlin/article/category/380213Lua手册中文版在线学习:http://www.lisdn.com/html/79/category-catid-379-page-8.htmlhttp://www.lua.org Lua 官方网站http://www.luajit.org Lua JIT 项目http://www.luaer.cn 中国lua开发者http://bbs.luaer.cn lua交流论坛http
阅读全文
摘要:--服务器的当前时间local nNowHour = os.date("%H")local nNowMin = os.date("%M")local nNowSec = os.date("%S")local nNowTime = nNowHour*3600+nNowMin*60+nNowSecprint(nNowTime)local BossID = {100 ,200 }local HurtStruct = {nRoleID,nHurt}local BossTime ={ [100] = { --12:00-12:30 nFirst
阅读全文
摘要:local BossID = {100,200}local WorldBossHurt = { [100] = {}, [200] = {}}for i=1,10,1 do local RoleList = {nRoleID = 20000,nHurt = 40} RoleList.nRoleID = RoleList.nRoleID+i RoleList.nHurt = RoleList.nHurt+i table.insert(WorldBossHurt[100],RoleList) table.insert(WorldBossHurt[200],RoleList) print(RoleL
阅读全文