#teleport ugi

1 messages Β· Page 1 of 1 (latest)

thorn veldt
#

Why are the ones I create from the list deleted when I leave the world and come back?

whole escarp
#

hi

#

ok

#

i see

thorn veldt
#

hi

#

You found me πŸ™‚

#

@whole escarp

whole escarp
#

waht

thorn veldt
#

Didn't you help me?

#

@whole escarp

whole escarp
#

dont ping me

gritty heart
#
function createButton(player) {
    const formData = new ModalFormData();
    formData.title('Create Button');
    formData.textField('Button Name', 'value');

    formData.show(player).then(data => {
        const buttonName = data.formValues[0];

        // Save button location as dynamic property
        let { x, y, z } = player.location;
        x = Math.round(x).toFixed(0);
        y = Math.round(y).toFixed(0);
        z = Math.round(z).toFixed(0);

        const buttonData = { x, y, z };
        player.setDynamicProperty(`button_${buttonName}`, JSON.stringify(buttonData));
        player.sendMessage(`Button "${buttonName}" created at ${x}, ${y}, ${z}`);
    });
}

function teleportToButton(player) {
    // Get all button names
    const buttonNames = player.getDynamicPropertyIds()
        .filter(propertyName => propertyName.startsWith('button_'))
        .map(buttonProperty => buttonProperty.replace('button_', ''));

    // Show buttons in the form
    const formData = new ActionFormData()
    formData.title('Teleport to Button');
    buttonNames.forEach(buttonName => {
        formData.button(buttonName);
    });

    formData.show(player).then(data => {
        const selectedIndex = data.selection;
        const selectedButton = buttonNames[selectedIndex]

        if (selectedButton) {
            const buttonDataString = player.getDynamicProperty(`button_${selectedButton}`);
            if (buttonDataString) {
                const buttonData = JSON.parse(buttonDataString);
                const { x, y, z } = buttonData;
                player.runCommandAsync(`tp ${x} ${y} ${z}`);
                player.sendMessage(`Teleported to Button "${selectedButton}" at ${x}, ${y}, ${z}`);
            } else {
                player.sendMessage('Invalid selection');
            }
        } else {
            player.sendMessage('Invalid selection');
        }
    });
}

@thorn veldt

#

here

#

should I add a function to remove locations?

thorn veldt
#

Yes, this was my idea, but I did not know how to implement it

#

@gritty heart

gritty heart
#
function deleteButton(player) {
    const buttonNames = player.getDynamicPropertyIds()
        .filter(propertyName => propertyName.startsWith('button_'))
        .map(buttonProperty => buttonProperty.replace('button_', ''));

    const formData = new ActionFormData().title('Delete Button');
    buttonNames.forEach(buttonName => {
        formData.button(buttonName);
    });

    formData.show(player).then(data => {
        const selectedIndex = data.selection;
        const selectedButton = buttonNames[selectedIndex];

        if (selectedButton) {
            player.setDynamicProperty(`button_${selectedButton}`, null);
            player.sendMessage(`Button "${selectedButton}" deleted.`);
        } else {
            player.sendMessage('Invalid selection');
        }
    });
}
```here
#

@thorn veldt

thorn veldt
#

okay

gritty heart
#
function TPS(player) {
    const form = new ActionFormData()
        .title('MG_MENU')
        .button('CREATE A BUTTON ')
        .button('TELEPORT')
        .button('delete');
    
    form.show(player).then(r => {
        const { selection, canceled } = r;
        if (canceled) return;
        switch (selection) {
            case 0:
                createButton(player);
            break;
            case 1:
                teleportToButton(player);
            break;
            case 2:
                deleteButton(player)
            break;
        }
    });
}
#

for the first ui

thorn veldt
#

πŸ‘ok

thorn veldt
#

@gritty heart

gritty heart
#

yes

thorn veldt
#

Yes, I fixed the problem of the buttons disappearing, but the delete button does not work

gritty heart
#

Its working for me

thorn veldt
#

How did you write it? Maybe I wrote it wrong

gritty heart
thorn veldt
#

I told you I wrote it wrong

#

This is my fault, I apologize

#

πŸ™‚πŸ‘

#

are you here

#

Listen, I previously made a mod that contained a list of increasing power through the Infinite Effects system

#

But the effect disappears quickly, even if you set the time to 100,000

#

You are really very expert in programming

thorn veldt
thorn veldt
#

teleport ugi