Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.
Excerpt

Remove a label from the game...

 

Syntax

Code Block
themeRDark
languagejavascript
linenumberstrue
removeLabel(label);

Parameters

ParameterTypeMandatoryNotesWarzone Version
labelString(tick)

The label will be associated with the objectto remove.

3.2

Return value

ValueTypeNotesWarzone Version
undefined<number>UndefinedThe function does not return anything if sucessfulNumber

The number of labels that were removed:

  • 0 – the label didn't exist
  • 1 – the label existed and has been removed

If <number> is greater than one, it means that somehow the same label was defined multiple times (most likely in labels.ini), and all <number> occurrences were removed.

3.2
<error>ErrorAn error occurred, most likely invalid parameters.3.2

Notes

When the label is removed, what happens to the object it was pointing to? It depends on the type of object:

  • Game objects – the droid/structure/feature will remainOther objects – the object, which now has nothing linking to it, will be deletedobject will be retained
  • Location objects – if the object doesn't have any other labels associated with it, it will be deleted

Remember that labels are shared by all scripts, so if you delete a label that deletes it for all other scripts as well.

Example

Code Block
themeRDark
languagejavascript
linenumberstrue
var firstTruck = enumDroid(me, DROID_CONSTRUCT)[0];
addLabel(firstTruck, "my_first_truck");if ( removeLabel("foo") ) {
	// label(s) removed (+ve numbers are truthy)
} else {
	// label not found (0 is falsey)
}
Div
classbox
Availability
Status
colourYellow
title3.2+

Requires:

  • Warzone 3.2 or above

See also

Related articles:

  • getLabel() – get the first label associated with a specific object
  • label() – get the object, if any, associated with a label
  • enumLabels() – get a list of all labels currently defined
  • eventArea<LABEL>() – triggered when a droid enters a labelled area
    Div
    classbox
    Contents

    Jump to:

    Table of Contents
    maxLevel5

    Div
    classbox

    Include Page
    .jslinks-labels
    .jslinks-labels