Skip to content

Add getWeaponTubeStatus() to the Lua API (#1975) - #2926

Open
dj803 wants to merge 1 commit into
daid:masterfrom
dj803:fix/1975-tube-status
Open

dj803 wants to merge 1 commit into
daid:masterfrom
dj803:fix/1975-tube-status

Conversation

@dj803

@dj803 dj803 commented Nov 13, 2026

Copy link
Copy Markdown
Contributor

Closes #1975.

Cause
Scripts can read which weapon is loaded (getWeaponTubeLoadType), but that returns nothing while a tube is loading or unloading, and there is no way to read the tube state (empty/loading/loaded/unloading/firing). The state was already exposed as components.missile_tubes[n].state, just not through a documented getter.

Change
scripts/api/entity/spaceship.lua: new Entity:getWeaponTubeStatus(index) beside getWeaponTubeLoadType. Returns two values: the state string ("empty", "loading", "loaded", "unloading", "firing") and the weapon type string ("none" when empty). Out-of-range index or no tubes returns no value (same as the neighbouring getters). Lua only, no C++. Docstring uses the existing --- format.

You noted in the issue that the ECS branch covers this, and it does through components.missile_tubes[n].state. This only adds a documented getter beside getWeaponTubeLoadType; if the component access is the intended API, feel free to close this.

Checks

  • Lua 5.4 syntax parse of scripts/**.lua (the engine's own Lua): 0 failed.
  • Headless run on an Atlantis (5 tubes), with a fresh Windows build of this branch (re-run 2026-11-13 after rebasing). Observed (tube index = state/type): initial 0..2 = empty/none; after loading Homing into 0 and HVLI into 1: loading/homing, loading/hvli; after 10 s: loaded/homing, loaded/hvli; unload tube 1 + fire tube 0: tube 0 empty/none, tube 1 unloading/hvli; later all empty/none; index 99 returns nil.

Not tested

🤖 Generated with Claude Code

Returns the missile tube state (empty/loading/loaded/unloading/firing) and the weapon type involved.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Enhancement Request - Missile Tube Status getter

1 participant