Project

General

Profile

Actions

Feature #1399

closed

Lua API: specialists control

Added by Alexandr Ignatiev 29 days ago. Updated 3 days ago.

Status:
Closed
Priority:
Normal
Category:
Scripting API
Target version:
Start date:
05/17/2025
Due date:
% Done:

0%

Estimated time:

Description

Continuation of #1375. The following methods are needed: * (City):settle_specialist(Specialist s, int num = 1) - adds a specialist or several; for normal specialist, also increases city size. Respects s's reqs. Returns number of specialists added. * (City):num_specialists(Specialist s?) - counts specialists of given type in the city, without parameter, counts all specialists (normal and super). Maybe add functions for counting all normal and all super specialists? * (City):reduce_specialist(Specialist s, int num = 1) - for superspecialist, just removes them, for normal specialist, toggles them cyclically (does not place workers or change city size), returns number of toggled/removed ones. * (City):can_use(Specialist s) - checks reqs (specialist can be still not addable due to 255 limit) * Player:can_use(Specialist s) - checks Player+-ranged reqs. Maybe rename these functions to sth more specific like can_employ but actually we have polymorphism.


Files

lua-superspecialists-edit.patch (18.8 KB) lua-superspecialists-edit.patch Alexandr Ignatiev, 06/05/2025 01:04 AM

Related issues 3 (0 open3 closed)

Blocked by Feature #1451: Lua API: specialist classClosedMarko Lindqvist05/26/2025

Actions
Blocked by Feature #1375: Introduce superspecialistsClosedMarko Lindqvist05/08/2025

Actions
Blocked by Feature #1464: Lua API: minimal specialist controlClosedMarko Lindqvist05/28/2025

Actions
Actions #1

Updated by Alexandr Ignatiev 29 days ago

also bool (Specialist).is_super

Actions #2

Updated by Marko Lindqvist 28 days ago

I think we should split this to two parts. First introduce lua methods that deal with normal specialists, and that patch would go to S3_3 too. Second patch to add super specialist handling would go to main branch only.

Actions #3

Updated by Marko Lindqvist 20 days ago

Actions #4

Updated by Marko Lindqvist 20 days ago

  • Target version changed from 3.3.0-d3f to 3.4.0-d3f
Actions #5

Updated by Marko Lindqvist 20 days ago

Actions #6

Updated by Marko Lindqvist 18 days ago

  • Related to Feature #1464: Lua API: minimal specialist control added
Actions #7

Updated by Alexandr Ignatiev 10 days ago

Patch for S3_4 ready (applied upon #1464).

Actions #8

Updated by Marko Lindqvist 10 days ago

  • Related to deleted (Feature #1464: Lua API: minimal specialist control)
Actions #9

Updated by Marko Lindqvist 10 days ago

  • Blocked by Feature #1464: Lua API: minimal specialist control added
Actions #10

Updated by Marko Lindqvist 8 days ago

  • Status changed from New to In Review
  • Assignee set to Marko Lindqvist
Actions #11

Updated by Alexandr Ignatiev 8 days ago

I am actually in doubt of should (City):num_specialists(nil) be also changed. The name does not suggest we count only normal specialists; but counting all specialists is needed much more rarely and some backward compatibility with 3.3 scripts tgat rely on "specialists == citizens that are not workers" may effectively be lost.

Actions #12

Updated by Marko Lindqvist 5 days ago

Alexandr Ignatiev wrote in #note-11:

I am actually in doubt of should (City):num_specialists(nil) be also changed. The name does not suggest we count only normal specialists; but counting all specialists is needed much more rarely and some backward compatibility with 3.3 scripts tgat rely on "specialists == citizens that are not workers" may effectively be lost.

Maybe we should have num_specialists() that count just normal specialists and num_superspecialists() that counts just superspecialists, and people wanting the sum of the two can add them themselves. Would also avoid changing the num_specialists() semantics from S3_3.

Actions #13

Updated by Marko Lindqvist 3 days ago

Whatever we decide to do with num_specialists(), it can happen in a separate future ticket. Pushing this one in now.

Actions #14

Updated by Marko Lindqvist 3 days ago

  • Status changed from In Review to Closed
Actions

Also available in: Atom PDF