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

The Test Of Time Patch Project

Discussion in 'Civ2 - General Discussions' started by TheNamelessOne, Dec 22, 2013.

  1. JPetroski

    JPetroski Chieftain

    Joined:
    Jan 24, 2011
    Messages:
    1,405
    I know this isn't exactly what you asked for, but this might help you achieve what you're hoping for to some extent, regardless:

    Lua allows us to cross reference a unit type against a unit location to achieve a result. You could have one "fortress" unit represent Eben Emael, Brest Litovsk, and Sevastopol, and they would all have different text/effects so long as you included their coordinates as part of the trigger.

    Though not as useful for moving units, you could nontheless expand the concept by having larger coordinates (a "box" if you will) that corresponds to a particular theater or region. Then, for example, you could have a different effect when a GI is destroyed in Italy than in Normandy or the Ardennes.

    It's not perfect, but it's way better than what we had before :)
     
  2. Grishnach

    Grishnach Chieftain

    Joined:
    May 15, 2006
    Messages:
    51
    Hi!
    To weigh in a bit - actually you can use the ID right now, it's only a question of getting the info in the first place :)
    If you know the id of a specific unit and you define
    Code:
    civ.onUnitKilled(...
    ...
    if unit.id == xxx then
    ...
    end
    ...
    end)
    
    then this will fire only for this specific unit and none else.

    Thats actually how i adress cities in my lua code - I get the ids once and then only reference these. For units there might be some issue in case you think about units which are built or created somewhere along the timeline in a scenario (you would have to continuously scan the unit list to catch new placements and stuff), but other than that ...

    If its a more general question (like the "GI in ..." example JPetroski mentioned), then coordinate checks work too, definitely.
     
  3. techumseh

    techumseh Chieftain

    Joined:
    Mar 12, 2002
    Messages:
    1,205
    Location:
    in the frozen north
    Good news, because getting the unit number is dead simple. Just use the cheat menu and "reveal map". Click on the unit you want and the number of each unit is listed in brackets after its nationality in the status box. This could be very useful! :think:
     
  4. Grishnach

    Grishnach Chieftain

    Joined:
    May 15, 2006
    Messages:
    51
    Just a final disclaimer - I'm not entirely sure if it is the exact same number since I never checked it :)

    You could try to ensure that via the lua console (ctrl-shift-f3) if you look at the output of
    Code:
    for u in civ.iterateUnits() do print(u.id, u.type.name, u.location.x, u.location.y, u.location.z)
    - this should give the list of all units, printing their IDs, tile locations and type name :)
     
  5. CurtSibling

    CurtSibling ENEMY ACE™ SLeague Staff

    Joined:
    Aug 31, 2001
    Messages:
    28,369
    Location:
    Innsmouth
    I was thinking about tribute amounts - :)

    I wonder if there is way to change the 4 pre-set amounts to a field where the player can type in an user-defined amount?
     
  6. McMonkey

    McMonkey ----Evertonian---- SLeague Staff

    Joined:
    May 9, 2005
    Messages:
    2,876
    Location:
    Cardiff
    A quick question about Labels colours. The standard white shows up as 0xf8f8f8. I have managed to use 0xb8b8b8 for a light blue/grey for labelling rivers. What other codes/colours can be used?
     
  7. techumseh

    techumseh Chieftain

    Joined:
    Mar 12, 2002
    Messages:
    1,205
    Location:
    in the frozen north
    I use this: https://htmlcolorcodes.com/
     
  8. McMonkey

    McMonkey ----Evertonian---- SLeague Staff

    Joined:
    May 9, 2005
    Messages:
    2,876
    Location:
    Cardiff
    Thanks Tech. Forgive me for being dull, but whatever I try pasting into the bottom line, it always comes out as black (except for the two I have mentioned). If, for example, I wanted to add yellow, what would be the code? 0xb8b8b8 = Grey/Light blue I've been experimenting, but nothing seems to work :wallbash:
     
  9. techumseh

    techumseh Chieftain

    Joined:
    Mar 12, 2002
    Messages:
    1,205
    Location:
    in the frozen north
    Instead of the #, use 0x as the prefix.
     
  10. McMonkey

    McMonkey ----Evertonian---- SLeague Staff

    Joined:
    May 9, 2005
    Messages:
    2,876
    Location:
    Cardiff
  11. McMonkey

    McMonkey ----Evertonian---- SLeague Staff

    Joined:
    May 9, 2005
    Messages:
    2,876
    Location:
    Cardiff
    That worked a treat. Thanks Brian. I can now colour code my labels for mercenaries, meaning I can cut down on the text (IE the colour specifies the nationality) which leads to a less cluttered screen. Thanks!
     
  12. techumseh

    techumseh Chieftain

    Joined:
    Mar 12, 2002
    Messages:
    1,205
    Location:
    in the frozen north
    Mon plasir! How is it coming?
     
  13. McMonkey

    McMonkey ----Evertonian---- SLeague Staff

    Joined:
    May 9, 2005
    Messages:
    2,876
    Location:
    Cardiff
    It's going great. This is my first co-operative project, something I have been hoping to do for many years. We have most of the game built and it's now at the event's stage. We're going to be using Lua. ToTPP and Lua have increased possibilities for scenario designers vastly. John & Grishnach have already included a ton of new features in Caesar's Gallic Wars and we're planning to incorporate many of these, as well as new experimental features in The Rise of Macedon. There are some teething problems getting to grips with Lua, but that's to be expected. Hopefully, the work John, Grishnach, The Nameless One and others are putting in will begin a new era of scenario creation.
     
  14. techumseh

    techumseh Chieftain

    Joined:
    Mar 12, 2002
    Messages:
    1,205
    Location:
    in the frozen north
    I hope so, too. Good luck!
     
  15. TheNamelessOne

    TheNamelessOne Chieftain

    Joined:
    Dec 18, 2013
    Messages:
    196
    Release v0.15.1, containing some fixes and minor features:
    • The Lua patch exports a new library globally ("totpp"), where patches can register their own Lua tables to expose functionality.
    • The Movement multipliers patch now registers the "totpp.movementMultipliers" table.
    • Fixed a crash bug in civ.ui.loadTerrain.
    • Fixed a bug in civ.scen.onCanBuild, where the callback was called twice for each wonder instead of once.
    As always, detailed information about the patches is available in the launcher. For an overview of all patches, as well as installation instructions & requirements, see the included README.txt. Happy gaming! :)
     

    Attached Files:

  16. Knighttime

    Knighttime Chieftain

    Joined:
    Sep 20, 2002
    Messages:
    72
    Thanks for the new version, TNO, this sounds very promising! It seems that the movementMultipliers table is initially empty though. Is this a foundational piece, that you're intending to fill out with appropriate keys/values in a later TOTPP release? Or is this something that's fully ready for use by scenario developers, we just need to populate it? (If the latter, I'm not quite understanding what keys are valid to use here.)

    I've recently found a few other anomalies in trying out various aspects of Lua and TOTPP, and I wondered if you (or perhaps someone else in the community) could help me out:

    1) For organizational purposes, I tried splitting some Lua functions out into a second .lua file, located in the same scenario directory as events.lua, which I would "require" from the main events file. However, this returns the following:
    Code:
    C:\Games\Civ2ToT\TestScen\events.lua:62: module 'events2' not found:
       no field package.preload['events2']
       no file 'C:\Games\Civ2ToT\lua\events2.lua'
       no file 'C:\Games\Civ2ToT\lua\events2\init.lua'
       no file 'C:\Games\Civ2ToT\events2.lua'
       no file 'C:\Games\Civ2ToT\events2\init.lua'
       no file 'C:\Games\Civ2ToT\..\share\lua\5.3\events2.lua'
       no file 'C:\Games\Civ2ToT\..\share\lua\5.3\events2\init.lua'
       no file '.\events2.lua'
       no file '.\events2\init.lua'
       no file 'C:\Games\Civ2ToT\events2.dll'
       no file 'C:\Games\Civ2ToT\..\lib\lua\5.3\events2.dll'
       no file 'C:\Games\Civ2ToT\loadall.dll'
       no file '.\events2.dll'
    I would have thought that '.' would be my scenario directory and '.\events2.lua' would succeed, but apparently not. It finds my events2.lua file just fine if I move it to one of the locations listed above with a fully qualified path. For the sake of distributing a scenario, though, it seems highly advisable to keep all events files in the scenario subdirectory if possible. Any thoughts?

    2) The new "onCityFounded" trigger works very well, except that in my testing it fires as soon as I give the command to build a city (i.e., as soon as I hit 'b'), while the "What Shall We Name This City?" dialog is still up on the screen. The city object received by the trigger contains the city's name as if that was finalized, but in fact I can change it in that dialog box. In fact, I can actually click "Exit" and undo the entire build, so that a city is not founded and my Settler unit still exists and is active. Would it be possible to delay the trigger so that it fires immediately after you click OK in that dialog box?

    3) I've encountered a few issues with Lua returning negative values that seem unexpected. Specifically, in at least a couple places, some things return -128 instead of +128, which seems like a situation involving signed/unsigned bytes. One example is tile.terrainType: this normally returns 0 through 15, unless the tile has a river. The river seems to subtract 128 from the normal value -- so a Grassland tile is "2" but a Grassland with a river is "-126". Another example is tile.improvements, where I think pollution (0x80 bitmask value) returns "-128". Is this working as intended? Is trial and error the best approach to see what is returned in similar cases, or is there a more general/consistent rule?

    As always, thanks for the great work and for any further help you can provide.
     
  17. Ce Tecpatl

    Ce Tecpatl Chieftain

    Joined:
    Dec 1, 2016
    Messages:
    3
    Gender:
    Male
    The Launcher doesn't start at all for me. ToT 1.1, WinXP.
     
  18. TheNamelessOne

    TheNamelessOne Chieftain

    Joined:
    Dec 18, 2013
    Messages:
    196
    It's not empty, I just haven't provided the documentation in the Lua thread yet. I'll do that shortly, but in the meantime you can try the keys 'road', 'railroad', 'alpine', 'river' and 'aggregate'.

    A valid point, the scenario directory is not in the search path atm. I'll be sure to add this in a future version. As a workaround, you can require 'package', and add the directory to package.path yourself. See the documentation for require & package for more information on how modules are loaded.

    Ah yes, this should run a little later - I'll change it.

    It shouldn't really matter as it is just representation, except in the case of terrainType, since there is no way to add or remove rivers now (I restrict the values to 0-15 on assignment, I'll have to change this). Just make sure you use bitwise operators in tests and assignments (e.g. to test for the presence of a river, use tile.terrainType & 0x80, to add pollution to a tile, use tile.improvements = tile.improvements | 0x80).
     
  19. techumseh

    techumseh Chieftain

    Joined:
    Mar 12, 2002
    Messages:
    1,205
    Location:
    in the frozen north
    I just experienced a glitch you might want to add to your list of PP fixes. When a transport without the trireme flag enters a stack of similar units that have successfully moved without sinking and sinks, the whole lot is lost. Most frustrating.
     
  20. Ce Tecpatl

    Ce Tecpatl Chieftain

    Joined:
    Dec 1, 2016
    Messages:
    3
    Gender:
    Male
    EDIT: Strangely, I managed to patch and run the game ticking the compatibility option on "Windows 2000" on both Civ2.exe and Launcher.
     

Share This Page