找回密码
 注册
搜索
楼主: syayas@tj

fqyy的lua笔记(1)------与或非运算

[复制链接]
门派:桃花岛
发表于 2018-7-6 16:47:24 | 显示全部楼层
支持風寫個完整的LUA 入門, 或許要跟MODMAN 那個合體
门派:天龙寺
发表于 2018-7-6 20:23:02 | 显示全部楼层
40多岁的人表示还想多活几年      
门派:少林派
发表于 2018-7-7 15:54:26 来自手机 | 显示全部楼层
这个必须要慢慢学习了   
门派:少林派
发表于 2018-7-7 15:55:10 来自手机 | 显示全部楼层
syayas@tj 发表于 2018-7-6 16:17
我水平有限,也只能讲讲简单的,算法数据 什么的再深我也不会了。
lua值得研究的东西挺多的,但目前不是 ...

看来风神你也是相关专业人士啊  
门派:少林派
发表于 2018-7-7 15:56:38 来自手机 | 显示全部楼层
syayas@tj 发表于 2018-7-6 16:40
mud的robot其实是lua里面最简单的应用,目前公版robot也是多年积累的打补丁方式写出来的,基本就是单线程, ...

是啊,就是这里的顺序看的比较头疼   
门派:古墓派
发表于 2018-7-7 15:58:23 | 显示全部楼层
woshicy@tj 发表于 2018-7-7 15:55
看来风神你也是相关专业人士啊

我不是,我只是爱好者 代码扔了10来年了,跟不上形式了
门派:古墓派
发表于 2018-7-7 16:30:25 | 显示全部楼层
公布答案
x= a and b or c    x=?    a=false  x=c 或者 a=true  x=b
x= a and b and c  x=?    a、b=true  x=c  或者 a=false  x=false
x= a or b or c      x=?    这个比较适合做robot, a取到真值返回a  如果a没取到b取到真值返回b,ab都没取到就返回c
门派:大轮寺
发表于 2018-7-7 22:06:49 | 显示全部楼层
大神能不能把这一段代码讲一下,function(func,p_cmd)  check_bei(job.prepare)




