Log In  

Cart #23349 | 2016-06-21 | Code ▽ | Embed ▽ | License: CC4-BY-NC-SA
4

View on Github.com

You miss built-in lua functions such as ipairs or getmetatable in pico-8? Well, fear no more.

Currently supported Lua "built-in" functions

    getmetatable
    setmetatable
    rawget
    unpack
    ipairs
    table.pack
    table.unpack as an alias to unpack
    table.insert
    table.remove
    table.sort

Tested to imitate their counterparts

Travis-CI is set to test missing.lua against test.lua, which compares results of this library functions with the built-in ones. Well, tests may be incomplete, so do not hesitate to flag a bug to the issue tracker if something goes wrong.

How to use

Heads up to the latest release. Then, there's two options:

Either you download
missing.lua

then copy the file contents into your .p8 project file, preferably before the rest of your code; or


you load missing.p8 in pico-8 to test it out first.

About this license

This library is under creative commons license CC4-BY-NC-SA. See LICENSE.md. It's the same license as the optional one on Lexaloffle's website if you choose to publish a cart.

So, if you happen to publish a cart using this library, it would be nice if you mention it.

Thanks

To Lexaloffle, which this library would not exist without pico-8.

Changes


0.2
Add some table functions.

    table.pack
    table.unpack as an alias to unpack
    table.insert
    table.remove
    table.sort

Refactor

ipairs

to make it return an iter function, as the native one does.


0.1
Add

    getmetatable
    setmetatable
    rawget
    unpack
    ipairs


P#22824 2016-06-13 06:11 ( Edited 2016-06-21 05:38)

I'm excited to know about Lua's iterator protocol. :) https://www.lua.org/pil/7.3.html

P#22863 2016-06-13 22:10 ( Edited 2016-06-14 02:10)

Oh! Yes. I'm gonna keep an eye out for this. Thanks for sharing me the link.

P#22865 2016-06-13 23:38 ( Edited 2016-06-14 03:38)

The only builtins I'm really missing are table.insert, table.sort, and table.remove ...
I've had to recreate their functionality twice so far, for Zep likes foxes and Nora's Mouse Chase! to do the Y axis sprite sorting.

P#22885 2016-06-14 17:07 ( Edited 2016-06-14 21:07)

@dddaaannn The iterator protocol is now implemented!

 @JTE table.insert, table.sort and table.remove are now available too.

P#23350 2016-06-21 01:38 ( Edited 2016-06-21 05:38)

[Please log in to post a comment]

Follow Lexaloffle:          
Generated 2024-03-19 02:35:31 | 0.014s | Q:22