0
我有一個物理按鈕,我在現實生活中按下了這個Lua腳本。不過,如果我按下並按住按鈕,它會一遍又一遍地發送腳本,直到我放開按鈕。我能做些什麼來防止這種情況發生?如何防止這個Lua腳本被反覆發送?
commandSent = 0
enableDebug()
while true do
--if input turns on and command has not been sent, send command
if io.input1 == 1 and commandSent == 0 then
httpRequest("http://xxx.xxx.xx.xx/axis-cgi/virtualinput/activate.cgi?schemaversion=1&port=1",50)
print("input turned on")
sleep(50)
httpRequest("http://xxx.xxx.xx.xx/axis-cgi/virtualinput/deactivate.cgi?schemaversion=1&port=1",50)
commandSent = 1
end
--when input turns off, reset commandSent flag to 0
if io.input1 == 0 then
print("input turned off")
commandSent = 0
end
end
您在這裏工作的主機環境是?有利於加載和執行這個腳本,並改變'io.input1'的值?如何定義'sleep'和'httpRequest'?我們需要更多信息來制定任何合理的答案。 – Oka
我正在使用ControlByWeb的X600M。它通過他們的網絡界面構建了控件。上面的腳本只是訪問這些屬性。 –
我不在你的位置,所以我不確定如何實施,但你基本上想要反彈。當他們按下時,檢查變量「used」是否爲true,如果不是,則將其設置爲true並運行代碼。如果是,則什麼都不要做。現在有另一個功能,當他們從按鈕中移除壓力時,並將其設置爲假。 – warspyking