#42681: Lua: basic city edit API Open Date: 2021-07-30 18:50 Last Update: 2021-07-30 18:50 URL for this Ticket: https://osdn.net//projects/freeciv/ticket/42681 RSS feed for this Ticket: https://osdn.net/ticket/ticket_rss.php?group_id=12505&tid=42681 --------------------------------------------------------------------- Last Changes/Comment on this Ticket: 2021-07-30 18:50 Updated by: ihnatus * New Ticket "Lua: basic city edit API" created --------------------------------------------------------------------- Ticket Status: Reporter: ihnatus Owner: (None) Type: Feature Requests Status: Open Priority: 5 - Medium MileStone: (None) Component: General Severity: 5 - Medium Resolution: None --------------------------------------------------------------------- Ticket details: Sub-task of #42501. Provide the following missing methods for cities: bool :rename(string name) -- sets city name if it's allowed by size and symbols int :add_size(int amount, Player nationality = NULL, string reason = NULL) -- changes size and returns the resulting size that is clipped by 0 (destroys city) and MAX_CITY_SIZE. nationality is in effect only for growing (at least). if reason is not nil, calls the signal "city_size_change" with this reason. bool :remove_building(Building_Type building || int building_id || string building_rule_name) -- removed wonders are marked as destroyed. Note: edithand.c does not dispatch info about removed wonders, maybe both should? bool :build_building(Building_Type building || int building_id || string building_rule_name) -- if an existing wonder (great or small) is built, it is removed from its previous location. Info is sent around. int :give_food(int amount) -- adds an amount of food and returns resulting food stock that is clipped from 0 to current granary size int :give_shields(int amount, string stype = NULL) -- adds amount of shields, returns current shield stock that is limited with 0 from below. stype may be NULL (change only basic shields, any future change in production target within city turn resets this value - current edithand.c effect, is it good?), "before_change" (also change this counter), "disband", "caravan" (changes corresponding accumulators like a unit was disbanded or a caravan helped a wonder this turn) or "last_turn" (like a surplus was bigger at this amount). In common Lua interface, we should better control the stocks of the city for the aforementioned functions, add city properties: int .food_stock int .shield_stock int .before_change_shields int .caravan_shields int .disbanded_shields int .last_turn_shields lua_Object .production -- Building_Type or Unit_Type lua_Object .changed_from -- Building_Type or Unit_Type maybe also int :change_penalty(lua_Object to_what = 0) --argument defaults to current production -- 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/42681 RSS feed for this Ticket: https://osdn.net/ticket/ticket_rss.php?group_id=12505&tid=42681