|
Page 1 of 1
|
[ 2 posts ] |
|
FlagShip, Recorder & Replayer
| Author |
Message |
|
Vaasref
Joined: Apr 3rd, '13, 05:56 Posts: 2
|
 FlagShip, Recorder & Replayer
FlagShip v1.0by Vaasref Record a track and replay it I did FlapShip for record and let my computer do SWToR space battle for me. And it do the job. FlagShip work in two part, the first one is the core, FlagShip.mms wich record some keyboard strokes and mouse clicks and moves. When you stop FlagShip it will save the record in FlagShip_Astromech.mms as a launchable script which will reproduce the record. Since it's my firt Lua script, it's raw, but it work. How to use it:Using FlagShip script- First, if it doesn't exist create "FlagShip_Astromech.mms" file in the MM folder
- Launch "FlagShip.mms"
- Press Left Control, FlagShip will start recording when you release it
- Do what you want to record
- Press Left Control, FlagShip will save the record and close
Note: Due to weird behavior it doesn't record the Left mouse button, it will record the Numpad1 key as the Left mouse button. So if you want to record the Left mouse button use some other script (a GlovePIE one) to map the Left mouse button as the Numpad1 key Using a FlagShip_Astromech script- Lauch the FlagShip_Astromech script
- Press Left Control, FlagShip will start play when you release it
- If you want to stop the script, press Left Control
- If you want to play the scipt again, press Left Control
What keys are recorded:- Left mouse button with the Numpad1 key (see note above)
- Right mouse button
- 1, 2, 3, 4 keys (not numpad ones)
- Numpad0 key
- Up
- Left
- Down
- Right
Script:FlagShip.mmsCode: while input.KeyGetState(input.VK_LCONTROL) == 0 do time.Sleep(0.1) end while input.KeyGetState(input.VK_LCONTROL) == 1 do time.Sleep(0.01) end local lastTime = math.floor(os.clock()*1000+0.5) local first = true local x, y = input.MouseGetPos() local file = assert(io.open("FlagShipAstromech.mms", "w")) local str = "local frame = {" local actions = "" local keys = {{input.VK_NUMPAD1, input.MOUSE_LEFT, 0}, {input.MOUSE_RIGHT, input.MOUSE_RIGHT, 0}, {input.VK_UP, input.VK_UP, 0}, {input.VK_DOWN, input.VK_DOWN, 0}, {input.VK_LEFT, input.VK_LEFT, 0}, {input.VK_RIGHT, input.VK_RIGHT, 0}, {0x31, 0x31, 0}, {0x32, 0x32, 0}, {0x33, 0x33, 0}, {0x34, 0x34, 0}, {input.VK_NUMPAD0, input.VK_NUMPAD0, 0}} while input.KeyGetState(input.VK_LCONTROL) == 0 do time.Sleep(0.02) if not first then str = str .. ", " else first = false end str = str .. "{" x, y = input.MouseGetPos() action = ", {" .. x .. ", " .. y .. "}" for i, k in ipairs(keys) do local state = input.KeyGetState(k[1]) if (state == 0 or state == 1) and state ~= k[3] then k[3] = state action = action .. ", {" .. k[2] .. ", " .. state .. "}" end end local currentTime = math.floor(os.clock()*1000+0.5) str = str .. (currentTime - lastTime) .. action .. "}" lastTime = currentTime end file:write(str .. "}\n\nwhile true do\n while input.KeyGetState(input.VK_LCONTROL) == 0 do\n time.Sleep(0.1)\n end\n while input.KeyGetState(input.VK_LCONTROL) == 1 do\n time.Sleep(0.01)\n end\n local timeAdjust = 0\n for i, f in ipairs(frame) do\n if input.KeyGetState(input.VK_LCONTROL) == 1 then break end\n if timeAdjust ~= nil then\n time.Sleep(0.001*f[1]-timeAdjust)\n timeAdjust = nil\n else\n timeAdjust = math.random(-0.005, 0.005)\n time.Sleep(0.001*f[1]+timeAdjust)\n end\n input.MouseSetPos(f[2][1]+math.floor(math.random(-3, 3)), f[2][2]+math.floor(math.random(-3, 3)))\n for j = 3, #f do\n if f[j][1] < 2 then\n if f[j][2] == 0 then\n input.MouseRelease(f[j][1])\n else\n input.MouseHold(f[j][1])\n end\n else\n if f[j][2] == 0 then\n input.KeyRelease(f[j][1])\n else\n input.KeyHold(f[j][1])\n end\n end\n end\n end\n while input.KeyGetState(input.VK_LCONTROL) == 1 do\n time.Sleep(0.01)\n end\nend\n") file:flush() file:close() This script is under CC-BY-NC-SA
|
| Apr 4th, '13, 13:46 |
|
 |
|
Sirmabus
Site Moderator
Joined: Aug 18th, '09, 03:32 Posts: 1201
|
 Re: FlagShip, Recorder & Replayer
Thanks for sharing your work!
|
| Apr 7th, '13, 17:41 |
|
 |
|
|
Page 1 of 1
|
[ 2 posts ] |
|
Who is online |
Users browsing this forum: No registered users and 1 guest |
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot post attachments in this forum
|
|