Scripting Commands

From Cube Wiki
Jump to: navigation, search

Command Reference

The following is an excerpt of commands available to you for scripting, refer to your local documentation to find out all commands available. On this page you will find commands and examples of usage to help get you into CubeScript. Almost all commands can be used in scripting, although a map-cfg cannot override persitent values - including among others watersubdiv, waterlod, maxparticledistance and fov among others. You can't override them in a map-cfg - a message will be output to your console in such cases - you can only set them manually. It counts as a manual setting if used via the menu!

exec C

Executes all commands in config file C.

history N

Executes the Nth command in the command line history. For example, binding "history 0" to a key allows you to quickly repeat the last command typed in (useful for placing many identical entities etc.)

saycommand P...

This puts a prompt on screen where you can type stuff into, which will capture all keystrokes until you press return (or esc to cancel). You may press tab to autocomplete commands/aliases/variables, and up/down keys to browse the command history. If what you typed started with a "/", the rest of it will be executed as a command, otherwise its something you "say" to all players. default key = T for talk, ` for commands. If P is prefix to insert to the buffer, (default key ` inserts a /).

The following example will prepare one of three messages to be output via say, but don't be fooled, you can execute anything else besides say with this too. It binds the key K to prepare the command onto the console upon release of the key. You will only see a beautified display - for example : GREET #2 But if you confirm the command, it will execute the prepared saycommand.

// ----------------
// greetings :
// ----------------

GMSG0   = "Hi! Let's Get It On!"
GMSG1   = "Hello! Get Ready To Be Cubed"
GMSG2   = "Hi There! Let's Fight Some..."

// change MAXC if you add/remove greetings above
// the first index to use (default : 0)

// ----------------
// beautification :
// ----------------

CCOL = ":^L0"
// JAT : sic! ::
JAT = "                                                                                                                                         "
// :: JAT : sic!
J4U = (concatword $JAT ";")

// ----------------
// functionality :
// ----------------

// bogus alias, to allow for pretty command call
GREET = []

greeting = [
    CIN = (concatword "#" $GMSGCOUNT)
    CVN = (concatword "$" GMSG $GMSGCOUNT)
    // this is what to output - it will look pretty
    // and even ignores any surplus hitting of keys by the user ;)
    CSC = (concat GREET $CCOL $CIN $J4U say @$CVN ";foo = bar")
    onrelease [saycommand [/@@CSC]]

bind K [greeting]
weapon a b c

Tries to select weapons a, b & c, in that order, if they have ammo ( 0 =`` fist, 1 ``=`` sg, 2 ``=`` cg, 3 ``=`` rl, 4 ``=`` rifle, 5 ``= gl ). If none of the 3 indicated have any ammo, it will try the remaining weapons for one with ammo (in order 3/2/1/4/0) (the fist needs no ammo). You can use the weapon command with 0 to 3 arguments. examples:

// close up selection :
weapon 2 1 0

// far away selection :
weapon 4 3 2

// medium distance selection :
weapon 3 2 1

// humiliate selection :)
weapon 0

// just switch to anything with ammo :

In any selection, it will skip whichever weapon you have currently selected, so executing a weapon command repeatedly toggles between the two best weapons with ammo within a given selection. default keys 0 to 4 select the corresponding weapons, with sensible default alternatives, middle mouse button is a simple weapon switch.

alias N A
N = A

Binds name N to commands A, after which you can use N as a shortcut for A. You may re-bind N as often as you like, call it recursively etc. You may use N = A as a shortcut for alias.


Move you in said direction (defaults to cursor keys).


Fires the current weapon. default = left mouse


Triggers a jump. default key space & right mouse.

fov N

Sets your FOV to 10..150.

setfullscreenshader Name

Sets your favourite fullscreen shader. Active permanently once set. Use without name argument to turn it off. Current example shaders: invert, gbr, sobel, bloom


Writes out "screenshotN.bmp", where N is the number of milliseconds since cube was launched (default key = F12). A little modified example :

// do a pretty screenshot (hiding HUD and all)
MPscreenshot = [
    phh = $hidehud
    phs = $hidestats
    phg = $hudgun
    hudgun 0
    hidestats 1
    hidehud 1
    sleep 2 screenshot
    sleep 3 [hudgun $phg; hidestats $phs; hidehud $phh;echo SCREENSHOT made]

hidehud b

Turns on/off the entire hud display, which includes rendering stats, ammo, and echoed text. (default = 0)

crosshairsize n

Sets the size of your crosshair, 0 being off (default = 3)

keymap K N A

// for players using a german keyboard the following keymappings can be added to data/keymap.cfg
keymap 223 SZ
keymap 252 UE
keymap 246 OE
keymap 228 AE

Sets up the keymap for key code K with name N and default action A. You should never have to use this command manually, use "bind" instead. But in case you do need it (to make use of previously un-bind-able keys (like above)) take a look at Internationalization

// for people uncomfortable with using "BACKQUOTE":
bind CARET [saycommand /]