#Adding new properties to cubes

7 messages · Page 1 of 1 (latest)

tender heath
#

I've been using Blockbench as a room editor for a game of mine, but need a way to add just a bit more information to a cube. I'm trying to make a plugin to do so and have them exported with the json files and so far my luck hasn't been all that great.

I have this set up in the onLoad() function

new Property(Cube, "array", "obj_data");

and im using this to try to change it

  onConfirm: function(data) {
        Undo.initEdit({elements: Cube.selected});
        Cube.selected.forEach(cube => {
            cube.obj_data[0] = (data.command_type + "-" + data.ref_variable + "-" + data.value_type + "-" + data.value);

            Blockbench.showToastNotification({
                text: (data.command_type + "-" + data.ref_variable + "-" + data.value_type + "-" + data.value),
                icon: "location_city",
                expire: 2500
            });
        });
        Canvas.updateView({
            elements: Cube.selected,
            element_aspects: {geometry: true},
            selection: true
        });
        Undo.finishEdit('Add object Data');

        dia_add_data.hide();
    }

when i run it i get this error though

Uncaught TypeError: Cannot set properties of undefined (setting '0')
    at <anonymous>:99:30
    at Array.forEach (<anonymous>)
    at Dialog.onConfirm (<anonymous>:98:23)
    at Dialog.close (dialog.js:595:22)
    at HTMLButtonElement.<anonymous> (dialog.js:683:11)
    at HTMLButtonElement.dispatch (jquery.js:2:43064)
    at v.handle (jquery.js:2:41048)
#

sorry if this doesn't make much sense im at a loss here and i cant find a program that works as well as blockbench for this

violet flax
#

~~Perhaps you should initialize it's value (correct me if I'm wrong)

new Property (Cube, 'array', 'obj_data', {default: []});
```~~
tender heath
#

i didnt think of that give me one second actually

#

that seems to have worked

#

awesome lol

violet flax
#

Well that's weird because blockbench already uses the defaults.