For whatever reason, some of the lua code (particularly the osc and ytdl_hook) is full of a bunch of stuff like if (foo), if not (foo == nil), etc. The parenthesis aren't needed in lua and actually just look weird since nobody actually writes lua like this. You can see most of the other conditionals are written normally. So cleanup the style to match when the parenthesis clearly aren't doing anything. Not directly related, but also add some spaces on a few math operations while we're at it.
Showing the changes to player/lua/defaults.lua (1 of 5 files). Show all
Unified · Split
| @@ -175,7 +175,7 @@ function mp.flush_keybindings() · 174 unmodified lines | |||
| 175 | end | 175 | end |
| 176 | 176 | ||
| 177 | local function add_binding(attrs, key, name, fn, rp) | 177 | local function add_binding(attrs, key, name, fn, rp) |
| 178 | if (type(name) ~= "string") and (name ~= nil) then | 178 | if type(name) ~= "string" and name ~= nil then |
| 179 | rp = fn | 179 | rp = fn |
| 180 | fn = name | 180 | fn = name |
| 181 | name = nil | 181 | name = nil |
| @@ -226,7 +226,7 @@ local function add_binding(attrs, key, name, fn, rp) · 44 unmodified lines | |||
| 226 | end | 226 | end |
| 227 | if is_mouse and (event == "u" or event == "p") then | 227 | if is_mouse and (event == "u" or event == "p") then |
| 228 | fn() | 228 | fn() |
| 229 | elseif (not is_mouse) and (event == "d" or event == "r" or event == "p") then | 229 | elseif not is_mouse and (event == "d" or event == "r" or event == "p") then |
| 230 | fn() | 230 | fn() |
| 231 | end | 231 | end |
| 232 | end | 232 | end |
| @@ -316,7 +316,7 @@ end · 83 unmodified lines | |||
| 316 | local function get_next_timer() | 316 | local function get_next_timer() |
| 317 | local best = nil | 317 | local best = nil |
| 318 | for t, _ in pairs(timers) do | 318 | for t, _ in pairs(timers) do |
| 319 | if (best == nil) or (t.next_deadline < best.next_deadline) then | 319 | if best == nil or t.next_deadline < best.next_deadline then |
| 320 | best = t | 320 | best = t |
| 321 | end | 321 | end |
| 322 | end | 322 | end |
| @@ -598,7 +598,7 @@ mp.register_event("hook", function(ev) · 275 unmodified lines | |||
| 598 | if fn then | 598 | if fn then |
| 599 | fn(hookobj) | 599 | fn(hookobj) |
| 600 | end | 600 | end |
| 601 | if (not hookobj._defer) and hookobj._id ~= nil then | 601 | if not hookobj._defer and hookobj._id ~= nil then |
| 602 | hookobj:cont() | 602 | hookobj:cont() |
| 603 | end | 603 | end |
| 604 | end) | 604 | end) |