看得头都大了,还有,第二篇太难了,进去就懵逼,能先来点浅的吗


  1. prepare_neili=function(func,p_cmd)

  2.    local l_db
  3.    if func~=nil then
  4.       job.prepare=func
  5.    else
  6.       job.prepare=test   
  7.    end

  8.    tmp.db=p_cmd
  9.    l_db=1/2
  10.    if tmp.db and type(tmp.db)=="number" and tmp.db<2 then
  11.       l_db=tmp.db
  12.    end

  13.    if hp.neili>hp.neili_max*l_db and job.prepare~=test and job.prepare~=fight_prepare then
  14.       return check_bei(job.prepare)
  15.    end
  16.    
  17.    prepare_trigger()
  18.    EnableTriggerGroup("prepare_neili",true)
  19.    flag.jixu=1
  20.    exe('unset 积蓄')
  21.    flag.prepare=0
  22.    exe('yun jing;yun jingli;hp')
  23.       if job.zuhe["gblu"] and not locl.id["铜钱"] then exe('drop 1 coin') end
  24.          prepare_neili_a()
  25. end
  26. prepare_neili_at=function()
  27.    if tmp.prepare then job.prepare=tmp.prepare end
  28.    prepare_trigger()

  29.    if job.zuhe["gblu"] and not locl.id["铜钱"] then exe('drop 1 coin') end

  30.    EnableTriggerGroup("prepare_neili",true)
  31.    create_timer_s('neili',3,'prepare_neili_idle')
  32. end
  33. prepare_neili_a=function()
  34.    condition.busy=0
  35.    prepare_neili_idle()
  36.    if hp.qixue_per<50 and isInBags(drug.heal) then
  37.       exe('eat chantui yao')
  38.    end
  39.    create_timer_s('neili',3,'prepare_neili_idle')
  40. end
  41. prepare_neili_b=function()
  42.    if mydummy==true then
  43.    EnableTriggerGroup("prepare_neili",false)
  44.    DeleteTriggerGroup("prepare_neili")
  45.       return dummyfind()
  46.    end
  47.    if score.party=="普通百姓" and nobusy==0 and condition.busy~=nil and condition.busy>=100 and hp.pot>=60 then
  48.         if skills["literate"] and score.gold>1000 and skills["literate"].lvl<hp.pot_max-100 then
  49.                 return check_halt(literate)
  50.         elseif (skills["force"].lvl>200 and skills["force"].lvl<hp.pot_max-100) or (skills["dodge"].lvl>101 and skills["dodge"].lvl<hp.pot_max-100) or (skills["parry"].lvl>101 and skills["parry"].lvl<hp.pot_max-100) then
  51.                 return check_halt(lingwu)
  52.         end
  53.    end
  54.    if score.party~="普通百姓" and nobusy==0 and condition.busy~=nil and condition.busy>=100 and hp.pot>=60 then
  55.         if skills["literate"] and score.gold>1000 and skills["literate"].lvl<hp.pot_max-100 then
  56.                 return check_halt(literate)
  57.         elseif (skills["dodge"].lvl<450 and skills["dodge"].lvl<hp.pot_max-100) or (skills["parry"].lvl<450 and skills["parry"].lvl<hp.pot_max-100) or (skills["force"].lvl<450 and skills["force"].lvl<hp.pot_max-100) then
  58.                 return check_halt(xuexi)
  59.         elseif (skills["force"].lvl>=450 and skills["force"].lvl<hp.pot_max-100) or (skills["dodge"].lvl>=450 and skills["dodge"].lvl<hp.pot_max-100) or (skills["parry"].lvl>=450 and skills["parry"].lvl<hp.pot_max-100) then
  60.                 return check_halt(lingwu)
  61.         end
  62.    end
  63.    exe('yun qi;hp')
  64.    check_bei(prepare_neili_c)
  65. end
  66. prepare_neili_c=function()
  67.    local l_db=1/2
  68.    --if score.party and score.party=='峨嵋派' then
  69.    --   l_db=5/4
  70.    --end
  71.    --if perform.skill and perform.skill=="jieshou-jiushi" then
  72.    --   l_db=7/4
  73.    --end
  74.    if tmp.db and type(tmp.db)=="number" and tmp.db<2 then
  75.       l_db=tmp.db
  76.    end
  77.    
  78.    --if job.zuhe["wudang"] then l_db = 1 end

  79.    if not flag.prepare or type(flag.prepare)~='number' then flag.prepare=0 end
  80.    if condition.busy and condition.busy>20 and job.prepare and job.prepare~=test and flag.prepare>0 then flag.prepare=4 end
  81.    if condition.busy and condition.busy==0 and job.prepare and job.prepare~=test and flag.prepare>0 then flag.prepare=flag.prepare+5 end
  82.    if job.prepare==duHhe_start or job.prepare==duCjiang_start then flag.prepare=0 end
  83.    if flag.prepare>4 then flag.prepare=0 end
  84.    if (hp.neili>hp.neili_max*l_db or hp.jingli>hp.jingli_max) and flag.prepare==0 then
  85.       EnableTriggerGroup("prepare_neili",false)
  86.       DeleteTriggerGroup("prepare_neili")
  87.       DeleteTimer('neili')
  88.       exe('yun jing;yun qi;yun jingli')
  89.       check_bei(job.prepare)
  90.    else
  91.       prepare_neili_a()
  92.    end
  93. end
  94. prepare_neili_w=function()
  95.    locate()
  96.    check_bei(prepare_neili_g)
  97. end
  98. prepare_neili_g=function()
  99.    exe(locl.dir)
  100. end
  101. prepare_neili_t=function()
  102.    DeleteTimer('neili')
  103.    tmp.i=1
  104. end
  105. prepare_neili_idle=function()
  106.    local l_cnt=0
  107.    local l_db=3/2

  108.    for p in pairs(skills) do
  109.        if skillEnable[p] and skillEnable[p]=="force" then
  110.           tmp.fskill=p
  111.           break
  112.        end
  113.    end
  114.    if perform.force then
  115.       tmp.fskill=perform.force
  116.    end

  117.    if ((hp.neili_max>hp.neili_lim-20 and score.party and score.party=="峨嵋派") or hp.neili_max>=hp.neili_lim-5 or flag.jixu==1 or skills[tmp.fskill].full==0) and hp.neili>hp.neili_max*l_db then
  118.       if hp.neili>hp.neili_max*7/4 then
  119.          l_cnt=l_cnt + math.modf((hp.neili-hp.neili_max*7/4)/10)
  120.       end
  121.       l_cnt=l_cnt + math.modf(hp.neili_max/300)
  122.       if l_cnt<1 then l_cnt=1 end
  123.       lianxi(l_cnt)
  124.    end
  125.    if score.gold and score.gold>1000 and hp.neili<hp.neili_max*0.5 then
  126.       exe('eat '.. drug.neili)
  127.    end
  128.    exe('yun jingli;yun jing;yun qi')
  129.    if hp.jingli_max<hp.jingli_lim-500 and flag.lianxi==1 and hp.neili>hp.neili_max*l_db and ((hp.neili_max>hp.neili_lim-20 and score.party and score.party=="峨嵋派") or hp.neili_max>=hp.neili_lim-5 or flag.jixu==1) then
  130.       exe('unset 积蓄')
  131.       exe('tuna '..hp.jingxue/2)
  132.    else
  133.       --if score.party and score.party=="峨嵋派" and locl.room=="牛心石" then
  134.       --   exe('lianneili '..hp.dazuo)
  135.       --end
  136.         exe('unset 积蓄')
  137.       exe('dazuo '..hp.dazuo)
  138.    end
  139.    exe('cond')
  140. end
复制代码
门派:桃花岛
发表于 2018-7-7 22:41:06 | 显示全部楼层
学习学习,坚持打卡!                                         
门派:桃花岛
发表于 2018-7-7 22:42:13 | 显示全部楼层
fqyy@tj 发表于 2018-7-7 16:30
公布答案
x= a and b or c    x=?    a=false  x=c 或者 a=true  x=b
x= a and b and c  x=?    a、b=tru ...

三目运算是从右往左判断的?                        
您需要登录后才可以回帖 登录 | 注册

本版积分规则

Archiver|手机版|小黑屋|书剑永恒MUD ( 闽ICP备14012032号|闽公网安备 35050202000162号 )

GMT+8, 2025-6-10 16:06 , Processed in 0.018214 second(s), 22 queries .

Powered by Discuz! X3.5

© 2001-2025 Discuz! Team.

快速回复 返回顶部 返回列表