#What can I do now?

1 messages · Page 1 of 1 (latest)

muted dirge
#
const scheduleID = system.runSchedule(() => {
  system.clearRunSchedule(scheduleID);
  player.addTag('test');
  letter_process = -1;
}, text.length);```I used to use this for a piece of my code but since `runSchedule` has been removed I'm not exactly sure what I can do for a replacement of this. Can I get some help on this? (I know it's been updated to `runInterval` but I just don't know what I would use for the `clearRunSchedule`)
regal maple
#

send code

muted dirge
# regal maple send code
import { system, world } from '@minecraft/server'

var letter_process = 0;
system.runInterval(() => {
  [...world.getPlayers()].forEach((player) => {
    if (!player.hasTag('test')) {
      var text = 'This is some example text.';
      if (letter_process < text.length) {
        letter_process = letter_process + 1;
      }
      player.onScreenDisplay.setActionBar(`${text.substring(0, letter_process)}`);
      player.runCommandAsync(`playsound random.click @s ~~~ 1.0 1.5`);
      const scheduleID = system.runSchedule(() => {
        system.clearRunSchedule(scheduleID);
        player.addTag('test');
        letter_process = -1;
      }, text.length);
    }
  });
});```
#

It used to work fine but like I said, the runSchedule and clearRunSchedule are not a think anymore so I'm not sure what I could do to fix it.

regal maple
#
system.runTimeout(() => {
    player.addTag('test');
    letter_process = -1;
}, text.length)
muted dirge
#

i was thinking about this way too hard if that's what fixes it lmao

muted dirge
regal maple
#

well, thats how text is set up there

#

what exactly r u tryna do there?

muted dirge
regal maple
#

like 1 char after every 26 ticks?

muted dirge
#

it just needs to run by adding 1 character at a time to the actionbar until it reaches the end of the given var text which is why it is set to text.length

#

however, when told to so it doesn't want to finish the message before stopping

#

@regal maple this is all it managed to push out before stopping

#

then afterwards its always this, using runTimeout doesn't seem to give it enough time to read the text

regal maple
#
var letter_process = 0;
system.runInterval(() => {
  [...world.getPlayers()].forEach((player) => {
    var text = 'This is some example text.';
    if (!player.hasTag('test')) {
      if (letter_process < text.length) {
        letter_process++;
      }
      player.onScreenDisplay.setActionBar(`${text.substring(0, letter_process)}`);
      player.runCommandAsync(`playsound random.click @s ~~~ 1.0 1.5`);
      system.runTimeout(() => {
        player.addTag('test');
        letter_process--;
      }, text.length * 2)
    }
  });
});
muted dirge
#

thanks!