#help with system.runTimeout
1 messages · Page 1 of 1 (latest)
system.runTimeout(() => {
for (let player of world.getPlayers()){
let inventory = player.getComponent("minecraft:inventory");
for (let i = 0; i < 36; i++){
let item = inventory?.container.getItem(i);
let test = item?.typeId
switch (test){
case undefined:
continue;
break;
case "se:philosopher_stone":
player.runCommandAsync("function potion_query_3_1")
break;
}
}
}
}, 1800)```
Pd: It works, all code run, but it doesn't work well
why it doesn't work well
say what is happening and say what you expect
Ok,
It should run more than one time, for example, my idea is that it gives me items for each 90 seconds, but it gives me the item one time, how I said. I try putting 1800 ticks of delay but nothing happens, and I try with 20 ticks of delay and nothing
I would want that, while I have the item into inventory, it gives me items for each 90 seconds
But just gives me one time
runInterval not runTimeout
I gonna assume that you are only calling the function one time
Timeout just run one time, interval runs more than one time
No it is like an sleep or delay function
Well, finally I could make it. I used the runInterval function that I had
I made a system using scoreboards
Thank you very much
it's the loop thats multiplying the /function
What did you mean?
like
for every philosopher_stone u have in ur slot, it triggers that much
Ummmmmmmm okay
I get it
Well, important thing is that I solved it 😅
system.runInterval(() => {
for (let player of world.getPlayers()){
let inventory = player.getComponent("minecraft:inventory");
for (let i = 0; i < 36; i++){
let item = inventory?.container.getItem(i);
let test = item?.typeId
switch (test){
case undefined:
continue;
break;
case "se:artifact":
player.runCommandAsync("scoreboard objectives add Kills dummy");
player.runCommandAsync("scoreboard players add @s Kills 0");
player.runCommandAsync(`titleraw @s actionbar {"rawtext":[{"text":"§bTienes §e"},{"score":{"name":"@s","objective":"Kills"}},{"text":"/10 §bkills§r"}]}`);
break;
case "se:artifact_ii":
player.runCommandAsync("scoreboard objectives add Kills dummy");
player.runCommandAsync("scoreboard players add @s Kills 0");
player.runCommandAsync(`titleraw @s actionbar {"rawtext":[{"text":"§bTienes §e"},{"score":{"name":"@s","objective":"Kills"}},{"text":"/10 §bkills§r"}]}`);
break;
case "se:philosopher_stone":
player.runCommandAsync("scoreboard objectives add pot dummy");
player.runCommandAsync("scoreboard players add @s pot 1");
player.runCommandAsync("scoreboard players set Potion pot 1800");
player.runCommandAsync("execute if score @s pot = Potion pot run function potion_query_3_1")
}
}
}
})```
I did it
why not use the scoreboard api
Because I feel more comfortable using /scoreboard for the functions
But thanks for the fact
By the way, @rich mist , is there a way to test if the player has equipment an item and if him has x health value?
Because the animation that I made just works one time
yeah...
Nice, but what's the component? Minecraft:health?
Ummm okay
But how I get the value?
Ahhhhhhhh okay
Thank you very much
It returns a number, right?

this module https://jaylydev.github.io/scriptapi-docs/1.20.10/modules/_minecraft_server_1_4_0_beta.html
Documentation for Script API - v1.20.10
I already learned, thanks