#The ui window is not generated.

1 messages · Page 1 of 1 (latest)

still sage
#

Hi, I'm new to javascript scripts in Minecraft Bedrock and I would like to know what I have wrong with my code. What I want to do with it is generate a UI for the player and show buttons so that the player can choose one of them. I've been trying but nothing works for me.

I don't know if it will be the versions of the APIs that I use.

still sage
#

No, there's just nothing happening in the world.

#

I have Minecraft 1.20.62.02 oficial

#

What I don't understand is that when I add the following:

world.afterEvents.playerSpawn.subscribe((data) => {
if (data.initialSpawn) {
const player = data.player;
player.sendMessage(§9Bienvenido §f§e${player.name} §7a §l§kii§r§l§bDLC§e-§dGames§k§fii§r \n§r§fCreado por: §dDe_La_Cupertino \n§2XBOX: §8DLC LazerX09, zeno oo zama)
}
});

#

It runs correctly.

final raft
wise lintel
#

@still sage You are using an unavailable method on the ModalFormData constructor, its formData.textField()

final raft
#

these not even a textfield it just put text

#

if I don’t say betise text alone doesn’t exist

still sage
#

@final raft I want it to show buttons to select and also that you can enter text:

#

@wise lintel I'll try it

final raft
still sage
#

I would like it to open when I use a certain item or else when I enter the world.

final raft
#

when we join the world eje do not know how to do but with an item know how to do

still sage
#

Show me that way.

#

With item

final raft
#
world.afterEvents.itemUse.subscribe(data => {
    if (data.itemStack.typeId === 'minecraft:compass') {
        button(data.source)
    }
})

function button(player) {
    const form = new ActionFormData;
    form.title("Button")
    form.button("textField")
    form.button("button")
    form.show(player).then(r => {
        if (r.selection == 0) { textField(player) }
        if (r.selection == 1) { button(player) }
    })
}

function textField(player) {
    const form = new ModalFormData;
    form.title("textField")
    form.textField("text field", "")
    form.show(player).then(r => {

    })
}
#

this is just one example

still sage
#

@final raft

A query. How do you ensure that your code that you wrote in the chat does not appear as an image?

scenic silo
# still sage There

world.afterEvents.itemUse.subscribe(data => {
if (data.itemStack.typeId === 'minecraft:compass') {
button(data.source)
}
})

function button(player) {
const form = new ActionFormData;
form.title("Button")
form.button("textField")
form.button("button")
form.show(player).then(r => {
if (r.selection == 0) { textField(player) }
if (r.selection == 1) { button(player) }
})
}

function textField(player) {
const form = new ModalFormData;
form.title("textField")
form.textField("text field", "")
form.show(player).then(r => {

})

}

scenic silo
still sage
#

@scenic silo Yes. The code that the other colleague gave me is perfect and works very well for me.