LogoLogo
  • Introduction
  • sdks
    • Feature Comparison
    • Unity
    • Godot
    • Defold
    • LÖVE
    • Unreal
  • Quick Start
    • Unity
    • Godot
    • Defold
    • LÖVE
    • Unreal
  • Server Side
    • Entities
    • Chunks
    • Dimensions
    • Events
    • Logging
    • Lua Environment
    • Git Primer
    • Physics
  • HTTP API
    • Authentication
    • Player API
  • Api Reference
    • Entity API
      • Create
      • Message
    • Client API
      • Message
    • Dimension API
      • Create
      • Delete
      • List
    • Events API
      • on_player_join
      • on_player_leave
    • Table API
      • Append
      • Remove
      • Join
    • Util API
      • Time
      • TimeMillis
    • HTTP Request API
      • Get
      • Post
      • Put
      • Delete
    • Physics API
      • NewBody
      • NewBoxShape
      • NewSphereShape
Powered by GitBook
On this page
  1. Api Reference
  2. Events API

on_player_join

on_player_join(player, first)

An event which runs when a player joins the game.

This function may only be called from within the events.lua file, and must be returned in a table at the end of the file.

Parameters:

Name
Type
Description

player

Entity

The joining player's entity.

first

boolean

True, if this player has never joined before.

Example:

When the player joins, print whether it is their first time.

-- events.lua
local function on_player_join(player, first)
	if first == true then 
		print("Player "..player.ID.." has joined for the first time! "..
			"They are in chunk: ("..chunk.X..","..chunk.Y..")")
	else
		print("Player "..player.ID.." has joined this game before. "..
			"They are in chunk: ("..chunk.X..","..chunk.Y..")")
	end
end

-- Prints:
-- Player e2e838b4-a250-4a89-9f1d-acae063201b8 has joined for the first time! They are in chunk: (0,0)

-- Or prints:
-- Player e2e838b4-a250-4a89-9f1d-acae063201b8 has joined this game before. They are in chunk: (0,0)
PreviousEvents APINexton_player_leave

Last updated 3 months ago