summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorwm4 <wm4@nowhere>2015-04-08 21:21:44 +0200
committerwm4 <wm4@nowhere>2015-04-08 21:21:44 +0200
commit26909c1113ab86801ca3e1f8097f7ed0e06d35d4 (patch)
treeecce7592d030c712ea67007134472f3afeabd12b
parent36ae8a6cab69f849b3e78ddf6840e5f95c86c659 (diff)
downloadmpv-26909c1113ab86801ca3e1f8097f7ed0e06d35d4.tar.bz2
mpv-26909c1113ab86801ca3e1f8097f7ed0e06d35d4.tar.xz
manpage: lua: clarify timer usage
This seems to come up often. I guess '.' vs. ':' for Lua calls is confusing, and this part of the scripting API is the only one which requires using it.
-rw-r--r--DOCS/man/lua.rst17
1 files changed, 17 insertions, 0 deletions
diff --git a/DOCS/man/lua.rst b/DOCS/man/lua.rst
index d8912dac2b..4700b90cb2 100644
--- a/DOCS/man/lua.rst
+++ b/DOCS/man/lua.rst
@@ -356,6 +356,23 @@ The ``mp`` module is preloaded, although it can be loaded manually with
(``true``). This value is used when the timer expires (but before
the timer callback function fn is run).
+ Note that these are method, and you have to call them using ``:`` instead
+ of ``.`` (Refer to http://www.lua.org/manual/5.2/manual.html#3.4.9 .)
+
+ Example:
+
+ ::
+
+ seconds = 0
+ timer = mp.add_periodic_timer(1, function()
+ print("called every second")
+ # stop it after 10 seconds
+ seconds = seconds + 1
+ if seconds >= 10 then
+ timer:kill()
+ end
+ end)
+
``mp.get_opt(key)``
Return a setting from the ``--script-opts`` option. It's up to the user and