Bos Wars Scripting API: Editor


Bos Wars FAQ PREV NEXT LUA Index
Editor EditorCommandLine EditorEditing EditorNotRunning EditorSaveMap EditorStarted SetEditorPatchIcon SetEditorSelectIcon SetEditorStartUnit SetEditorUnitsIcon StartEditor StartPatchEditor

Intro - Introduction to editor functions and variables

These affect only the map editor or the patch editor, not the game itself.

Functions

EditorSaveMap("name.map")

Saves the map being edited in the map editor.

"name.map"
The name of the directory to which this function will save the map files. This name must end with ".map".
RETURNS
0 on success, or -1 on error.

SetEditorPatchIcon("icon-name")

Set the icon of the button that activates patch-placement mode in the map editor. In this mode, the map editor shows a list of patch types, and the user can insert, move, and remove patches on the map.

"icon-name"
The name of the icon.
RETURNS
Nothing

Example

-- Use "icon-editor-patch" for the map editor's patches icon.
SetEditorPatchIcon("unit-editor-patch")

SetEditorSelectIcon("icon-name")

Set the icon that is used in the editor to indicate selection.

"icon-name"
The name of the icon.
RETURNS
Nothing

Example

-- Use "icon-human-patrol-land" for the editor's select icon.
SetEditorSelectIcon("icon-human-patrol-land")

SetEditorUnitsIcon("icon-name")

Set the icon of the button that activates unit-placement mode in the map editor. In this mode, the map editor shows a list of unit types, and the user can insert, move, and remove units on the map.

"icon-name"
The name of the icon.
RETURNS
Nothing

Example

-- Use "icon-footman" for the map editor's units icon.
SetEditorUnitsIcon("unit-footman")

SetEditorStartUnit("unit-start")

Set the unit used in the map editor to show the start location.

unit
The name of the unit.
RETURNS
Nothing

See also Editor.StartUnit.

Example

SetEditorStartUnit("unit-start-location")

StartEditor("presentation.smp")

Starts the map editor.

"presentation.smp"
The name of the presentation file of the map that the map editor will load, or an empty string to create a new map from scratch.
RETURNS
Nothing

StartPatchEditor("patch-name")

Starts the patch editor.

"patch-name"
The name of patch type you want to edit.
RETURNS
Nothing

Variables

Editor

This variable refers to an object that has at least the following properties and methods: Running ShowTerrainFlags StartUnit TileSelectedPatch UnitTypes

Editor.Running = integer

Whether the map editor is running. When the user starts the map editor, the engine sets Editor.Running = EditorEditing. When a Lua script sets Editor.Running = EditorNotRunning, the map editor exits. The value of this property also affects what the engine shows on the screen: for example, patches may get borders around them when the editor is running.

The value of the Editor.Running property should be one of the following constants defined by the engine:

EditorNotRunning
The editor is not running.
EditorStarted
This constant is not used.
EditorCommandLine
This constant is not used.
EditorEditing
The editor is running; the user can edit the map. A Lua script can tell the editor to exit, by setting Editor.Running = EditorNotRunning.

Editor.ShowTerrainFlags = boolean

If true, the editor shows the terrain flags of map tiles as colored rectangles. This makes it easier to check that the terrain flags have been correctly and consistently defined in patch types, and that there is enough space for large units to move between obstacles.

Editor.StartUnit = const CUnitType*

The value of this read-only property is the CUnitType object that the editor will use to show the start location of each player. Lua scripts can change it by calling SetEditorStartUnit.

Editor.UnitTypes = vector

A sorted list of unit-types for the editor. This is only a temporary hack for better sorted units. Because this is a C++ vector rather than a Lua table, the key numbers start from 0 rather than 1.

Example
Editor.UnitTypes.clear()
Editor.UnitTypes.push_back("unit-vault")
Editor.UnitTypes.push_back("unit-apcs")
Editor.UnitTypes.push_back("unit-medic")
Editor.UnitTypes.push_back("unit-bazoo")
Editor.UnitTypes.push_back("unit-assault")
Editor.UnitTypes.push_back("unit-grenadier")
Editor.UnitTypes.push_back("unit-camp")
Editor.UnitTypes.push_back("unit-hosp")

Editor:TileSelectedPatch()

Fills the map with patches of the selected type, removing all other patches.

RETURNS
Nothing

All trademarks and copyrights on this page are owned by their respective owners.
(c) 2002-2007 by The Bos Wars Project