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

Expressions

Expressions allow us to combine or modify variables, such as addition, subtraction, etc.

We already looked at one type of expression, which is the set expression. This assigns a value to a variable.

myFloat = 5.5;

We can modify this float variable through addition, subtraction, division, multiplication expressions.

myFloat = myFloat + 5.0;
myFloat = 5.0 / 3.0;
myFloat = (myFloat * 2.0) - 3.5;
myFloat += 5.0;

Parentheses can be used to specify operation priority as in the third example.

Be careful not to perform operations on incompatible types. This would throw an error:

vector = Vector3(0, 0, 0);
myInt = 5;
Game.Print(vector + myInt);

You can't add a vector and an int together! Instead, lets convert the int to vector first before adding them.

Game.Print(vector + Vector3(myInt, myInt, myInt));

This will print out "5, 5, 5".

We can reference other class fields or method calls in our expressions.

myString = Network.MyPlayer.Name + " joined at " + Convert.ToString(Time.GameTime);

Finally, we can use some symbols to modify bool values. They include the following:

  • == (equals)

  • != (not equals)

  • || (or)

  • && (and)

  • ! (not)

  • < (less than)

  • >(greater than)

  • <= (less than or equal)

  • >= (greater than or equal)

myInt = 5;
myBool = myInt == 5; (this returns true)
myBool = !(myInt == 5); (this returns false)
myBool = myInt != 5; (this returns false)
myBool = (myInt == 4 || myInt == 5); (this returns true)
myBool = myInt == 4 && myInt == 5; (this returns false)
myBool = myInt >= 4; (this returns true)
PreviousVariable InspectorNextConditionals

Last updated 7 months ago