Skip to content

Commit 355fc20

Browse files
authored
Merge pull request #25 from kiccer/test
Test
2 parents 91057c3 + 07287eb commit 355fc20

File tree

3 files changed

+90
-15
lines changed

3 files changed

+90
-15
lines changed

README.md

+38-1
Original file line numberDiff line numberDiff line change
@@ -154,7 +154,44 @@ G键 | 功能
154154
`Beryl M762` | 直接切换至 `Beryl M762` 配置
155155
`DP-28` | 直接切换至 `DP-28` 配置
156156

157-
> 可以绑定至 `G_bind` ,使用预设的组合键触发指令
157+
> 可以绑定至 `G_bind` ,使用预设的组合键触发指令。
158+
> 注意:是指令绑定到组合键上,而不是组合键绑定到指令。请不要修改等号前面`[""]`中的内容!
159+
160+
### `G_bind` 指令绑定演示
161+
```lua
162+
-- G
163+
["G3"] = "",
164+
["G4"] = "",
165+
["G5"] = "",
166+
["G6"] = "5.56",
167+
["G7"] = "9mm",
168+
["G8"] = "7.62",
169+
["G9"] = ".45",
170+
["G10"] = "last",
171+
["G11"] = "next",
172+
173+
-- ✖,错误的修改方式
174+
["G3"] = "",
175+
["G4"] = "", -- 下面的 G4 会覆盖这个 G4,丢失了 G6 ,按下 G6 会出错。
176+
["G5"] = "",
177+
["G4"] = "5.56", -- 绝对不可以直接修改等号前面的组合键!
178+
["G7"] = "9mm",
179+
["G8"] = "7.62",
180+
["G9"] = ".45",
181+
["G10"] = "last",
182+
["G11"] = "next",
183+
184+
-- ✔,正确的修改方式
185+
["G3"] = "",
186+
["G4"] = "5.56", -- 把指令绑定到了这里
187+
["G5"] = "",
188+
["G6"] = "", -- 清空了这个指令
189+
["G7"] = "9mm",
190+
["G8"] = "7.62",
191+
["G9"] = ".45",
192+
["G10"] = "last",
193+
["G11"] = "next",
194+
```
158195

159196
### 硬件条件
160197
* 一只可编程 Logitech 鼠标(无线鼠标运行宏时很不稳定)

Soldier76.lua

+26-14
Original file line numberDiff line numberDiff line change
@@ -214,7 +214,7 @@ pubg.xLengthForDebug = pubg.generalSensitivityRatio * 60 -- 调试模式下的
214214
pubg.renderDom = {
215215
separator = "~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n", -- 分割线
216216
combo_key = "G-key", -- 组合键
217-
cmd = "", -- 指令
217+
cmd = "cmd", -- 指令
218218
autoLog = "No operational data yet.\n", -- 压枪过程产生的数据输出
219219
}
220220

@@ -774,7 +774,7 @@ end
774774
--[[ autputLog render ]]
775775
function pubg.outputLogRender ()
776776
ClearLog()
777-
OutputLogMessage(table.concat({
777+
local outputScriptMessage = table.concat({
778778
"\n>> [\"", pubg.renderDom.combo_key, "\"] = \"", pubg.renderDom.cmd, "\" <<\n",
779779
pubg.renderDom.separator,
780780
pubg.outputLogGunSwitchTable(),
@@ -783,7 +783,16 @@ function pubg.outputLogRender ()
783783
pubg.renderDom.separator,
784784
pubg.renderDom.autoLog,
785785
pubg.renderDom.separator,
786-
}))
786+
})
787+
OutputLogMessage(outputScriptMessage)
788+
789+
-- local file = io.open('C:\\Soldier76_outputScriptMessage.json', 'w+')
790+
-- file:write(table.concat({
791+
-- "{\n",
792+
-- "\toutputScriptMessage: '", outputScriptMessage, "'\n",
793+
-- "}\n",
794+
-- }))
795+
-- file:close()
787796
end
788797

789798
--[[ Output switching table ]]
@@ -864,16 +873,8 @@ function pubg.autoLog (options, y)
864873
pubg.renderDom.autoLog = resStr
865874
end
866875

867-
--[[ Listener method ]]
868-
function OnEvent (event, arg, family)
869-
870-
-- Whether to open the capitalization key or not
871-
if not pubg.ok then return false end
872-
873-
-- OutputLogMessage("event = %s, arg = %s, family = %s\n", event, arg, family)
874-
-- OutputLogMessage("event = " .. event .. ", arg = " .. arg .. ", family = " .. family .. "\n")
875-
876-
-- Automatic press gun
876+
--[[ Automatic press gun ]]
877+
function pubg.OnEvent_NoRecoil (event, arg, family)
877878
if event == "MOUSE_BUTTON_PRESSED" and arg == 1 and family == "mouse" and pubg.ok then
878879
if not pubg.runStatus() then return false end
879880
if pubg.isAimingState("ADS") or pubg.isAimingState("Aim") then
@@ -892,10 +893,21 @@ function OnEvent (event, arg, family)
892893
end
893894

894895
if event == "M_PRESSED" and arg == 1 and pubg.G1 and pubg.ok then
895-
-- PressAndReleaseMouseButton(1)
896896
pubg.auto(pubg.gunOptions[pubg.bulletType][pubg.gunIndex])
897897
SetMKeyState(1)
898898
end
899+
end
900+
901+
--[[ Listener method ]]
902+
function OnEvent (event, arg, family)
903+
904+
-- Whether to open the capitalization key or not
905+
if not pubg.ok then return false end
906+
907+
-- OutputLogMessage("event = %s, arg = %s, family = %s\n", event, arg, family)
908+
-- OutputLogMessage("event = " .. event .. ", arg = " .. arg .. ", family = " .. family .. "\n")
909+
910+
pubg.OnEvent_NoRecoil(event, arg, family)
899911

900912
-- Switching arsenals according to different types of ammunition
901913
if event == "MOUSE_BUTTON_PRESSED" and arg >=3 and arg <= 11 and family == "mouse" and pubg.ok then

test/MoveMouseTo.lua

+26
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
local test = false
2+
3+
local x, y
4+
5+
function loop ()
6+
for i = 1, 500 do
7+
if IsMouseButtonPressed(1) then
8+
x, y = GetMousePosition()
9+
y = y + 100
10+
MoveMouseTo(x, y)
11+
Sleep(20)
12+
end
13+
end
14+
end
15+
16+
function OnEvent(event, arg, family)
17+
if not test then return false end
18+
--OutputLogMessage("event = %s, arg = %s\n", event, arg);
19+
if not IsKeyLockOn("capslock") then return false end
20+
if event == "MOUSE_BUTTON_PRESSED" and arg == 1 and family == "mouse" then
21+
loop()
22+
end
23+
24+
end
25+
ClearLog()
26+
EnablePrimaryMouseButtonEvents(true) -- Enable left mouse button event reporting

0 commit comments

Comments
 (0)