#Trouble with .runInterval() method

1 messages · Page 1 of 1 (latest)

brisk salmon
#

Hello. I'm very new to scripting, and am having some trouble with getting a function to run every tick. Currently my code is:

import { world, system } from "@minecraft/server";

system.runInterval(() => {
ticker();
}, 1);

...

In game the ticker() function seems to only execute once when I reload the pack. Is this an error in my .runInterval() syntax or would it be a problem in the ticker() function? Thanks

waxen osprey
#

the runInterval is fine

brisk salmon
waxen osprey
#

lemme see if system.currentTick even works
i just use a i++ most of the time

waxen osprey
brisk salmon
#

Hm, alright. Thanks for the help

brisk salmon
# waxen osprey system.currentTick works so probaly something wrong with your logic

Out of curiosity, do you know what I should look for? The function seems to run for 1 tick and then subsequently stops, so would there be a variable that when initialized or given a value would break things? I'm not familiar enough with JavaScript to know of the little errors that might pop up, so any notes on things to be wary of would be very helpful.

torpid turtleBOT
#
Debug Result

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

main.js:31:9 - error TS2322: Type 'string' is not assignable to type 'number'.

31         altTPS = tps; //ERROR (fixed?): 'string' not assignable to type 'number'
           ~~~~~~

``````ansi
main.js:34:9 - error TS2322: Type 'string' is not assignable to type 'number'.

34         redstoneTPS = tps; //ERROR (fixed?): 'string' not assignable to type 'number'
           ~~~~~~~~~~~

waxen osprey
#

Not sure

#

thats just type error thing which should not be an issue

brisk salmon
#

Okay. Thanks for your help