0
焦点头条

【小雪】插件制作教学系列(一)《一切都从零开始》

2014-02-23 13:06| 查看: 13517 |作者: 小雪



循环句式:
for 循环变量 = 初值,终值,每次的增量 do
语句块
end
for循环是插件中常用的一种循环方式,for在这里可以理解为"在...时候",上面语句可以理解为:在循环变量从初值到终值,根据增量每次改变的时候时候,执行语句。这类型的语句主要是用于需要多次重复执行的命令,比如说循环小队成员找到相应的人物名字。

例:
for i = 1,10,2 do
print(i)
end
打印结果为:1,3,5,7,9
每次的增量如果没有写,就表示默认是1。

for i = 20,-10,-5 do
print(i)
end
打印结果为:20,15,10,5,0,-5,-10
in pairs的运用:

假设我们有个表格:
表格t:
11
25
312
520

我们想要打印出这个表格右边的数字,那么就这样写:t={[1]=1,[2]=5,[3]=12,[5]=20}for i,v in pairs(t) doprint(v)end打印结果为:1,5,12,20 in pairs指的是i,v成对地,这个的意思就是说,在i,v于表格t中成对的时候:即i为第一列,v为第二列,打印v。因为我们表格是双列表格,所以成对是绝对成立的,于是就导出所有第二列的数值。

函数封装:关于函数封装这个问题简单说一下。 
function 函数名(参数列表)
语句块
end 
这个的作用就是将代码打包,方便在其他地方进行调用,同时也是方便调试的时候找错并且修改。 
例: 
function Compare(a,b) 
if a>b then              
print(a) 
elseif b>a then 
print(b) 
elseif a==b then 
print("相等的") 
end
end 

上面是个简单的比较大小的。
尝试调用一下: 
Compare(1,9) =>9 
Compare(8,2) =>8 
Compare(3,3) =>相等的 
Compare(a,z) =>z
Compare("你好","不好") =>你好 
Compare("你好","你号") =>你号
剑三中的一些常用API:B叔说,我们跟系统是用函数进行沟通,但是彼此之间并不同步。比如说我的函数说:“你是谁?”,而系统函数却回复:“那座山很高。”。API就是系统告诉我们他会什么语言,我们便要说他懂得语言来进行沟通。以下为比较常见的一些API:
  • GetClientPlayer()
  • 获取本机的player对象。
  • GetNpc(dw)
  • 获取npc对象,参数为NPCID。
  • GetPlayer(dw)
  • 获取一个player对象,参数为playerID。
  • GetDoodad(dw)
  • 获取一个Doodad对象,参数为doodad的ID
  • RegisterEvent(sz,function)
  • 注册一个客户端事件,可以在Event()函数中响应它。参数为事件名,响应时间的函数。当它作为一个全局函数使用的时候,由于脚本程序是由上至下逐行解释的,所以一定要把响应事件的函数定义在它的前面。
  • RegisterCustomData(sz)
  • 注册一个用户数据,参数是数据名。
  • GetTarget()
  • 获取目标,返回值为目标类型,目标ID
  • GetTargetHandle(tType,tID)
  • 获取目标,参数为目标类型,目标ID
  • GetKungfuMount()
  • 获取当前装备内功,返回值为内功ID
  • GetSkillPrepareState()
  • 获取技能准备状态,返回值为四个,是否在吟唱,技能ID,技能等级,读条进度
  • GetCharacterDistance(dwID,dwID)
  • 获取两者之间的距离,需要除以64方为真正距离,参数为两者的ID
  • GetClientTeam()
  • 获取客户端玩家默认小队代号
  • GetClientTong()
  • 获取客户端玩家默认帮会代号
  • OnFrameCreate(),OnFrameBreathe()
  • 上面这两个事件实际上是两个函数,当遇到插件创建事件时会调用OnFrameCreate()。一般在没有特殊设置的情况下,当界面窗口可见时,会每秒调用16次OnFrameBreathe()函数。下面是一个API的列表,剑三所开放的白名单

收藏 分享 邀请

