Hi, newbie here!
I'm toying around with scripting with Typescript, and I'm wondering how, from a list of players (from world.getAllPlayers()) I can get a player variable (say, from players[0]) to use player methods with. VS code marks players[0] has an error because it cannot know what it is, how can I fix that? I'd like to get to a point where VS code shows me autocomplete for player, even though it comes from a list of players
#Players index and VS code
1 messages · Page 1 of 1 (latest)
Take a look at this guide: https://wiki.bedrock.dev/scripting/typescript.html
I've gone through it, but I'm not sure what you're referring to in particular here
The entire article, follow step by step. It enables Typescript usage and intellisense
I've followed the article, I still don't have much things about Intellisense in the way I wanted to
I still can't do anything with players[0]
I have a script of the likes of:
import { world, Player, Entity, system, ButtonPushAfterEvent } from "@minecraft/server";
let TICK = 0;
function init() {
world.sendMessage("Test");
}
function ButtonPushed(){
world.sendMessage("Pushed!");
let players = world.getAllPlayers;
let message = players[0].toString;
world.sendMessage(message);
}
function gameTick() {
TICK ++;
if(TICK % 10 === 0){
//init();
}
world.afterEvents.buttonPush.subscribe(ButtonPushed);
system.run(gameTick);
}
system.run(gameTick);```
Either I run into an error without knowing what, or I'm not doing things the way I should
What intellisense are you getting? Also it should be world.getAllPlayers()
T-T nvm had to restart for some reason it fixed everything