#44779: Lua: support for requirement vectors Open Date: 2022-06-08 11:46 Last Update: 2022-06-08 11:46 URL for this Ticket: https://osdn.net//projects/freeciv/ticket/44779 RSS feed for this Ticket: https://osdn.net/ticket/ticket_rss.php?group_id=12505&tid=44779 --------------------------------------------------------------------- Last Changes/Comment on this Ticket: 2022-06-08 11:46 Updated by: ihnatus * New Ticket "Lua: support for requirement vectors" created --------------------------------------------------------------------- Ticket Status: Reporter: ihnatus Owner: (None) Type: Feature Requests Status: Open Priority: 5 - Medium MileStone: (None) Component: (None) Severity: 5 - Medium Resolution: None --------------------------------------------------------------------- Ticket 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 requirementsreq_type(...). "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 information of Freeciv project Freeciv Project is hosted on OSDN Project URL: https://osdn.net/projects/freeciv/ OSDN: https://osdn.net URL for this Ticket: https://osdn.net/projects/freeciv/ticket/44779 RSS feed for this Ticket: https://osdn.net/ticket/ticket_rss.php?group_id=12505&tid=44779