#Can someone help me to do this?

1 messages · Page 1 of 1 (latest)

native hearth
#

Someone gave me a ready-made form, I would like it to go from looking like this:

try {
      if (!player.hasTag("admin") && item.typeId == "minecraft:stick") {
        exDef.OnFormOne.show(player).then(
          (result) => {
            if (result.selection == 0) {
              exDef.OnFormTwo.show(player).then(
                (result) => {
                  if (result.selection == 0) {
                    player.runCommandAsync('say Triggered One, form1')
                  }
        
                  if (result.selection == 1) {
                    player.runCommandAsync('say Triggered Two, form 1')
                  }
                }
              );
              
              player.runCommandAsync('say Triggered One, form 2')
            }
        
            if (result.selection == 1) {
              player.runCommandAsync('say Triggered Two, form 2')
            }
          }
        );
      }```

I would like the commands that are executed when a button is touched to look like this
```js
function battle(player) {
    new ModalFormData()
        .title('§3§lBattle Pass')
        .slider("Claim Your Tier! ", 1, 100, 1)
        .show(player).then((r) => {
            if (r.formValues[0] === 0) {
                player.runCommandAsync('say test');
            }
        });
} ```

Here is my code
#

no?

#

oh ok?

#

@final echo

#

code for forms.js```js
import {
world
} from '@minecraft/server';
import {
ActionFormData,
ModalFormData,
MessageFormData
} from '@minecraft/server-ui'
import { getScore } from './functions.js';

const allPlayers = Array.from(world.getPlayers(), (plr) => plr.name);

for (const player of world.getPlayers()) {
var OnFormTwo = new ActionFormData()
.title('Title Here')
.body(Form Body, tu dinero: ${getScore(player, 'Money')})
.button('Button One')
.button('Button Two');

var OnFormOne = new ActionFormData()
.title('Title Here')
.body(Form Body, tu dinero: ${getScore(player, 'Money')})
.button('Button One')
.button('Button Two');

var OnModalFormOne = new ModalFormData()
.title('Title Here')
.dropdown('Dar diamantes', allPlayers)
.slider('Cantidad Diamantes', 1, 64, 1);
}

let exDef = { OnFormOne, OnFormTwo, OnModalFormOne }
export default exDef;```

#

ok

#

ok

#

the functions.js code only has the getScore.

#

ok

#

I didn't mention you but well xd

#

I replied to your message, but ok.

#

hahaha stop answering me

native hearth
#

@lime steeple

lime steeple
#

native hearth
#

hello, you are my trusted developer

#

☺️

lime steeple
#

¿Cuál es el error/problema?

native hearth
#

It is that the code that they gave me is confusing and I want it to look like the one below.

native hearth
#

here are the forms

#

If it's not too much trouble, could you?

#

sorry for not knowing

lime steeple
#

¿Quieres entender el código?
o no eres capaz de ponerlo si fuera necesario?

native hearth
#

I would like you to do it

lime steeple
#

¿Hacer lo?

native hearth
#

that you make the code more understandable

#

yes

lime steeple
#

veo

#

Dame algo de tiempo

native hearth
#

(I speak Spanish)

lime steeple
#

lo sé

native hearth
#

It's just that someone else came asking, I wanted to clarify

#

How gratifying it is to see that you translate the messages

lime steeple
#

dame un poco de tiempo enviaré el código comprensible aquí en un momento

native hearth
#

Don't worry about time.

#

take the time you need

lime steeple
#

déjame saber si tienes algún problema, pero sí, te ayudaría más tarde.

native hearth
#

ok

#

let me check

#

Hey, and couldn't you make each form have its own runCommandAsync?

#

I mean each one separately

#

OnFormOne
runCommandAsync
runCommandAsync

OnFormTwo
runCommandAsync
runCommandAsync

OnFormThree
runCommandAsync
runCommandAsync

lime steeple
#

¿Por qué necesitas eso?

native hearth
#

Because I want to make a menu by categories

lime steeple
#

entonces runCommandAsync normal funcionará para eso

native hearth
#

that's why

native hearth
#

but each separate

lime steeple
#

funcionará mismo
darle una oportunidad

native hearth
#

would this not work?

#
try {
      if (!player.hasTag("admin") && item.typeId == "minecraft:stick") {
        exDef.OnFormOne.show(player).then(
          (result) => {
            if (result.selection == 0) {
              exDef.OnFormTwo.show(player).then(
                (result) => {
                  if (result.selection == 0) {
                    player.runCommandAsync('say Triggered One, form1')
                  }
        
                  if (result.selection == 1) {
                    player.runCommandAsync('say Triggered Two, form 1')
                  }
                }
              )
            }
          }
        );
        exDef.OnFormTwo.show(player).then(
          (result) => {
            if (result.selection == 0) {
              exDef.OnFormTwo.show(player).then(
                (result) => {
                  if (result.selection == 0) {
                    player.runCommandAsync('say Triggered One, form1')
                  }
        
                  if (result.selection == 1) {
                    player.runCommandAsync('say Triggered Two, form 1')
                  }
                }
              );```
lime steeple
#

deberia de funcionar

native hearth
#

nice

native hearth
opaque remnantBOT
#
Remember M9

o simplemente hacer

merry ether
#
console.warn(JSON.stringify(result,0,3))
native hearth
#

What's that?

native hearth
#
try {
      if (!player.hasTag("admin") && item.typeId == "minecraft:stick") {
        exDef.OnFormOne.show(player).then(
          (result) => {
            if (result.selection == 0) {
              exDef.OnFormTwo.show(player).then(
                (result) => {
                  if (result.selection == 0) {
                    player.runCommandAsync('say Triggered One, form1')
                  }
        
                  if (result.selection == 1) {
                    player.runCommandAsync('say Triggered Two, form 1')
                  }
                }
              )
            }
          }
        );
        exDef.OnFormTwo.show(player).then(
          (result) => {
            if (result.selection == 0) {
              exDef.OnFormOne.show(player).then(
                (result) => {
                  if (result.selection == 0) {
                    player.runCommandAsync('say Triggered One, form1')
                  }
        
                  if (result.selection == 1) {
                    player.runCommandAsync('say Triggered Two, form 1')
                  }
                }
              )
            }
          }
        )
      };
      
      if (player.hasTag("admin") && item.typeId == "minecraft:stick") {
        exDef.OnFormTwo.show(player).then(
          (result) => {
            if (result.selection```
#

@lime steeple

lime steeple
#

intente esto, no soy tan bueno para obtener los errores y problemas con solo mirar.

#

espero que entiendas

#

o use el bot depurador para eso, recuerde que para usar ese bot puede proporcionar el código o archivo completo. ¿bueno?

#

Por ejemplo

#
world.events.beforeItemUse.subscribe((data) => {
data.item
data.player //error
})
willow bladeBOT
#
Debug Result

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

<repl>.js:3:6 - error TS2339: Property 'player' does not exist on type 'BeforeItemUseEvent'.

3 data.player //error
       ~~~~~~

lime steeple
#

y ahora

world.events.beforeItemUse.subscribe((data) => {
data.item
data.source //no error
})
willow bladeBOT
#
No errors

No errors in [code](#1085022508857696347 message)