#Need help to update my ui file

1 messages · Page 1 of 1 (latest)

south coral
#

I have a little problem I can't get the ui to work anymore since the last version I think I must have put something in the condition to open the ui

the manifest is up to date

//Module
import { world } from '@minecraft/server'
import { getScore } from '../utilities/utilities'
import { ActionFormData } from '@minecraft/server-ui'

//Condition
world.events.entityHit.subscribe(source => {
    if (source.entity.typeId === 'minecraft:player') {
        if (source.hitEntity.typeId === 'npc:arena') {
            openArenaMenu(source.entity)
        }
    }
})
#
//Arena Main Menu
function openArenaMenu(source) {
    const ActionForm = new ActionFormData()

    ActionForm.title('Arène')
    ActionForm.button('TP Aléatoire', 'textures/items/ender_pearl')
    ActionForm.button('TP Personnalisé', 'textures/items/ender_pearl')
    ActionForm.button('Kit de Départ', 'textures/azure/items/kit')

    ActionForm.show(source).then(response => {
        if (response.canceled) {
            source.runCommandAsync(`playsound note.bass @s`)
            return
        }
        switch (response.selection) {
            case 0:
                if (getScore('autostarterkit', source) == 0) {
                    source.runCommandAsync(`tag @s add rtp`)
                    source.runCommandAsync(`execute @r[type=minecraft:armor_stand,tag=rtp] ~ ~ ~ tp @a[tag=rtp] ~ ~10 ~ false`)
                    source.runCommandAsync(`tag @s remove rtp`)
                } else {
                    source.runCommandAsync(`tag @s add rtp`)
                    source.runCommandAsync(`execute @r[type=minecraft:armor_stand,tag=rtp] ~ ~ ~ tp @a[tag=rtp] ~ ~10 ~ false`)
                    source.runCommandAsync(`structure load kitStarter ~ ~ ~`)
                    source.runCommandAsync(`tag @s remove rtp`)
                }
                source.runCommandAsync(`playsound random.levelup @s`)
                break
            case 1:
                openCustomTPMenu(source)
                break
            case 2:
                openStarterKitMenu(source)
                break
        }
    })
}
vast joltBOT
#
Debug Result

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

<repl>.js:3:26 - error TS2307: Cannot find module '../utilities/utilities' or its corresponding type declarations.

3 import { getScore } from '../utilities/utilities'
                           ~~~~~~~~~~~~~~~~~~~~~~~~
<repl>.js:10:13 - error TS2304: Cannot find name 'openArenaMenu'.

10             openArenaMenu(source.entity)
               ~~~~~~~~~~~~~

south coral
#

What??

vast joltBOT
#
Debug Result

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

<repl>.js:17:21 - error TS2304: Cannot find name 'getScore'.

17                 if (getScore('autostarterkit', source) == 0) {
                       ~~~~~~~~
<repl>.js:30:17 - error TS2304: Cannot find name 'openCustomTPMenu'.

30                 openCustomTPMenu(source)
                   ~~~~~~~~~~~~~~~~
<repl>.js:33:17 - error TS2304: Cannot find name 'openStarterKitMenu'.

33                 openStarterKitMenu(source)
                   ~~~~~~~~~~~~~~~~~~

south coral
#

What is the cmd @open hollow?

open hollow
#

Right click the message > App > Debug

south coral
#
//Function
export function getScore(objective, target, useZero = true) {
    try {
        const obj = world.scoreboard.getObjective(objective)
        if (typeof target == 'string') {
            return obj.getScore(obj.getParticipants().find(v => v.displayName == target))
        }
        return obj.getScore(target.scoreboard)
    } catch {
        return useZero ? 0 : NaN
    }
}
vast joltBOT
#
No errors

No errors in [code](#1077617213365829652 message)

south coral
#

I'm confused I don't see what the problem is

open hollow
#

Is the UI can be opened?

#

Also any error from content log?

south coral
#

Nothing

#

Probably the open condition

#

wait i check the doc

#

@open hollowSorry for ping but i dont find

#

Not error... but not open the ui

open hollow
#

How the UI is open?

south coral
# open hollow How the UI is open?

With this

//Condition
world.events.entityHit.subscribe(source => {
    if (source.entity.typeId === 'minecraft:player') {
        if (source.hitEntity.typeId === 'npc:arena') {
            openArenaMenu(source.entity)
        }
    }
})
open hollow
#

So the UI is should be opened when player hit npc:arena right?

open hollow
#
world.events.entityHit.subscribe(source => {
    world.say("1")
    if (source.entity.typeId === 'minecraft:player') {
        world.say("2")
        if (source.hitEntity.typeId === 'npc:arena') {
            world.say("3")
            openArenaMenu(source.entity)
        }
    }
})
#

Try run this and tell me what appear on chat

south coral
#

Sorry I'm boring but I'm struggling with the doc even with the node install modules I have the impression that the autocompletion works halfway

#

wait

#

..

#

@open hollow
i am stupid
I used the villagers a lot lately (modify the nbt) and to open the villagers have to interact I got used to it...

and for the ui I did not knock but use by reflex 😅 😂

#

i am so srry...

open hollow
#

That's fine

#

Atleast still works