游客 2016-05-16 10:41
mi9VMU You produced  ...
引用
游客 2016-05-14 03:17
You have brought up  ...
引用
游客 2016-04-06 01:43
bYohsZ very couple o ...
引用
游客 2016-03-31 18:45
bjfls4 Wow, great ar ...
引用
游客 2016-01-31 02:30
AWZu3D ugg australia ...
引用
游客 2016-01-01 20:43
boQTg6
引用
游客 2015-02-26 22:14
RqaqJn  <a href="htt ...
引用
游客 2014-11-23 07:13
紫檀手串的价值也是很大的:在本草纲目上就有记载,紫檀能够止痛止血,还能够调节气血;紫檀木所散发出来的香气对人们的心脏肾脏肝脏有很好的调节保养作用;紫檀手串戴在身上,还能够稳定人的情绪,使人遇事平静、沉稳,还有助于睡眠和安神醒脑,长期佩戴能够促进新细胞再生,预防皱纹的出现;紫檀对肠胃也很好,有的人就是把紫檀屑放到枕芯里当抱枕睡觉,对肠胃有很好的舒缓作用;在蒙古族的医学上还有记载,紫檀能够消除关节肿痛,和 ...
引用
游客 2014-09-28 10:26
1、春天,山坡的朝阳处雪开始融化,慢慢地露出黄黑色的地皮;雪水滋润着泥土,浸湿了去年的草楂;被雪盖着过了冬眠的草根苏醒复活了,渐渐地倔强有力地推去陈旧的草楂烂叶,奋力地生长起来。与此同时,去年秋天随风摇落下来的草木种子,也被湿土裹住,在孳殖着根须,争取它们的生命。山的背阴处虽然还寒气凛凛,可是寒冷的威力已在渐渐衰弱。朝阳处的温暖雪水顺着斜谷流过来,融化了硬硬的雪层,开始冲开山涧溪水的冰面。巨大的冻 ...
引用
游客 2014-09-28 06:27
每到春天,红得如火的木棉花,粉得如霞的芍药花,白得如玉的月季花竞相开放。它们有的花蕾满枝,有的含苞初绽,有的昂首怒放。一阵阵沁人心肺的花香引来了许许多多的小蜜蜂,嗡嗡嗡地边歌边舞。 <br><br>盼望着,盼望着,(表现急切喜悦的心情)东风来了,春天的脚步近了。 <br><br>清晨,春姑娘穿着美丽的衣裳,舞着暖风,招展地笑着向我们走来,给大自然披上了新装,使万物显现出无限生机.一缕缕金黄色的阳光撒向刚披上新装的草地,阳 ...
引用
游客 2014-09-24 20:58
ahF8QM I have been absent for some time, but now I remember why I used to love this blog. Thanks , I'll try and check back more frequently. How frequently you update your site?
引用
游客 2014-08-26 06:10
A lot of thanks for each of your work on this web site. My mom really loves going through investigation and it is simple to grasp why. Many of us notice all relating to the dynamic ways you make invaluable information by means of this web blog and even cause response from others on the issue so our favorite princess is certainly studying a whole lot. Take advantage of the remaining portion of the  ...
引用
游客 2014-08-09 08:42
I have been exploring for a bit for any high quality articles or blog posts on this kind of area . Exploring in Yahoo I at last stumbled upon this site. Reading this information So i¡¦m happy to convey that I've a very just right uncanny feeling I discovered exactly what I needed. I most indisputably will make sure to don¡¦t overlook this website and provides it a glance regularly.
gebrauchte  ...
引用
游客 2014-08-08 21:10
What i don't understood is actually how you are no longer really a lot more smartly-liked than you might be right now. You're so intelligent. You already know therefore considerably in terms of this topic, produced me individually consider it from a lot of varied angles. Its like women and men are not involved unless it is one thing to accomplish with Lady gaga! Your own stuffs nice. All the time  ...
引用
游客 2014-08-08 20:06
Good ¡V I should certainly pronounce, impressed with your site. I had no trouble navigating through all the tabs and related info ended up being truly simple to do to access. I recently found what I hoped for before you know it at all. Quite unusual. Is likely to appreciate it for those who add forums or something, website theme . a tones way for your customer to communicate. Excellent task..
Che ...
引用
游客 2014-08-04 14:04
I would like to convey my gratitude for your generosity supporting men and women who really need help with your theme. Your personal commitment to passing the solution up and down ended up being amazingly interesting and have consistently empowered many people just like me to get to their aims. Your useful help signifies a whole lot to me and even more to my colleagues. Thanks a lot; from all of u ...
引用
n5012346 2014-07-05 11:49
: Well written. Who's number four? Lately Ive been following Damon Vickers, a finacial luminary from Seattle. If you havnt read his book The Day after t ...
oh ·····can you speak  Chinese?
引用
游客 2014-07-05 09:01
有剑网三pak v3的解包工具么?
引用
游客 2014-06-18 04:52
Well written. Who's number four? Lately Ive been following Damon Vickers, a finacial luminary from Seattle. If you havnt read his book The Day after the Dollar Crashes, you should get plan a trip to the bookstore. I feel that people dont really fathom the magnitude of the situation we face today. To have a great manager like Damon Vickers, who called the market plummet in both 2000 and 2008, publi ...
引用
游客 2014-04-14 15:47
请问一下有没有交流群?
引用

查看全部评论(20)

关注订阅号"剑网3PVE"
获取第一手剑三资讯

关闭
您当前使用的浏览器版本过低,网站部分功能可能失效,请更换合适的浏览器。了解更多
返回顶部