Commit Graph

402 Commits

Author SHA1 Message Date
rhy
3c959caa23 uuid: Slight style fix
Don't need to capture the 2nd value oops, also separated the format
call into multiple lines
2023-01-10 11:21:32 -03:00
rhy
370b33b96f woops typo 2023-01-10 11:21:31 -03:00
rhy
2642c304ad uuid: Discard gsub's 2nd return value 2023-01-10 11:21:31 -03:00
rhy
57bc1a2edb uuid: Use mathx's _random instead of stringx's 2023-01-10 11:21:31 -03:00
rhy
e630418372 uuid: Add a passed rng to uuid4 2023-01-10 11:21:31 -03:00
rhy
5f2e7b437d uuid: Fix variable casing 2023-01-10 11:21:31 -03:00
rhy
0f390f9f85 Add uuid.lua from the other pull request 2023-01-10 11:21:31 -03:00
Max Cahill
ba7a7b5500 fixed intersection tests with zero radius shapes (treated as points generally) 2022-12-08 13:36:29 +11:00
Max Cahill
2c76b7dde0 fixed crash in spairs and then provided a more robust default_less function which sorts numbers before strings, but sorts those groups with operator< 2022-12-06 10:45:57 +11:00
Max Cahill
0d88061e3b moved unique_mapping to ferris 2022-12-05 18:10:21 +11:00
Max Cahill
844c9e8c8f ...needed to forward-declare for the previous fix 2022-11-08 09:23:45 +11:00
Max Cahill
c6e6ec858c fixed accidentally global callback in subscribe_once 2022-11-08 09:20:37 +11:00
Max Cahill
94d9901728 better error reporting for pubsub defer-related errors 2022-11-07 17:13:25 +11:00
Max Cahill
66e9848bef added pubsub:subscribe_once and fixed a bug if you subscribe or unsubscribe from inside a callback 2022-11-03 16:19:18 +11:00
Max Cahill
9a8493b880 added stringx.split_and_trim to save me inlining something with the same effect all over the place 2022-10-24 16:08:39 +11:00
Max Cahill
84d4e39622 clarified position/halfsize for aabbs and provided conversion functions from xywh to pos/hs representation
closes #60
2022-10-24 15:18:28 +11:00
Max Cahill
49df9d9743 added tablex.next_element 2022-10-18 12:25:37 +11:00
Max Cahill
7285531870 fixed dedent() with trimmed blank lines (some editors do this automatically) 2022-09-20 15:00:44 +10:00
Max Cahill
662101ddae Merge branch 'feature/nobit-colour' 2022-09-13 11:15:18 +10:00
Max Cahill
4f86dc0a5e keep both bitop and float-only pack/unpack functions in colour 2022-09-13 11:15:08 +10:00
Max Cahill
44c6ae1b0a added tablex.compact to compact sequential tables of a known range containing nils 2022-07-19 15:58:15 +10:00
Max Cahill
24fde1c157 made stringx.deindent remove all trailing empties rather than just one 2022-07-11 16:44:51 +10:00
Max Cahill
9f5dfcb923 removed needless branch in tablex.shallow_copy 2022-06-23 16:36:54 +10:00
Max Cahill
81512550bb fixed possible stack overflow in deep_copy 2022-06-09 16:36:02 +10:00
Max Cahill
a5c26038df fixed reset timer still counting as expired 2022-06-07 16:43:20 +10:00
Max Cahill
bff54f0dbd disambiguated variable names in map_call 2022-06-07 16:30:01 +10:00
Max Cahill
b68081be53 added map_call for mapping a sequence with a method call (useful for object-y collections) 2022-06-07 16:16:01 +10:00
Max Cahill
7366473f32 added functional.map_field for quick extraction of some field of a sequence of objects 2022-06-07 15:38:16 +10:00
Max Cahill
dbce7e6083 managed expired state inside the timer rather than just checking if the time has expired; makes sure the callback fires even for zero length timers 2022-06-07 14:09:35 +10:00
Josh Perry
a089b160a2 uuid: added a uuid module
Only contains a function for (the most useful) uuid4 at present.
2022-05-26 14:05:04 +01:00
Max Cahill
795f2587d2 fixed pretty.lua using tablex instead of table alias 2022-05-23 14:54:05 +10:00
Max Cahill
1e75fad409 changed pretty printing to use sorted keys 2022-05-23 14:51:18 +10:00
Max Cahill
433e4ebb08 removed whitespace to make the linter happy; todo discover how to turn this particular inanity (whitespace only lines) off :) 2022-05-23 14:51:02 +10:00
Max Cahill
8a57ae458f added changes to accept spairs; merged #58 2022-05-23 14:48:52 +10:00
jalhund
199b8ded1d tablex: Add spairs (alternative of pairs that returns sorted table) 2022-05-18 05:17:55 +00:00
Miku AuahDark
fabbd3f702
colour: Don't depend on bit library. 2022-05-09 10:16:43 +08:00
Max Cahill
be48dd9115 clarified blue vs chroma b in oklab functions 2022-04-22 10:08:55 +10:00
Max Cahill
6e65f82474 clarified rng variable name, but also removed warning for _ prefixed variables as they are used to signal internal/private variables rather than unused variables. 2022-04-22 10:05:44 +10:00
Max Cahill
cb3083bc79 added oklab support to colour.lua (needs testing) 2022-04-05 14:51:49 +10:00
Max Cahill
05f86e2cc1 fixed wrong degenerate direction checked in intersect.line_line_collide 2022-03-29 17:56:02 +11:00
Max Cahill
813ee20052 moving tests to .test to get them out of root folder for now 2022-03-07 12:10:20 +11:00
Max Cahill
6969a044a3 updated tests to reflect that tablex shallow and deep copy don't copy non-table values 2022-03-07 12:04:19 +11:00
Max Cahill
213ba5df0f added tablex.copy is an alias for tablex.shallow_copy, same for overlay, bunch of whitespace changes, some additional asserts 2022-03-07 12:00:05 +11:00
Max Cahill
de5c803389 fixed set not specifying deep or shallow copy 2022-03-07 11:59:23 +11:00
Max Cahill
b6ca4c7740
Merge pull request #53 from idbrii/fix-async-lovejs
async: Skip wrapping with xpcall under lovejs
2022-03-07 10:50:36 +11:00
Max Cahill
840f4ba703
Merge pull request #54 from idbrii/capture-w-func
async: Use function to capture ...
2022-03-07 10:49:01 +11:00
Max Cahill
461c3a8131
Merge pull request #52 from idbrii/table-deep-test
tablex: Add deep & shallow for copy, overlay; remove redundant recursion; add tests
2022-03-07 10:27:35 +11:00
Max Cahill
4b0e0c7ec7
Merge pull request #51 from idbrii/lint
Add luacheck and fix bugs it found
2022-03-07 10:14:08 +11:00
David Briscoe
a030a20985 async: Assert that args is a table; add type_or_nil
If args is valid, assert it's a table.

