API:GetCityRatingForCityId
From RoR Wiki
UI Lua API · RvR functions
Version: WAR 1.4.8
Returns the rating (rank) of a capital city.
rating = GetCityRatingForCityId(cityId)
Arguments
- cityId
number– City id, for exampleGameData.CityId.EMPIRE,GameData.CityId.CHAOSorGameData.Player.City.id.
Returns
- rating
number– The stored rating of the city. Nothing if the rating is 0 or the client has no rating for that city.
Details
- A rating of 0 returns nothing, not
0. Code that compares the result directly with a number, asMapUtilsdoes (rating <= cityRating), raises a Lua error in that case. Uselocal rating = GetCityRatingForCityId(id) or 0. - The value is read from a table the client keeps; nothing is requested from the server.
- The function takes exactly one argument.
Errors
None besides the generic Invalid Parameters message when the argument is missing or not a number.
Example
From default/easystem_utils/source/maputils.lua: one star per city rank:
local cityRating = GetCityRatingForCityId( cityId )
for rating = 1, GameDefs.NUM_CITY_RANKS
do
local showStar = rating <= cityRating
WindowSetShowing( windowName.."Star"..rating, showStar )
