你们能帮帮我吗,我已经添加了一个旗帜,但是它跳过了远程传送()而继续向南走()知道为什么吗?我是个新手,希望你们能帮我
walk1 := 0
loop {
teleport()
}
teleport()
{
if (walk1 => 1) ;this never worked even i added flag walk1:=1 :( please help
send, {f9}
sleep, 500
walk1 := 0
return
} else if (walk1 <= 0){
walksouth()
return
}
}
walksouth() { ;this keeps running and skipping teleport()
send, {f5}
sleep, 500
walk1 := 1 ;added flag 1 to run the teleport, but still skipping
return
}发布于 2017-11-06 22:40:20
这是经过更正和重构的代码:
walk := false
loop {
teleport()
}
teleport()
{
global walk
if (walk) {
send {f9}
walk := false
} else {
send {f5}
walk := true
}
sleep 500
}代码中的错误:
函数中的
global声明它们。因此,在if (walk1 => 1)之后,函数中的walk1变量和全局walk1都是不同的,缺少一个左花括号{
https://stackoverflow.com/questions/47135733
复制相似问题