|
以下是我借用的路径搜索
function is_number(c_name)
local x,y=string.find(c_name,".*");
for x=1,y do
local b=string.byte(string.sub(c_name,x,x));
if ((b<48) or (b>57)) then
return false;
end
end
return true;
end
temp_slow_path_table={};
function fill_slow_path(path_name)
local i,v = string.find(path_dir_bianli_table[path_name],".*");
while i<=v do
if is_number(string.sub(path_dir_bianli_table[path_name],i,i+1)) then
for j=1,string.sub(path_dir_bianli_table[path_name],i,i+1) do
if nil~= path_dir_table[string.sub(path_dir_bianli_table[path_name], i+2, i+2)] then
table.insert(temp_slow_path_table, path_dir_table[string.sub(path_dir_bianli_table[path_name], i+2, i+2)].cmd);
else
table.insert(temp_slow_path_table, string.sub(path_dir_bianli_table[path_name], i+2, i+2));
end
end
i=i+3;
elseif is_number(string.sub(path_dir_bianli_table[path_name], i, i)) then
for j=1,string.sub(path_dir_bianli_table[path_name],i,i) do
if nil~= path_dir_table[string.sub(path_dir_bianli_table[path_name],i+1,i+1)] then
table.insert(temp_slow_path_table, path_dir_table[string.sub(path_dir_bianli_table[path_name],i+1,i+1)].cmd);
else
table.insert(temp_slow_path_table, string.sub(path_dir_bianli_table[path_name],i+1,i+1));
end
end
i=i+2;
else
if nil~= path_dir_table[string.sub(path_dir_bianli_table[path_name], i, i)] then
table.insert(temp_slow_path_table, path_dir_table[string.sub(path_dir_bianli_table[path_name], i, i)].cmd);
else
table.insert(temp_slow_path_table, string.sub(path_dir_bianli_table[path_name], i, i));
end
i=i+1;
end
end
end
function slow_path(path_name, time_wait)
if nil~= path_dir_bianli_table[path_name] then
fill_slow_path(path_name);
slow_path_thread=coroutine.create(function ()
for i,v in ipairs(temp_slow_path_table) do
world.DoAfterSpecial(time_wait, "slow_auto_next();",12);
coroutine.yield();
world.Send(v);
end
end);
coroutine.resume(slow_path_thread);
else
Note("你有这个搜索路径么");
end
end
slow_state=0;
function slow_pause()
slow_stat=1;
end
function slow_resume()
slow_stat=0;
slow_auto_next();
end
function slow_auto_next()
if slow_state==0 then
coroutine.resume(slow_path_thread);
end
end
function slow_path_Init()
world.AddAlias("al_slow_path","^\\#slow (.*?) (.*?)$",
"slow_path(\"%1\",%2);",
alias_flag.Enabled + alias_flag.Replace + alias_flag.RegularExpression,
"");
world.SetAliasOption("al_slow_path", "send_to", "12");
end
按照maper大哥的调用function slow_path(path_name, time_wait)函数使用,
我发现我遍历一个地方后,需要遍历第二的地方,会先遍历第一个地方再遍历我选择的地点,是不是代码哪里有问题哦?还是需要改变哪个参数让遍历重置 |
|