SwitchCraftCC / sc-peripherals

Custom peripherals for the SwitchCraft server
MIT License
10 stars 7 forks source link

Accept an array of numbers instead of a lua table for 3dj seat coordinates #48

Closed dimaguy closed 6 months ago

dimaguy commented 6 months ago

Maybe I'm being stupid, or there's something I'm missing. but as I'm writing a Pull Request for Sam's 3DJ blockbench plugin (written in javascript) I can't seem to be able to output a lua table with just numbers without falling onto very stupid string manipulation workarounds. Could the coordinates be inserted with an array of numbers instead?

TL;DR: [ ] instead of { } pretty please?

Lemmmy commented 6 months ago

3dj files are JSON? I'm not sure I understand the problem?

dimaguy commented 6 months ago

Javascript refuses to do objects without a key-value relation

Lemmmy commented 6 months ago

seatPos is already an array. For reference, here is one of my test prints:

{
    "label": "a",
    "tooltip": "Made with Blockbench",
    "isButton": false,
    "collideWhenOn": true,
    "collideWhenOff": true,
    "lightLevel": 0,
    "redstoneLevel": 0,
    "seatPos": [0.5, 0.1, 0.5],
    "shapesOff": [
        {
            "bounds": [0, 0, 0, 16, 1, 16],
            "texture": "minecraft:block/stripped_birch_log",
            "tint": "FFFFFF"
        }
    ],
    "shapesOn": [
        {
            "bounds": [0, 0, 0, 16, 1, 16],
            "texture": "minecraft:block/stripped_birch_log",
            "tint": "FF0000"
        },
        {
            "bounds": [0, 1, 0, 16, 11, 1],
            "texture": "minecraft:block/stripped_birch_log",
            "tint": "FF0000"
        },
        {
            "bounds": [0, 1, 15, 16, 11, 16],
            "texture": "minecraft:block/stripped_birch_log",
            "tint": "FF0000"
        },
        {
            "bounds": [15, 1, 1, 16, 11, 15],
            "texture": "minecraft:block/stripped_birch_log",
            "tint": "FF0000"
        },
        {
            "bounds": [0, 1, 1, 1, 11, 15],
            "texture": "minecraft:block/stripped_birch_log",
            "tint": "FF0000"
        }
    ]
}
Wojbie commented 6 months ago

I think they are confused by how it's explained in documentation using lua table.

dimaguy commented 6 months ago

Oh, then there's a mistake in the docs, because you're using curly braces there

Lemmmy commented 6 months ago

I think they are confused by how it's explained in documentation using lua table.

Got it, fixing now