Skip to main content
Prerequisite Basic understanding of Lua programming language is recommended.

Getting Started

Poly Plaza includes a robust Lua scripting system that allows you to create mods and extend game functionality. This guide covers the core functions and features available to Lua scripts.

Global Functions

Learn about the core functions available in all scripts

Character System

Spawn and control characters

UI System

Create custom user interfaces

Steam Integration

Access Steam features

Global Functions

Core Functions

-- Send a notification to the player
SendNotification("Hello World!")

-- Quit the game
Quit()

-- Resume from pause
Resume()

-- Respawn the player
Respawn()

-- Save the game
SaveGame()

-- Open settings menu
OpenSettings()

Character System

Spawn and control characters in the game world:
-- Spawn a character at coordinates
local character = SpawnCharacter({
    x = 100,
    y = 200,
    z = 50
})

Player Functions

Access and modify player data:
-- Get reference to local player
local player = GetLocalPlayer()

-- Money management
local money = player:GetMoney()
player:AddMoney(100)
player:RemoveMoney(50)

-- Experience system
local exp = player:GetExp()
player:AddExp(100)
local level = player:GetLevel()

-- Inventory management
local inventory = player:GetInventory()
local weight = inventory:GetWeight()
local maxWeight = inventory:GetMaxWeight()

UI System

Create and manage custom UI elements:
-- Create a new UI instance
local ui = CreateUI()

-- Configure the UI
ui.ui = {
    title = "My Custom Window",
    elements = {
        { type = "text", content = "Hello World" }
    }
}

-- Show/hide the UI
ui:Show()
ui:Hide()

Steam Integration

Access Steam platform features:
-- Get Steam API instance
local steam = GetSteamAPI()

-- Get user information
local steamId = steam:GetId()
local username = steam:GetUsername()

-- Check DLC ownership
local hasDLC = steam:DoesOwnDLC("dlc_name")

Best Practices

Always check if objects exist before calling their methods to avoid errors.
local character = SpawnCharacter({x = 0, y = 0, z = 0})
if character then
    character:MoveTo({x = 100, y = 100, z = 0})
end

Example Script

Here’s a complete example showing various features:
-- Create a character that opens a UI when interacted with
local npc = SpawnCharacter({
    x = 100,
    y = 100,
    z = 0
})

-- Create UI
local ui = CreateUI()
ui.ui = {
    title = "NPC Dialog",
    elements = {
        { type = "text", content = "Would you like to trade?" }
    }
}

-- Add interaction
npc:BindPrimaryInteraction(function()
    ui:Show()
end)

-- Get player reference
local player = GetLocalPlayer()

-- Send welcome message
SendNotification("Welcome " .. GetSteamAPI():GetUsername())

Next Steps

Join Discord

Get help from the modding community

Youtube tutorials

Check out more examples with my video tutorials