|
发表于 2014-10-28 21:30:56
|
显示全部楼层
本帖最后由 littleknife 于 2014-10-28 09:37 PM 编辑
哈哈。遍历有啊。好多遍历方法的。不过不是城际互联插件里的。
机器人应用层框架代码可以参考如下内容:- TestMOD={
- new=function()
- local _TestMOD={}
- setmetatable(_TestMOD,{__index=TestMOD})
- return _TestMOD
- end,
- interval=5,
- timeout=20,
- help="格式:帮助文件",
- -------------------------------------
- Sleeproomno=player.Sleeproomno,
- Eatfoodroomno=player.Eatfoodroomno,
- Trainingroomno=player.Trainingroomno,
- -------------------------------------
- aimroomno="",
- aimroomname="",
- -------------------------------------
- jobnpcname="",
- jobnpcid="",
- jobnpcmenpai="",
- jobwords="",
- }
- function TestMOD:finish()
- end
- function TestMOD:fail()
- end
- TestMOD_button=function()
- print(TestMOD.help)
- SetCommandSelection (1, -1)
- PasteCommand("#TestMOD ")
- end
- TestMOD_alias=function(name, line, wildcards)
- do_TestMOD(wildcards,TestMOD_ok,TestMOD_fail)
- end
- do_TestMOD=function(wildcards,TestMOD_ok,TestMOD_fail)
- local tmp_TestMOD=TestMOD.new()
- tmp_TestMOD.finish=TestMOD_ok
- tmp_TestMOD.fail=TestMOD_fail
- tmp_TestMOD:start(wildcards)
- end
- function TestMOD:start(wildcards)
- wait.make(function()
- self:update()
- local f=function() self:check(wildcards) end
- getinfo(f)
- end)
- end
- function TestMOD:check(wildcards)
- local askjob=function() self:askcmd() end
- local endf=function()
- do_walkgo(self.masterroomno,0.2,askjob,askjob)
- end
- if me.hp["neili"]<=1.2*me.hp["neilimax"] then
- do_dazuo(1.2,"curmaxneili",endf,endf)
- else
- busytest(endf)
- end
- end
- function TestMOD:askcmd()
- end
- function TestMOD:cooltime()
- end
- function TestMOD:main()
- end
- -----------------------------------------------
- function TestMOD:dosomething1(n,l,w)
- end
- function TestMOD:dosomething2()
- end
- function TestMOD:dosomething3()
- end
- function TestMOD:dosomething4()
- end
- -----------------------------------------------
- function TestMOD:update()
- local TestMOD_triggerlist={
- {name="TestMOD_dosth1",regexp="Here is trigger1 RegularExpression",script=function(n,l,w) self:dosomething1(n,l,w) end,},
- {name="TestMOD_dosth2",regexp="Here is trigger2 RegularExpression",script=function() self:dosomething2() end,},
- {name="TestMOD_dosth3",regexp="Here is trigger3 RegularExpression",script=function() self:dosomething3() end,},
- {name="TestMOD_dosth4",regexp="Here is trigger4 RegularExpression",script=function() self:dosomething4() end,},
- }
- ---Creat Trigger-->>
- for k,v in pairs(TestMOD_triggerlist) do
- addtri(v.name,v.regexp,"q_TestMOD",v.script)
- end
- ---End Creat Trigger--<<
- local noecho_trilist={
- "noecho_tri1",
- "noecho_tri2",
- }
- local _noechotri=linktri(noecho_trilist)
- addtri("TestMOD_noecho",_noechotri,"q_TestMOD","")
- SetTriggerOption("TestMOD_noecho","omit_from_output",1)
- EnableTriggerGroup("q_TestMOD",1)
- end
- AddAlias("alias_TestMOD_button","#TestMOD_button","",alias_flag.Enabled + alias_flag.Replace ,"TestMOD_button")
- AddAlias("alias_TestMOD","#TestMOD (.*)","",alias_flag.Enabled + alias_flag.Replace+ alias_flag.RegularExpression ,"TestMOD_alias")
- SetAliasOption("alias_TestMOD","group","job_TestMOD")
- SetAliasOption("alias_TestMOD_button","group","job_TestMOD")
复制代码
- addtri=function(triname,trimatch,trigroup,triscript,triflag,trisequence)
- if triflag==nil or triflag=="" then triflag=flag_base_enable end
- if trisequence==nil then trisequence=10 end
- if type(triscript)=="string" then
- tri_returnvalue=check(AddTriggerEx(triname, trimatch, "", triflag, -1, 0, "", triscript, 0, trisequence))
- end
- if type(triscript)=="function" then
-
- local Addtri_fun = "addtri_" .. GetUniqueNumber ()
- _G [Addtri_fun] = triscript
- tri_returnvalue=check(AddTriggerEx(triname, trimatch, "", triflag, -1, 0, "", Addtri_fun, 0, trisequence))
- end
- SetTriggerOption(triname,"group",trigroup)
- return tri_returnvalue
- end
复制代码
关键你得能看明白。呵呵。 |
|