求助:为G402(罗技鼠标)编写脚本遇到错误,非语法
lua吧
全部回复
仅看楼主
level 1
错误:[string "LuaVM"]:119:attempt to index global 'io'(a nil value)
代码:
function OnEvent(event,arg)
bEnable=false---避免瞬间多按造成的互相干扰
bCycle=true--循环开关
count_Left=0--用于左键连击标记
count_Right=0--用于右键连击标记
count_Hammer=0--用于锤子连击标记
count_Explode=0--用于血猎驽执行标记
mytable={}
Config_Read()
co1=coroutine.create(
function()
repeat
coroutine.resume(co2)
coroutine.yield(c02)
coroutine.resume(co3)
coroutine.yield(c03)
until(bCycle)
end
)
co2=coroutine.create(
function()
MAIN()
end
)
co3=coroutine.create(
function()
Config_Read()
for k,v in pairs(mytable) do
if(v>0 and v%2==0) then
return
end
end
--[[if(count_Left>0 or count_Right>0 or count_Middle>0 or count_Hammer>0 or count_Explode>0) then
return
end]]
end
)
coroutine.resume(co1)
end
--主功能
function MAIN()
if(event == "MOUSE_BUTTON_PRESSED" and arg == 3 and bEnable == false) then
bEnable=true
count_Hammer=count_Hammer+1
mytable["hammer"]=count_Hammer
Config_Write()
HammerHit()
end
if(event == "MOUSE_BUTTON_PRESSED" and arg == 4 and bEnable == false) then
bEnable=true
mytable["explode"]=count_Explode
Config_Write()
ContinuousExplode()
end
if(event == "MOUSE_BUTTON_PRESSED" and arg == 5 and bEnable == false) then
bEnable=true
mytable["right"]=count_Right
Config_Write()
ContinuousRightButton()
end
if(event == "MOUSE_BUTTON_PRESSED" and arg == 7 and bEnable == false) then
bEnable=true
mytable["left"]=count_Left
Config_Write()
ContinuousLeftButton()
end
end
--锤子连击
function HammerHit()
--repeat
PressKey("3")
ReleaseKey("3")
Sleep(170)
PressMouseButton(3)
ReleaseMouseButton(3)
Sleep(480)
PressKey("q")
ReleaseKey("q")
bEnable=false
--until(count>1)
count=0
end
--左键连点
function ContinuousLeftButton()
PressMouseButton(1)
Sleep(10)
ReleaseMouseButton(1)
bEnable=false
end
--右键连点
function ContinuousRightButton()
PressMouseButton(3)
Sleep(10)
ReleaseMouseButton(3)
bEnable=false
end
--血猎重驽瞬爆
function ContinuousExplode()
PressMouseButton(1)
ReleaseMouseButton(1)
Sleep(10)
PressMouseButton(3)
ReleaseMouseButton(3)
Sleep(10)
bEnable=false
end
--C:\Users\Administrator\Desktop
--读取配件文件
function Config_Read()
print("读取开始")--测试用
local file=io.open("cs_config.txt","r")
if(file==nil) then
file=io.open("cs_config.txt","w")
local array={"left 0","right 0","hammer 0","explode 0"}
io.output(file)
for i=1,4 do
io.write(string.format("%s\n",array[i]))
end
io.close(file)
else
for k,v in lines(cs_config.txt) do
mytable[k]=v
if(k=="left") then
count_Left=v
if(k=="right") then
count_Right=v
if(k=="hammer") then
count_Hammer=v
else
count_Explode=v
end
end
end
end
end
end
--写入配件文件
function Config_Write()
local file=io.open("cs_config.txt","w")
io.output(file)
for k,v in pairs(mytable) do
io.write(k," ",v,"\n")
end
end
自己网上找一下相关资料,大概说可能是不允许调用io库,有没有具体知道细节和解决办法的大神!拜谢!!!
2019年09月07日 01点09分 1
level 1
我会再试试第三方的,谢谢提示!
2019年09月20日 15点09分 3
level 2
大佬能教教我吗[小乖]
2019年09月26日 04点09分 4
level 1
大哥我用你的bEnable=false,怎么实现不了防止瞬间多按互相影响啊
2023年08月11日 06点08分 5
1