#how do i make this work?

1 messages · Page 1 of 1 (latest)

inland shore
#

convert it in js format like this

inner quail
inland shore
#

js, not json, and thats a file, but whatever

#
world.beforeEvents.itemUse.subscribe(async (eventData) => {
    const player = eventData.source;
    const itemUsed = eventData.itemStack;
    suvUi.textField("Enter a secret code", "Code", "")
    server.system.run(async () => {
        if (itemUsed.typeId == "prp:customize1") {
            const operationResult = await suvUi.show(player);
            const [text] = result.formValues;
            switch (operationResult.selection) {
                case 0:
                    player.runCommandAsync(`tellraw @s {"rawtext":[{"text":"§l§cStill on WIP"}]}`)
                    break;
                case 1:
                    player.runCommandAsync(`tellraw @s {"rawtext":[{"text":"§l§cStill on WIP"}]}`)
                    break;
                case 2:
                    player.runCommandAsync(`tellraw @s {"rawtext":[{"text":"§l§cStill on WIP"}]}`)
                    break;
                case 3:
                    player.runCommandAsync(`tellraw @s {"rawtext":[{"text":"§l§cStill on WIP"}]}`)
                    break;
                case 4:
                    break;
            }
            switch (text) {
                case '1234':
                    player.sendMessage('§l§cStill on WIP')
                    break;
            }
        }
    })
});
#

what is the problem

inner quail
#

i want to detect an specific text in the textfield and make an "event"

#

i want to detect when i type 1234 inside the form

#

but the textfield doesn't works

inland shore
inner quail
#

do you want me to send you all the code?

inland shore
#

no, i want you to analyze your problem, ill help you solve it by your own

#

have you initiated a modalform called suvUi?

inner quail
#

that is my code, the problem is that the textfield is not working, not event outside of the world.beforeEvents and idk why

#

and when i use the item it says this

inland shore
#

actionform data has no textfield

inner quail
#

do i change action to modal?

inland shore
#
import * as server from '@minecraft/server'
import { ActionFormData, ModalFormData } from "@minecraft/server-ui";
const world = server.world
const option = [`Hats`,`Grabpacks`,`Hands`,`Feet`]
const suvUi = new ModalFormData();
suvUi.title(`Survivor Customisation`)
suvUi.dropdown(`Select:`,option,0)
suvUi.textField("Enter a secret code", "Code", "")

world.beforeEvents.itemUse.subscribe((eventData) => {
    const player = eventData.source;
    const itemUsed = eventData.itemStack;
    server.system.run(() => {
        if (itemUsed.typeId == "prp:customize1") {
            suvUi.show(player).then((response) => {
            const [selection,text] = response.formValues;
            switch (selection) {
                case 0:
                    player.runCommandAsync(`tellraw @s {"rawtext":[{"text":"§l§cStill on WIP"}]}`)
                    break;
                case 1:
                    player.runCommandAsync(`tellraw @s {"rawtext":[{"text":"§l§cStill on WIP"}]}`)
                    break;
                case 2:
                    player.runCommandAsync(`tellraw @s {"rawtext":[{"text":"§l§cStill on WIP"}]}`)
                    break;
                case 3:
                    player.runCommandAsync(`tellraw @s {"rawtext":[{"text":"§l§cStill on WIP"}]}`)
                    break;
            }
            switch (text) {
                case '1234':
                    player.sendMessage('§l§cStill on WIP')
                    break;
            }
})
}
})
});
copper knollBOT
#
Debug Result

There are 2 errors in this [code](#1118556819401482320 message):

<repl>.js:15:24 - error TS2345: Argument of type 'Entity' is not assignable to parameter of type 'Player'.
  Type 'Entity' is missing the following properties from type 'Player': level, name, onScreenDisplay, selectedSlot, and 16 more.

15             suvUi.show(player).then((response) => {
                          ~~~~~~

``````ansi
<repl>.js:33:28 - error TS2339: Property 'sendMessage' does not exist on type 'Entity'.

33                     player.sendMessage('§l§cStill on WIP')
                              ~~~~~~~~~~~

inner quail
#

do i copy this code?

inland shore
#

use sendMessage instead of tellraws