Custom Maps & Logic
  • Custom Map Tutorial
    • Custom Map Introduction
    • Your first map
    • Map Navigation
    • Object Selection
    • Object Positioning
    • Object Attributes
    • Shortcuts and Macros
    • Editor Settings
    • Built-in Components Common Errors
    • Map Performance
    • Custom Assets
      • Your first Asset Bundle
      • Asset Bundles in Map Editor
      • Asset Bundles in Game
      • Adding to Asset Bundles
      • Asset Bundle naming
  • Custom Logic Tutorial
    • Custom Logic Introduction
    • Your first script
    • Variables
    • Types
    • Variable Inspector
    • Expressions
    • Conditionals
    • Loops
    • Functions
    • Coroutines
    • Classes
    • Static Classes
    • Components
    • Extensions
    • Cutscenes
    • Static Objects
    • Networking
    • Commenting
  • Reference
    • Static Classes
      • Game
      • Network
      • Map
      • UI
      • Time
      • Convert
      • String
      • Input
      • Math
      • Random
      • Cutscene
      • Camera
      • RoomData
      • PersistentData
      • Json
      • Physics
    • Objects
      • Component
      • Object
      • Character
      • Human
      • Titan
      • Shifter
      • MapObject
      • Transform
      • Player
      • NetworkView
      • Color
      • Vector3
      • Quaternion
      • Dict
      • List
      • Range
      • LineCastHitResult
      • MapTargetable
      • Random
    • Callbacks
      • Main
      • Components
  • Examples
    • Gamemodes
      • Survive
      • Waves
      • Endless
      • Racing
      • Blade PVP
      • Thunderspear PVP
      • Titan Explode
      • Cranked
      • More Examples
    • Components
      • SupplyStation
      • Daylight
      • PointLight
      • Rigidbody
      • NavMeshObstacle
      • Cannon
      • Dummy
      • Wagon
      • Tag
      • KillRegion
      • DamageRegion
      • MovePingPong
      • RacingCheckpointRegion
      • RacingFinishRegion
      • TeleportRegion
      • Animal
      • SignalMover
      • SignalSender
      • More Examples
Powered by GitBook
On this page
  1. Custom Logic Tutorial

Your first script

Now that you know how to load custom logic into a map, let's create our first custom logic script. This script will be simple - it will start the game and print "Hello world" to the chat window.

The Main class

The core of every custom logic script is the Main class. This class is responsible for most of the game mode logic, and receives important event callbacks.

class Main
{
    function OnGameStart()
    {
        Game.Print("Hello world");
    }
}

Here, class Main means we are declaring a new class named Main. The class named Main is a special class that is always running and always receives event updates.

function OnGameStart() means we are declaring a new function named OnGameStart that takes no parameters. OnGameStart is a special function known as an event callback. This means that it gets called by the interpreter under certain circumstances. In this case, OnGameStart is called once every time the game begins.

Game.Print("Hello world"); means we are calling the Game.Print function, which prints out a message to the chat window.

Notice that curly braces are used to enclose classes and functions, while semicolons are used to end statements.

PreviousCustom Logic IntroductionNextVariables

Last updated 7 months ago