Essentials Series/Counters

From Heavy Iron Modding
Revision as of 03:24, 29 April 2020 by Battlepedia>Igorseabra4 (Created page with "{{EssentialsSeriesBox}} This page is part of the Essential Series modding tutorials. In this guide, you will learn how to use CNTR assets. A '''counter''' is an Asset#Ba...")
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Essentials Series
  1. Introduction
  2. Industrial Park basics
  3. Editing Assets
  4. Templates
  5. Links
  6. Dispatchers
  7. Tikis and Enemies

This page is part of the Essential Series modding tutorials. In this guide, you will learn how to use CNTR assets. A counter is an base asset that keeps track of a single number value. A counter's value is able to be modified, accessed, and reset at any time.

Using a Counter

Industrial Park has a Counter template. When placing the template, you can choose the initial value stored in the counter. This value is an integer that can be in the range of -32,768 to 32,767. Counters are used for creating game logic: for example, if you want an event to be sent after pressing three buttons, or after destroying 10 enemies, you can use a counter with its initial value set to that, and have each button or enemy asset decrement the counter, until 0 is reached. These are the events used by a counter:

  • Reset: Send this event to a counter to reset its initial value.
  • Expired: This event is sent to the counter when its value reaches 0. Once in 'Expired' mode, Increment and Decrement do not work anymore until you send Reset to it.
  • Increment: Send this to a counter to increase its value by one. If the new value is 0, Expired will be sent as well. If the new value is between 1 and 20, an event between Count1 and Count20 will be sent as well.
  • Decrement: Send this to a counter to decrease its value by one. If the new value is 0, Expired will be sent as well. If the new value is between 1 and 20, an event between Count1 and Count20 will be sent as well.
  • Count1 to Count20: these are twenty different events. Sending one of them to a counter will override its value with the corresponding count. The events are also received by the counter when the new value (set after Increment or Decrement) is between 1 and 20.

Note that setting a counter's initial value to 0 does not make it expired. It only becomes expired when its new value after receiving Increment or Decrement is 0 (i.e. incrementing a counter whose value is -1 or decrementing a counter whose value is 1).

An example of using counters in the game is Mr. Krab's Dream (Krabby Patty Platforms). Each robot, on death, sends Decrement to a counter whose initial value is 5. The counters use Count1 to Count5 events to send events to the different Krabby Patty ingredient platforms and make them move.

Using Conditionals

Conditionals can access a counter's value. More information on the Conditionals page.