#entity interact not opening

1 messages · Page 1 of 1 (latest)

twilit aurora
#
import { system, world, ItemStack} from "@minecraft/server";
import { ModalFormData, ActionFormData } from "@minecraft/server-ui";
let world = world.getDimension("overworld")

//gr_lab
system.runInterval(() =>{
    for(let player of world.getPlayers()){
        if(player.hasTag("gr_lab_interact")){
            gr_lab_interact(player)
            player.removeTag("gr_lab_interact")
        }
  }
  function gr_lab_interact (player) {
    const gui = new ActionFormData();

    gui.button('Jump Up!', 'textures/gui/menu/jump_up_icon')
    gui.button('Exit!', 'textures/gui/menu/exit_icon')
    gui.show(player).then(result => {

        if (result.selection === 1) {
            jump_up(player)
        }
        if (result.selection === 4) {
            exit(player)
        }
    }
)
}

function jump_up(player) {
    player.runCommandAsync("event entity @e [family=wolf,c=1,r=5] gr_lab:to_jump_up");
}

function exit(player) {
    player.runCommandAsync;
  }
})
silver ivy
#

This doesn't make sense.

#

The world is already a property of the server why make another variable that overwrites that? That ain't got.

twilit aurora
#

I to worked before

#

with single entity

silver ivy
#

that's bad...

twilit aurora
#

now when I added more it stopped working

silver ivy
#

Why put function inside of a runtInterval?

twilit aurora
#

¿

silver ivy
# twilit aurora ¿
system.runInterval(() => {
  for (const player of world.getPlayers()) {
    if (player.hasTag('gr_lab_interact')) {
      player.removeTag('gr_lab_interact');
      gr_lab_interact(player);
    }
  }
});

function gr_lab_interact(player) {
  const gui = new ActionFormData()
        .button('Jump Up')
        .button('Exit!');

  gui.show(player).then(({ selection }) => {
    switch (selection) {
      case 1:
        jump_up(player);
        break;

      case 4:
        exit(player);
        break;

      default: break;
    }
  });
}
twilit aurora
#

no errors but doesn't work