你们可以帮助我吗,我已经添加了一个标志,但是它会跳过teleport()并且一直在想着为什么?我在这里有点新手我希望你们帮帮我
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
}
答案 0 :(得分:0)
这是您已更正并重构的代码:
walk := false
loop {
teleport()
}
teleport()
{
global walk
if (walk) {
send {f9}
walk := false
} else {
send {f5}
walk := true
}
sleep 500
}
代码中的错误:
global
声明它们。因此,函数中的walk1
变量和全局walk1
都是不同的变量{
(walk1 => 1)