Provides a clear and immediate error message when you convert
add_timeout() to call().

Also add type_or_nil. Very useful for optional parameters like this one.
Seems clearer than checking the arg first:
    if args then assert:type() end
2022-03-06 00:25:24 -08:00
David Briscoe
98f3630c07 async: Skip wrapping with xpcall under lovejs
See Davidobot/love.js#54.

lovejs crashes love with "attempt to yield across metamethod/C-call
boundary" when you try to yield in a coroutine, so we skip wrapping.

We lose the coroutine-local callstack, but at least it works.

Here's my repro:

    local color = {
        purple = {0.25, 0.09, 0.28, 1},
        white = {0.89, 0.91, 0.90, 1},
    }
    local ball = {
        x = 100,
        y = 100,
        r = 20,
    }
    local S = {}
    local input = {
        vanilla = 'v',
        async = 'c',
        quit = 'escape',
    }

    function love.load()
        S.coro = async()
    end

    local function coro_fn()
        S.async_running = true
        for i=1,100 do
            color.purple[4] = i / 100
            coroutine.yield()
        end
        color.purple[4] = 1
        S.async_running = false
        return true
    end

    function love.update(dt)
        S.coro:update(dt)

        if S.vanilla then
            local success, result = coroutine.resume(S.vanilla)
            if result then
                print("coroutine cleared")
                S.vanilla = nil
            end
        end

        if not S.async_running then
            if love.keyboard.isDown(input.vanilla) then
                S.vanilla = coroutine.create(coro_fn)
                print("raw coroutine started")

            elseif love.keyboard.isDown(input.async) then
                print("Starting async call coroutine from update")
                S.coro:call(coro_fn)

            elseif love.keyboard.isDown(input.quit) then
                love.event.quit()
            end
        end
    end

    function love.draw()
        love.graphics.setColor(color.purple)
        love.graphics.circle("fill", ball.x, ball.y, ball.r)

        love.graphics.setColor(color.white)
        local str = "To start a coroutine:"
        for key,val in pairs(input) do
            str = ("%s\n%s: %s"):format(str, key, val)
        end
        love.graphics.printf(str, 5,5, 200, "left")
    end
2022-03-05 23:44:08 -08:00