beyond-all-reason / beyond-all-reason/RecoilEngine

Add a way to get known CEG names

Open
#1,606 0 comments 0 reactions 0 assignees View on GitHub
area: CEG area: Lua API
Dominant language
C++
Stars
679
Forks
290
Avg merge
3d 2h
Merged PRs (30d)
40

Description

I would like to have a Lua side listing of all valid CEG names.

Right now I do it by just parsing the whole ceg defs from scratch:
```lua
local explosions = VFS.Include('gamedata/explosions.lua') -- { NUKE_MUSHROOM = {...}, SPARKS = {...}, ... }
```
But this fails for multiple reasons:
* a lot of duplicated processing, the engine already parsed this once
* does not filter away CEGs that the engine would reject (e.g. incorrect class, etc)
* different Lua environment compared to when this is originally parsed by engine, which means there can be different results or even errors.
* doesn't give me numerical IDs, requiring N calls of `Spring.GetCEGID(name)`, though in my specific case I don't really need them.

I would be happy with any of:
* `Spring.GetCEGNames() -> table`, e.g. { "NUKE_MUSHROOM", "SPARKS", ... }.
* `Spring.GetCEGInfo(integer) -> table`, e.g. GetCEGInfo(2) = { .name = "SPARKS", .class = "CExploSpikeProjectile", ... }. I could get all CEGs this way by just iterating from 1 until I hit nil.
* I hope the numbers start from 1. If they don't (I know that SEG exists but maybe it has ID 0?) then perhaps this turns into a request to do that first.

Contributor guide

Open the contributing guide

Research direction

Start by tracing the existing Spring.GetCEGID(name) API and the gamedata/explosions.lua CEG definitions to understand how valid CEGs are registered and indexed. Decide which proposed Lua-facing listing or info API fits the engine, including whether IDs begin at 1; done means Lua can enumerate engine-accepted CEGs without reparsing the definitions.

Written by the indexing model from the issue text.

Assessment

Tech stack
cpp, lua
Domain
api, game-dev
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
30/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.