|
发表于 2015-5-1 20:15:11
|
显示全部楼层
本帖最后由 littleknife 于 2015-5-1 08:17 PM 编辑
引自【武林MUD】的一段代码,这里就是要说一下,不要着急的用wait.make框架。因为很多时候并不是一定用要协程解决问题,顺序执行即可。
- Me.check_state = function(f)
- Execute("hp;set keep_idle hp");
- local l, w = wait.regexp("^【 精 气 】\\s*(\\d+)\\/\\s*(\\d*)\\s*\\(\\s*(\\d*)\\%\\)\\s*【 精 力 】\\s*(\\d*)\\s*\\/\\s*(\\d*) \\(\\+(\\d*)\\)$")
- Me.mp, Me.maxmp, Me.pmp, Me.mana, Me.maxmana = tonumber(w[1]), tonumber(w[2]), tonumber(w[3]), tonumber(w[4]), tonumber(w[5])
- l, w = wait.regexp("^【 气 血 】\\s*(\\d+)\\/\\s*(\\d*)\\s*\\(\\s*(\\d*)\\%\\)\\s*【 内 力 】\\s*(\\d*)\\s*\\/\\s*(\\d*) \\(\\+(\\d*)\\)$")
- Me.hp, Me.maxhp, Me.php, Me.force, Me.maxforce, Me.enforce = tonumber(w[1]), tonumber(w[2]), tonumber(w[3]), tonumber(w[4]), tonumber(w[5]), tonumber(w[6])
- l, w = wait.regexp("^【 食 物 】\\s*(\\d*)\\/\\s*(\\d*)\\s*【 潜 能 】\\s*(\\d*)\\s*$")
- Me.food, Me.maxfood, Me.pot = tonumber(w[1]), tonumber(w[2]), tonumber(w[3])
- l, w = wait.regexp("^【 饮 水 】\\s*(\\d*)\\/\\s*(\\d*)\\s*【 体 会 】\\s*(\\d*)\\s*$")
- Me.water, Me.maxwater, Me.tihui = tonumber(w[1]), tonumber(w[2]), tonumber(w[3])
- l, w = wait.regexp("^【 等 级 】\\s*(\\d*)\\s*【 经 验 】\\s*(\\d*)\\s*$")
- Me.level, Me.exp = tonumber(w[1]), tonumber(w[2])
- wait.regexp ("^(> )*设定环境变数:keep_idle = "hp"$")
- if f then f() end
- end
复制代码 |
|