1. We have added a Gift Upgrades feature that allows you to gift an account upgrade to another member, just in time for the holiday season. You can see the gift option when going to the Account Upgrades screen, or on any user profile screen.
    Dismiss Notice

[TOTPP] Prof. Garfield's Lua Code Thread

Discussion in 'Civ2 - Scenario League' started by Prof. Garfield, Apr 11, 2020.

  1. Prof. Garfield

    Prof. Garfield Deity Supporter

    Joined:
    Mar 6, 2004
    Messages:
    2,900
    Location:
    Ontario
    Oh, I also found (and updated general library) the city attribute flags for an investigated city, a used airport, and a used transporter. It seems that there aren't any 'famine' flags, though perhaps I misremembered how famine works, and expected a flag for it.
     
  2. Prof. Garfield

    Prof. Garfield Deity Supporter

    Joined:
    Mar 6, 2004
    Messages:
    2,900
    Location:
    Ontario
    Repository updated again. A few things added to the General Library

    The map can now be declared round or flat, and checked for same. By default it is assumed to be flat.
    gen.isMapFlat()-->boolean
    gen.isMapRound()-->boolean
    gen.declareMapFlat()-->void
    gen.declareMapRound()-->void

    Distance (gen.distance) was also changed to take into account situations when the map isn't flat. There may be things I overlooked in this regard, so let me know if something doesn't work as expected.

    I also produced a couple functions to get nearby tiles

    -- gen.cityRadiusTiles(cityOrTileOrCoordTable) --> table
    -- gen.getTilesInRadius(centre,radius,minRadius=0,maps=nil) --> table

    gen.cityRadiusTiles gets the tiles in the city radius, indexed according to the position of the bit in city.workers that determines if that tile is worked. That is
    Code:
    --      #       #       #       #       #
    --          #       #       #       #       #
    --      #       #       #       #       #
    --          #       20      13      #       #
    --      #       12      8       9       #
    --          19      7       1       14      #
    --      #       6       21      2       #
    --          18      5       3       15      #
    --      #       11      4       10      #
    --          #       17      16      #       #
    --      #       #       #       #       #
    --          #       #       #       #       #
    
    Absent tiles have a nil value.

    gen.getTilesInRadius is more generic, and simply lists nearby tiles. If a tile doesn't exist, there is no gap in the indices, rather the index is simply used for the next tile.
     

Share This Page