#Help

1 messages · Page 1 of 1 (latest)

queen swift
#

It was working just fine but while I was adding stuff I forgot to make sure It still works and it now won't open.

civic patrolBOT
#
Debug Result

There are 85 errors in this [code](#1135837895794638940 message).
Please read the attached file for the result.

trim chasm
#

firstly, idk why you put the same code twice

#

secondly, that is a terrible way to store all the data

#
import { world, Player, system } from "@minecraft/server";
import { ModalFormData } from "@minecraft/server-ui";

function hotbarDetect() {
  // Rest of the code...
}

function getTwoDigitNumber(value) {
  // Rest of the code...
}

function hour() {
  // Rest of the code...
}

function minute() {
  // Rest of the code...
}

function second() {
  // Rest of the code...
}

hotbarDetect();
hour();
minute();
second();

// Open UI when stick is used
world.afterEvents.itemUse.subscribe(event => {
  const { source: player, itemStack } = event;
  if (event.itemStack.typeId === "kc:sword_combat_menu") {
    openModalTemplate(player);
  }
});

// Put UI into a function
function openModalTemplate(player) {
  const slots = [
    "1", "2", "3", "4", "5", "6", "7", "8", "9", "10",
    "Head-slash", "Right-shoulder-slash", "Left-shoulder-slash",
    "Right-gut-slash", "Left-gut-slash", "Right-leg-slash",
    "Left-Leg-slash", "Rotational-slash", "Blade-thrust"
  ];
  const moves = ["Idle", "Step", "Back-step", "Leap"];

  new ModalFormData()
    .title("bSword §4|§b Combat Configurations") // Title of the form
    .dropdown('Pick the number of attacks:', slots) // Dropdown 1

    // Add rest of the dropdowns here...

    .show(player)
    .then(({ formValues }) => {
      const dropdownResults = formValues.map(value => slots[value]);
      if (dropdownResults[2] === "Hello") {
     player.runCommand('say hello') 
}
// Do something with the array of dropdown results
    });
}

customise this

#

to get the results, use dropdownResults[dropdown number - 1]

#

-1 is because it starts at 0 in arrays

civic patrolBOT
#
Debug Result

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

<repl>.js:55:31 - error TS18048: 'formValues' is possibly 'undefined'.

55       const dropdownResults = formValues.map(value => slots[value]);
                                 ~~~~~~~~~~

``````ansi
<repl>.js:55:61 - error TS2538: Type 'false' cannot be used as an index type.

55       const dropdownResults = formValues.map(value => slots[value]);
                                                               ~~~~~

``````ansi
<repl>.js:55:61 - error TS2538: Type 'true' cannot be used as an index type.

55       const dropdownResults = formValues.map(value => slots[value]);
                                                               ~~~~~

queen swift
#

Thank you

queen swift
trim chasm
queen swift
#

👍

queen swift
trim chasm
#

whats ur error

queen swift
#
    .then(({ formValues: [dropdown] }) => {
      const { formValues } = ModalFormResponse;
      const dropdownResults = attacks1[dropdown];
      if (dropdownResults === "1") {
     player.runCommand('scoreboard players set @s attack_pattern2 2') 
}

I changed it to this but it didn't work either

trim chasm
#
    .then(({ formValues: [dropdown] }) => {
      const dropdownResults = attacks1[dropdown];
      if (dropdownResults === "1") {
     player.runCommand('scoreboard players set @s attack_pattern2 2') 
}

try this

queen swift
#

Ok