OPX//77
opx_infinityneeds

needs

Last updated on

The character's gameplay needs (hunger, thirst, stamina, street cred) and the status-effect registry every module adds a chip to.

Holds two things. The character's needs (hunger, thirst, stamina, streetCred by default): the server owns them. It decays them on its own clock while the character is loaded, raises them, stores them per character and sends every change to the player's client, which only draws them. And the status-effect registry: any module can put a chip (a short label with a tone and an optional countdown) on the player's screen. It draws nothing itself; hud draws both. Use it to feed or drain a need, or to show a temporary state such as "Bleeding" or "Well fed".

Sideboth
Requirescharacter (hard)
Contractneeds v1 — server (the values), client (read only, and the chips)
Configconfig/needs.lua (shared)
Dataopx77_character_status (one row per character: citizen_id, needs JSON)
  • health, armor, isDead and inLastStand are not needs. They belong to the character and the engine.
  • A need goes up only through the server contract: an item whose USE.STATUS is consumed (the inventory adds it after taking the unit), the staff command /opx.needs.set, or the creator exports AddNeeds / SetNeeds (SERVER.EXPORTS.WRITERS). A client cannot send a value: there is no push event.
  • The values load when the character module announces the character on the server, without waiting for the client.
  • Nothing downs or kills a player whose need reaches MIN.
  • A character deleted through character also deletes its needs row (it listens to the private opx:in:character:deleted).

Configuration

config/needs.lua sets OPX.Config.MODULES.needs. Shared script.

KeyDefaultEffect
enabledtruefalse switches the module off.
ANCHOR'bottom-left'Corner the chip strip sits in. Sent in the strip payload.
OFFSET120Pixels above that corner.
MAX_VISIBLE6Chips published at once.
NEEDSsee NEEDSEvery need, with bounds. A key not listed here is refused and never stored. A need added later is served at its DEFAULT to existing characters.
DECAY_MS60000Milliseconds between two decay charges, on the server (minimum 1000). Each charge sends the new values to the player, so this is also how often the gauges move.
AUTOSAVE_MS300000Milliseconds between two server writes of the held values (minimum 1000).

PUSH_MS and PUSH_DELTA were removed with the push event; a copy of them in your config is ignored.

NEEDS

Each entry is name = { MIN, MAX, DEFAULT, DECAY_PER_MINUTE? }. A need without DECAY_PER_MINUTE only moves when a caller moves it.

NeedMINMAXDEFAULTDECAY_PER_MINUTE
hunger01001000.20
thirst01001000.28
stamina0100100—
streetCred01000000—

Commands

CommandAccessArgumentsEffect
/opx.needs.setACL command.opx.needs.set<player> <need> <value>Sets one need of a connected player, clamped to its bounds. Audited (needs.set). The only way a need goes up by hand.

Refusal codes

Not translated; they are for the calling code.

CodeMeaning
no_characterNo character is loaded on this client.
not_loadedClient: the server has not sent the values yet. Server: no character is loaded on that player, or its row could not be read.
bad_playerServer: not a positive integer player id.
spec_must_be_a_tableThe spec or patch is not a table.
unknown_needA patch key is not in NEEDS.
invalid_need_valueA patch value is not a finite number.
empty_patchThe patch names no need.
invalid_ownerowner is not a valid name.
missing_id / invalid_idThe effect id is missing or malformed.
invalid_labelThe label is missing or empty after cleaning.
invalid_eventevent is not a valid name.
invalid_tonetone is not one of the eight tones.
invalid_durationdurationMs is not in 1..3600000.
invalid_data / data_too_largedata is not a table, or is over 64 nodes / 4 levels.
invalid_progressprogress is not a finite number.
owner_limitThe owner already holds 24 chips and the id is new.
not_foundThe owner holds no chip with that id.

On this page