Ticket #44779

Lua: support for requirement vectors

Eröffnet am: 2022-06-08 17:46 Letztes Update: 2022-07-09 19:30

Auswertung:
Verantwortlicher:
(Keine)
Status:
Offen
Komponente:
Meilenstein:
Priorität:
5 - Mittel
Schweregrad:
5 - Mittel
Lösung:
Keine
Datei:
Keine

Details

Make a class to get requirement vector properties of unit types etc., as well as create them dynamically for in-script use.

That probably requires creating Lua object type that resides within Lua memory (see comment in the code about destructors in C projects, it's probably still actual). Like this:

struct req_vec_obj {
struct requirement_vector* reqs; bool is_external; // Memory managed by C, editing not allowed bool operation_or; // For obsoleted_by
} #define Req_Vec struct req_vec_obj

We provide methods (Req_Vec):test(elements), (Req_Vec):iterate(), and for editable vectors :insert(pos, {elements}) and :delete(pos). Also, we make module requirements with method .new_vec{table} and .test(req_type, req_range, {elements}, survives?), better with a shortcut to just requirements[ req_type ](...) (e.g., requirements.MaxUnitsOnTile("Local", find.tile(3,14))). "Elements" may be a table with named fields like {city = "Leningrad"} or just a sequence where field is detected by element type (find.city(nil, "Leningrad")). The vector table may look most alike what we have in specfiles {"type", "name", "range"}, {"DiplRel", "IsForeign", "Local"}} or consist of tables with named arguments {{type = "DiplRel", name = "IsForeign", range = "Local ", }}.

Ticket-Verlauf (3/4 Historien)

2022-06-08 17:46 Aktualisiert von: ihnatus
  • New Ticket "Lua: support for requirement vectors" created
2022-06-08 17:58 Aktualisiert von: ihnatus
  • Meilenstein Update from (Keine) to S3_2 d3f
  • Komponente Update from (Keine) to Scripting API
  • Details Updated
2022-07-09 08:00 Aktualisiert von: cazfi
Kommentar

My main concern is that the design is such that things remain stable from version to version, as deprecating anything from the lua script is next to impossible. So having internal structures exposed to lua scripts may mean that we can't change those internals.

2022-07-09 19:30 Aktualisiert von: ihnatus
Kommentar

Reply To cazfi

My main concern is that the design is such that things remain stable from version to version, as deprecating anything from the lua script is next to impossible. So having internal structures exposed to lua scripts may mean that we can't change those internals.

Requirements are not that internal as we set them from rulesets. Requirement factors are well quite backstage but are so firmly tied to the requirements that deprecating existing ones is also very unlikely, only new ones may sometimes arrive, the design I think about is likely more or less resistable to it.

Dateianhangliste

Keine Anhänge

Bearbeiten

You are not logged in. I you are not logged in, your comment will be treated as an anonymous post. » Anmelden