From 10337af11e48ec9b028c0098399069c000ddc7ae Mon Sep 17 00:00:00 2001 From: TorchedSammy <38820196+TorchedSammy@users.noreply.github.com> Date: Sat, 28 May 2022 17:24:14 -0400 Subject: [PATCH] docs: update changelog and docs referencing how objects are userdata --- CHANGELOG.md | 3 +++ docs/jobs.txt | 7 +++++-- docs/timers.txt | 14 +++++++++++--- 3 files changed, 19 insertions(+), 5 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 8a1d377..ab8a2a4 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -56,6 +56,9 @@ This is probably one of (if not the) biggest things in this release. user input, exit code, and error. User input has been added to the return to account for runners wanting to prompt for continued input, and to add it properly to history. +- **Breaking Change:** Job objects and timers are now Lua userdata instead +of a table, so their functions require you to call them with a colon instead +of a dot. (ie. `job.stop()` -> `job:stop()`) - All `fs` module functions which take paths now implicitly expand ~ to home. ### Fixed diff --git a/docs/jobs.txt b/docs/jobs.txt index 1dc8009..a5fee9c 100644 --- a/docs/jobs.txt +++ b/docs/jobs.txt @@ -20,8 +20,11 @@ and `execPath` is an absolute path for the command executable. - `disown(id)`: Removes a job by ID from the job table. # Job Object -A job object on the Lua side is a table with some functions. -On the under side it represents a job in the job table. +A job object is a piece of `userdata`. All the functions of a job require +you to call them with a colon, since they are *methods* for the job object. +Example: hilbish.jobs.last():foreground() +Which will foreground the last job. + You can still have a job object for a disowned job, it just won't be *working* anywhere. :^) diff --git a/docs/timers.txt b/docs/timers.txt index c5a456b..0f89718 100644 --- a/docs/timers.txt +++ b/docs/timers.txt @@ -16,9 +16,17 @@ a timer via ID. when the timer is triggered. # Timer Object -Those previously mentioned functions return a `timer` object, to which you can -stop and start a timer again. The functions of the timers interface also -return a timer object. +All those previously mentioned functions return a `timer` object, to which +you can stop and start a timer again. + +An example of usage: +local t = hilbish.timers.create(1, 5000, function() + print 'hello!' +end) + +t:stop() +print(t.running, t.duration, t.type) +t:start() ## Properties - `duration`: amount of time the timer runs for in milliseconds