Otter Snippets Otter Upstream Otter 1.0.1 Tested

Ability Cooldown System

Track ability cooldown durations and check ready status against elapsed timestamps.

ID: snippet/game-cooldown-system Version: 1.0.0 License: MIT Framework: Otter 1.0.1

Architecture & Runtime Preview

Otter 1.0.1

Zero-dependency Otter 1.0.1 snippet (Game Systems). Copy the parameterized template or run the self-contained example.

  1. 1Category: Game Systems
  2. 2Attribution: Otter Reusable Library (Official)
  3. 3Zero external pack dependencies — paste directly into any .ot file

Source Code (2 files)

template.ot · otter
a AbilityCooldown has
    abilityName
    cooldownSeconds
    lastUsedAt
.

to createAbility name cd
    ability is a AbilityCooldown
    abilityName of ability is name
    cooldownSeconds of ability is cd
    lastUsedAt of ability is 0 minus 9999
    return ability
.

to isAbilityReady ability nowSeconds
    last is lastUsedAt of ability
    duration is cooldownSeconds of ability
    elapsed is nowSeconds minus last
    if elapsed is at least duration
        return true
    otherwise
        return false
    .
.

to useAbility ability nowSeconds
    ready is isAbilityReady ability nowSeconds
    if ready is true
        lastUsedAt of ability is nowSeconds
        return true
    otherwise
        return false
    .
.

Installation & Usage

otter snippet inspect game-cooldown-system

Copy template.ot directly into your .ot source file, or run example.ot with 'otter run example.ot'.