Your first script
Create a file in config/questscript/scripts/. Your selected language tab is remembered and applied to other synchronized examples.
- JavaScript
- Python
welcome.js
world.afterEvents.playerJoin.subscribe((event) => {
world.getPlayer(event.playerId)?.sendMessage('Welcome to the server!');
});
welcome.py
def on_player_join(event):
player = world.get_player(event.player_id)
if player is not None:
player.send_message('Welcome to the server!')
world.after_events.player_join.subscribe(on_player_join)
Load the file with:
/qs load welcome.js
Use welcome.py for Python.
Python API
Python type stubs describe the snake_case Python projection of the shared API; JavaScript declarations use camelCase. Events, players, world access, inventory, and scheduling retain the same semantics in both languages.