Commit Graph

1487 Commits

Author SHA1 Message Date
Starbeamrainbowlabs
74377c7285
safe_function: update docs, add todo ref implementing wea_core.safe_after() 2024-10-17 02:40:07 +01:00
Starbeamrainbowlabs
6ea9a5acc8
//subdivide: upgrade to use new async & notify core APIs 2024-10-17 02:26:44 +01:00
Starbeamrainbowlabs
6ef17fed27
core/notify: fix crash in suppression system
`local globalstate` is initialised to have the field `suppressed_players`, but the non-existent field `suppress` is requested, resulting in operations on nil rather than the expected table. This causes the aforementioned crash.

This commit fixes this issue.
2024-10-17 02:25:31 +01:00
Starbeamrainbowlabs
8a2c26d395
Merge branch 'dev' of github.com:sbrl/Minetest-WorldEditAdditions into dev 2024-10-17 02:01:10 +01:00
Starbeamrainbowlabs
52c30a8dd1
safe_function: fix docblock docs 2024-10-17 02:01:04 +01:00
Starbeamrainbowlabs
1ae48f3a52
run_command: implement support for async functions.
Also update //for to make use of this new functionality.

//subdivide is still on the todo list.

The new functionality works by adding the new property `async = false` to command definition tables registered via wea_core.register_command()`. When `true`, if and only if the command's MAIN FUNC ONLY returns no values at all then it will consider an async operation to be in progress.

This delays `run_command` from emitting the `post-execute` event on `wea_core`.

Additionally, all async commands have a callback function injected as the first argument to their main `func` (ref main cmd definition table). This callback function -- if no arguments are returned by the main `func` -- must be called once the async operation is complete with same args you would normally return from `func` -- that is `success, result_message`. These will then be handled as normal and sent to the player as appropriate, as well as finally emitting the `post-execute` event.

BUG: There is a potential issue in this implementation, in that if i.e. `minetest.after()` is used to delay async execution then this will break out of the `xpcall()` protection in place to prevent crashes. To this end, if you implement an async function you need to be very careful, and do a manual `wea_core.safe_function()` call yourself!
2024-10-17 01:54:32 +01:00
VorTechnix
6ecbeccd54
doc update 2024-10-16 17:04:37 -07:00
Starbeamrainbowlabs
a06136812f
split_shell: use @example 2024-10-17 00:34:42 +01:00
Starbeamrainbowlabs
1677c68a7b
update some commands to the new notification system
....there's a bug in run_command tho with respect to return value handling
2024-10-17 00:27:33 +01:00
Starbeamrainbowlabs
36a6bf6b49
weac.notify: fix __call
When you do weac.notify(player_name, "info", "msg"), Lua auto-inserts a `self` table which refers to the main `Notify` table there.

This is because `local function call()` is registered via `setmetatable(Notify, ...)`, which auto-inserts `self` as the 1st argument.

To this end, this command adds a dummy 1st argument `_self` to capture this extra table to avoid all args being shifted by 1.
2024-10-17 00:21:42 +01:00
Starbeamrainbowlabs
547cdb943a
CHANGELOG: note addition of new notification system 2024-10-16 23:52:06 +01:00
Starbeamrainbowlabs
a45c119945
run_command: update result_message handling from execution to be more exhaustive 2024-10-16 23:49:40 +01:00
VorTechnix
ecafb69486
switched run_command to wea core notify 2024-10-16 15:15:47 -07:00
Starbeamrainbowlabs
c352446226
Merge branch 'dev' of github.com:sbrl/Minetest-WorldEditAdditions into dev 2024-10-16 20:19:11 +01:00
Starbeamrainbowlabs
bfc22ae6dd
website: fix missing target_dir error 2024-10-16 20:18:51 +01:00
VorTechnix
41577de416
doc updates 2024-10-16 12:04:20 -07:00
VorTechnix
112364e767
refactor of test registry 2024-10-15 17:32:14 -07:00
VorTechnix
66dcd6bbd7
added suppression 2024-10-15 17:31:40 -07:00
Starbeamrainbowlabs
565dc81994
website: update moondoc, fix Lua API docs sitename 2024-10-16 01:22:01 +01:00
Starbeamrainbowlabs
fbb3d5096c
tokenise_commands: use @example 2024-10-16 01:00:01 +01:00
Starbeamrainbowlabs
9101d32bd5
website: update dependencies 2024-10-15 22:37:29 +01:00
Starbeamrainbowlabs
c84fa5f152
Notify, Notify.validate: correct docblock comments so they work with moondoc
moondoc is the system we use for auto-generating Lua API docs

Ref https://github.com/sbrl/moondoc
2024-10-15 22:36:47 +01:00
Starbeamrainbowlabs
57d09a766b
Merge branch 'feature/pcall-protection' into dev 2024-10-15 20:15:17 +01:00
VorTechnix
2f1332739e
added notify_bad test 2024-10-14 19:14:18 -07:00
VorTechnix
e0f6d9d9ce
Update notify.lua 2024-10-14 19:13:47 -07:00
VorTechnix
a9307d3725
Update validate.lua 2024-10-14 19:13:20 -07:00
VorTechnix
a0f3fb5a3d
folderized notify 2024-10-14 15:41:43 -07:00
Starbeamrainbowlabs
287d448d03
promise_tech: fix remaining LuaCheck errors 2024-10-14 21:07:55 +01:00
Starbeamrainbowlabs
514a9346ac
promise_tech: disable unnecessary luacheck errors 2024-10-14 21:03:26 +01:00
Starbeamrainbowlabs
0ca3842b40
fix busted error 2024-10-14 20:59:42 +01:00
Starbeamrainbowlabs
45711764da
//maze3d: fix crash 2024-10-14 20:58:50 +01:00
Starbeamrainbowlabs
e0ba5d9810
Revert "//count: deliberately introduce a crash for testing purposes"
This reverts commit 39b3ef428d94220fda7dc22da5b2e807041ed6d9.
2024-10-14 20:56:20 +01:00
Starbeamrainbowlabs
4bd278d6b9
//maze, //maze3d: update to WEA pos API
Ref https://worldeditadditions.mooncarrot.space/api/#worldeditadditions_core.pos
2024-10-14 20:50:31 +01:00
Starbeamrainbowlabs
ea1c17a6e3
safe_function: only log error when there's actually an error 2024-10-14 20:48:55 +01:00
Starbeamrainbowlabs
b6c41395f6
core: tidy up new safe_function implementation; bugfix 2024-10-14 20:46:26 +01:00
Starbeamrainbowlabs
00b1aed1ff
abstract new xpcall wrapper into new API function safe_function 2024-10-14 19:25:53 +01:00
Starbeamrainbowlabs
c01eb23488
newline 2024-10-14 18:53:32 +01:00
Starbeamrainbowlabs
938a617dc3
run_command: add prototype wrapper around command parsing. 2024-10-14 18:51:33 +01:00
VorTechnix
d006a91eaa
better error tracebacks 2024-10-14 10:32:11 -07:00
VorTechnix
5381c31abb
Update notify.lua 2024-10-13 21:18:57 -07:00
VorTechnix
a9a7a5a9f1
Fixed some problems 2024-10-13 15:01:53 -07:00
VorTechnix
cd8a034333
more tests 2024-10-13 14:23:34 -07:00
VorTechnix
ef1189e6db
Update notify.lua 2024-10-13 14:23:05 -07:00
VorTechnix
c218242190
added //test 2024-10-13 13:54:02 -07:00
VorTechnix
f15d2e31f7
added test handler 2024-10-13 13:53:24 -07:00
VorTechnix
5e54d112ce
added wea_c.notify 2024-10-13 13:52:27 -07:00
Starbeamrainbowlabs
39b3ef428d
//count: deliberately introduce a crash for testing purposes
YOU DO NOT WANT THIS COMMIT!
TODO REVERT THIS COMMIT VIA REBASE WHEN DONE.
2024-10-12 01:05:38 +01:00
Starbeamrainbowlabs
cd22c710b2
start working on implementing some kind of system to catch error messages
....it works, but:
- We can't capture stack traces like this
- It's messy
- We need to implement an escape/encodeURIComponent function ourselves from scratch 'cause the one I ripped from Stack Overflow sucks
2024-10-12 01:04:27 +01:00
Starbeamrainbowlabs
86fd6a560d
split_shell: document properly
it should appear in the Lua API docs now.

Cody AI was actually v helpful with this, and it helped that I already had tests for it o/
2024-10-11 03:19:31 +01:00
Starbeamrainbowlabs
270cbd5aae
split_shell: remove unused argument 2024-10-11 03:12:14 +01:00