Console Tutorial

From Data Realms Wiki

Jump to: navigation, search

Contents

The Console

The Lua console is a very useful feature that allows you to test Lua expressions, access game functions, or just mess around. The console is displayed by pressing ~ or / on the keyboard. Statements are interpreted as a line of Lua in the context of the Cortex Command game engine.

Console Options

The Cortex Command console comes with an object for accessing the console: ConsoleMan. ConsoleMan includes several variables and functions to make the console fore flexible and powerful.

Screen Size

ConsoleMan.ScreenSize is a number between 0 and 1 that indicates the percent of the screen that the console takes up. The following example makes the console take up half of the screen:

  1. ConsoleMan.ScreenSize = .5

Saving Text

Cortex Command's console includes functions to output console text to a file:

Simple Console Tricks

Changing Funds

To change your funds type

  1. ActivityMan:GetActivity():SetTeamFunds(5000,0)

This may seem like overkill just to change one variable, but it is necessary. The only things you should bother changing in this line are the two numbers in the final round brackets. The first is the number that the funds are changed to. The second is the team whose funds will be changed. By default the player is Team 0 and the computer controls Team 1.

Gibbing Actors

Ever just wish you could kill all of the actors on the other team? Let's see what we can do with the console. To gib all actors in play, type

  1. for actor in MovableMan.Actors do actor:GibThis() end

This code gibs all actors, but that's not what we want. A little more needs to be added:

  1. for actor in MovableMan.Actors do if actor.Team == 1 then actor:GibThis() end end

Now this code checks if the actor's team is 1 and gibs it if it is. Note that "Health", "Team", and "Actors" use periods (.) instead of colons (:). This differentiates between member functions and member variables.

Changing Health

Give yourself super-actors or handicap the enemy by changing the Health variable. This uses a for statement like we used with GibThis(), but instead changes actor health. This line will change all of your actor's Healths to 200:

  1. for actor in MovableMan.Actors do if actor.Team == 0 then actor.Health = 200 end end

This code, on the other hand, will just make all enemies fall over dead:

  1. for actor in MovableMan.Actors do if actor.Team == 1 then actor.Health = 0 end end
Personal tools