Project

General

Profile

Actions

Feature #1464

open

Lua API: minimal specialist control

Added by Alexandr Ignatiev 10 days ago. Updated 1 day ago.

Status:
In Review
Priority:
Normal
Category:
Scripting API
Target version:
Start date:
05/28/2025
Due date:
% Done:

0%

Estimated time:

Description

Split from #1399 but applied also to S3_3. Main application there is scripted removal of specialists that the city can't employ any more due to their reqs but that are not automatically removed.

Common
  • bool (City):can_employ(Specialist s)
  • bool (Player):can_employ(Specialist s)
  • int (City):num_specalists(Specialist s?)
Server
  • bool (City):reduce_specialist(Specialist s, amount n?)

Probably we also want a way to know Specialist_Output effect but the logical addition in effects module is probably too global for this patch; just a City method can be added though.


Files

specialists-lua-api.patch (13.7 KB) specialists-lua-api.patch Alexandr Ignatiev, 05/31/2025 12:47 AM
lua-specialists.patch (13.7 KB) lua-specialists.patch from 202-06-04 Alexandr Ignatiev, 06/04/2025 09:37 PM
lua-specialists1.patch (13.7 KB) lua-specialists1.patch Alexandr Ignatiev, 06/05/2025 12:58 AM

Related issues 2 (1 open1 closed)

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

Actions
Blocks Feature #1399: Lua API: specialists controlNew05/17/2025

Actions
Actions #1

Updated by Marko Lindqvist 10 days ago

Actions #2

Updated by Marko Lindqvist 10 days ago

Actions #3

Updated by Marko Lindqvist 10 days ago

  • Target version changed from 3.3.0 to 3.3.0-d3f
Actions #4

Updated by Alexandr Ignatiev 7 days ago

In fact, effects.specialist_bonus() is rather easy and natural to place here ("Specialist_Output" is an unique effect that is calculated towards city but not its tile). But seeing that superspecialists patch is already in review, the editing stuff should probably be delivered to S3_3 and S3_4 separately since its methods must be aware if the specialist is calculated within citizens.

Actions #5

Updated by Alexandr Ignatiev 7 days ago

Well, let's eat elephant by pieces. Here is a patch to apply at S3_3 and probably stop with specalists API there. For S3_4 it is applied but the editing part does a wrong thing if superspecialists are introduced, so we shall fix it in a separate patch that will also add some more API for superspecialists (namely, City:add_specialist() and Specialist.is_super).

Actions #6

Updated by Marko Lindqvist 4 days ago

  • Status changed from New to In Progress
  • Assignee set to Alexandr Ignatiev

Can you fix the global observers FIXME comment.

Likely helpful:
conn_list_iterate(game.glob_observers ...

Actions #7

Updated by Alexandr Ignatiev 3 days ago

Marko Lindqvist wrote in #note-6:

Can you fix the global observers FIXME comment.

Likely helpful:
conn_list_iterate(game.glob_observers ...

I copied this part from handle_city_change_specialist() in server/cityhand.c, I did not check thoroughly, just expressed a concern. Probably we need first define a function to broadcast city internals, and then apply it in both places.

Actions #8

Updated by Alexandr Ignatiev 3 days ago

citytools.c L#2471-2472:
if (dest == powner->connections {
/* HACK: send also a copy to global observers. */

really well hidden thing but it works, I delete that line.

Actions #9

Updated by Alexandr Ignatiev 2 days ago

Also, I probably should write a wrapper method in tolua_server.pkg to get more comprehensive Lua backtraces on arg errors.

Actions #10

Updated by Alexandr Ignatiev 1 day ago

Alexandr Ignatiev wrote in #note-9:

Also, I probably should write a wrapper method in tolua_server.pkg to get more comprehensive Lua backtraces on arg errors.

The traceback is not much better, but the wrappers probably serve one purpose: you can replace a method in edit table, and the objects' API changes alongside. Rather a dubious merit but not to be changed here. HEre is the patch.

Actions #11

Updated by Alexandr Ignatiev 1 day ago

Some cleanup.

Actions #12

Updated by Marko Lindqvist 1 day ago

  • Related to deleted (Feature #1399: Lua API: specialists control)
Actions #13

Updated by Marko Lindqvist 1 day ago

Actions #14

Updated by Marko Lindqvist 1 day ago

  • Status changed from In Progress to In Review
  • Assignee changed from Alexandr Ignatiev to Marko Lindqvist
Actions

Also available in: Atom PDF