-
Notifications
You must be signed in to change notification settings - Fork 168
Extending mpv and mpv.net via Lua scripting
Learn what Lua is in 100 seconds here.
Lua scripting is documented in the mpv manual here.
A very large collection of user scripts can be found in the mpv wiki here.
On GitHub, mpv scripts are tagged as mpv-script.
In Visual Studio Code install:
These are fantastic extensions that are actively maintained.
The last tested version of Lua Debug by actboy168 that worked for me is v1.57, v1.58 and v1.58.1 did not work, a bug report was submitted. In VS Code you can install old versions by using the context menu in the extension panel.
The debugger works when the code is error free, if there is a Lua error the debugger exits at the error location without giving a trace or hint about the error. The debugger allows stepping through your code, watch variables and even table contents.
In your debug configuration defined in launch.json you can use 3 profiles:
- Pure Lua without mpv using VS Code terminal output and debugging.
- Debugging mpv.exe when the code is error free, you have to compile a mpv debug build, which is described here and here.
- Show mpv and Lua errors via external terminal output from mpv.com.
{
"version": "0.2.0",
"configurations": [
{
"name": "lua",
"program": "${file}",
"request": "launch",
"stopOnEntry": false,
"type": "lua"
},
{
"type": "lua",
"request": "launch",
"name": "mpv lua",
"runtimeExecutable": "D:/Software/Development/MSYS2/mingw64/bin/mpv.exe",
"runtimeArgs": ["--quiet", "--script=${file}", "D:/Samples/LG New York HDR UHD 4K Demo.mkv"],
"stopOnEntry": false,
"luaVersion": "5.1"
},
{
"type": "lua",
"request": "launch",
"name": "mpv lua term",
"console": "externalTerminal",
"runtimeExecutable": "D:/Software/Development/MSYS2/mingw64/bin/mpv.com",
"runtimeArgs": ["--quiet", "--script=${file}", "D:/Samples/LG New York HDR UHD 4K Demo.mkv"],
"stopOnEntry": false,
"luaVersion": "5.1"
}
]
}
To read resources in dark mode, there is Dark Reader.
- https://github.com/LewisJEllis/awesome-lua
- https://www.lua.org/manual/5.1/manual.html
- https://www.lua.org/manual/5.1/index.html#index
- http://lua-users.org/
- https://www.reddit.com/r/lua/
- https://github.com/uhub/awesome-lua
- http://kiki.to/blog/2014/03/30/a-guide-to-authoring-lua-modules/
- https://learnxinyminutes.com/docs/lua/
- https://www.tutorialspoint.com/lua
- https://www.wikiwand.com/en/Lua_(programming_language)
- https://www.newthinktank.com/2015/06/learn-lua-one-video/
- https://stevedonovan.github.io/lua-cookbook/topics/00-intro.md.html#
- https://en.m.wikibooks.org/wiki/Lua_Programming
- https://riptutorial.com/lua
- http://www.w3big.com/lua/default.html
- https://github.com/pohka/Lua-Beginners-Guide
- http://lua-users.org/wiki/LuaStyleGuide
- http://lua-users.org/wiki/TutorialDirectory
- http://notebook.kulchenko.com/programming/lua-good-different-bad-and-ugly-parts
- https://github.com/Olivine-Labs/lua-style-guide
- https://www.lua.org/pil/contents.html