The self_destruct component is the Computronics self-destruct card. It arms a countdown fuse and eventually detonates at the host position unless the host is restarted or stopped first.
- Repository:
computronics - Component name:
self_destruct - Typical host: Computronics self-destruct card in a supported OC host
local component = require("component")
local boom = component.self_destruct- The fuse is stored internally in ticks.
start(seconds)converts seconds to ticks usingfloor(seconds * 20).- Once armed, the fuse counts down every server tick.
- When it reaches zero, the card calls
SelfDestruct.goBoom(...)at the host position. - The fuse state is saved to NBT and survives normal saves.
- If the neighboring computer emits
computer.startedorcomputer.stopped, the fuse is reset to-1.
- Syntax:
boom.start([time]) - Returns:
- Success:
seconds - Failure:
-1, reason - Severe failure: exception
- Success:
- Purpose: Arms the self-destruct fuse.
Parameters:
time:numberoptional: desired fuse time in seconds. Defaults to5.
Behavior:
- If the fuse is already armed, the callback returns
-1, "fuse has already been set". - Times greater than
100000throwtime may not be greater than 100000.
Example:
local seconds = assert(boom.start(10))
print("Fuse:", seconds)- Syntax:
boom.time() - Returns:
- Armed:
secondsRemaining - Unarmed:
-1, reason
- Armed:
- Purpose: Returns the remaining fuse time in seconds.
Behavior:
- If the fuse has not been armed, the callback returns
-1, "fuse has not been set".
Example:
local left, reason = boom.time()
print(left, reason)componentparticle