#World.say is no working for me (i'm begginer on this)

1 messages ยท Page 1 of 1 (latest)

stark compass
#
import {system, world } from '@minecraft/server';
let decir = void system.runInterval((world.say('say Hello starter!')), 20);

I don't know what i'm doing wrong, the compiler sends

"Property 'say' doesn't exist on type 'world'

iron hill
#

world.say world.sendMessage

stark compass
# iron hill ~~world.say~~ world.sendMessage
src/main.ts:2:20 - error TS2345: Argument of type 'void' is not assignable to parameter of type '() => void'.
                                                        2 system.runInterval((world.sendMessage('say Hello starter!')), 20);                                                                 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~                                                                                                          
Found 1 error in src/main.ts:2
iron hill
#
import { system, world } from '@minecraft/server';

system.runInterval( () => { 
  world.say('say Hello starter!')
}, 20);
stark compass
iron hill
stark compass
# iron hill ^

It compiled, i'll test.

One questions, what's the meaning of "() => {}" structure?

iron hill
#

its known as arrow function

#
function() {

}

() => {

}```
stark compass
# iron hill ^

Minecraft says:

[Scripting][error]-Plugin [Invisible Armors - 0.0.1] - [main.js] ran with error: [TypeError: not a function    at <anonymous> (main.js:5)
]

iron hill
#

whats u game version

stark compass
iron hill
#

well you are using preview version api on stable version

#

you need preview version

#

or use old version types

stark compass
#

Where can i find the old types?

iron hill
#

what u used now?

stark compass
iron hill
#

to install types

stark compass
#

The command prompt. (?)

iron hill
#

which command i mean

stark compass
#

Tsc

#

I send tsc and that compiles the .ts

iron hill
#

i mean the npm command

stark compass
#

I don't used any npm command, except for installing Typescript

iron hill
#

im asking for that only

#

what command u used to install types

stark compass
#

Oh ๐Ÿ˜…

#

npm install -g typescript

iron hill
#

npm i @minecraft/server

#

is for stable

stark compass
#

And the "world.sendMessage" things are the same?

iron hill
#

use .say for stable

#

rest is same

stark compass
reef bridgeBOT
#
Debug Result

JavaScript/TypeScript code blocks not detected in [message](#1083044630595108865 message ).
Example:
```js
console.log("Hi mom!")
```

iron hill
#

oh yea

#

?await

zealous breachBOT
#
Tick Awaition

since 1.19.50, we recieved two new methods that can be used for delaying function execution

// next tick
 system.run(func); 

// like setInterval
system.runSchedule( func, tickDelay );

// like cancel run
system.clearRun( runId );

// like clearInterval
system.clearRunSchedule( intervalId );

Example
for running code every 20ticks (1sec)

const TICKS_IN_SEC = 20;

const runSchedule = system.runSchedule( () => {
    console.warn( "show this message every " + TICKS_IN_SEC + " ticks");
}, TICKS_IN_SEC );

system.clearRunSchedule( runSchedule ); //stop execution loop
iron hill
#

system.runSchedule

grand ledge
stark compass
#

Where can i find all the properties for stable Minecraft?

iron hill
grand ledge
#

Np,it was just a jk

iron hill
#

xd

stark compass
# grand ledge Docs

Which docs? RunInterval exist in where i'm using.. Or how i can know if it's a preview/stable?

iron hill
#

docs are for beta

#

๐Ÿฅฒ

grand ledge
#

Vsc or bridge
Idk