Results 1 to 4 of 4

Thread: Scripts Reading Text Files

  1. #1

    Default Scripts Reading Text Files

    I can't for the life of me figure out how to make a script read a text file for some extra data. This would be very useful, because if we could make mods read and write to text files, we could have separate programs read and write the same files and therefore talk to our Medieval II games. Does anyone know how to do this?

  2. #2
    Jurand of Cracow's Avatar History and gameplay!
    Join Date
    Oct 2012
    Location
    Cracovia
    Posts
    8,504

    Default Re: Scripts Reading Text Files

    Depending on what you want to achieve, you may have a look at Belovese's work: this one, or maybe this one.
    Mod leader of the SSHIP: traits, ancillaries, scripts, buildings, geography, economy.
    ..............................................................................................................................................................................
    If you want to play a historical mod in the medieval setting the best are:
    Stainless Steel Historical Improvement Project and Broken Crescent.
    Recently, Tsardoms and TGC look also very good. Read my opinions on the other mods here.
    ..............................................................................................................................................................................
    Reviews of the mods (all made in 2018): SSHIP, Wrath of the Norsemen, Broken Crescent.
    Follow home rules for playing a game without exploiting the M2TW engine deficiencies.
    Hints for Medieval 2 moders: forts, merchants, AT-NGB bug, trade fleets.
    Thrones of Britannia: review, opinion on the battles, ideas for modding. Shieldwall is promising!
    Dominant strategy in Rome2, Attila, ToB and Troy: “Sniping groups of armies”. Still there, alas!

  3. #3

    Default

    Thanks for the reply Jurand. I believe Belovese's tools reformat files that already exist as text -- I'm talking about making the game write to files that don't exist yet -- new text files that contain new information.

    For example, let's say you want to make a mod that counts casualties in a battle real-time and does something with that data in a separate program. You could use the Units units() scripting line to get data on the units in the battle, but currently there's no way that data could leave the game. If there's a way to write text files in scripts, you can write that data to a text file and have the separate program look at the same text file for the data it needs.

    I'm basically looking for a way to make my script write to a text file. I know scripts can do this -- they read and write to cfg files. Does anyone know how this is done?

    Knowledge on which script looks at your config files in the beginning of the game would also be really helpful, as I might be able to figure it out by looking through it and post what I find here.
    Last edited by Abdülmecid I; August 04, 2021 at 05:03 AM.

  4. #4
    Gigantus's Avatar I am not special - I am a limited edition.
    Patrician took an arrow to the knee spy of the council

    Join Date
    Aug 2006
    Location
    Goa - India
    Posts
    53,149
    Blog Entries
    36

    Default Re: Scripts Reading Text Files

    The script can create custom log entries in the log file which you can base on conditions. Not sure if that actually happens in real time or at game exit....

    Only game options can be written to the CFG file, scripts can't do that. When I say scripts I mean the campaign script and show me scripts, no third party scripts.

    There are a good number of battle script conditions that you can use directly in a script, depending what your precise goal is. It involves labeling the units which can then be tested individually for unit strength and other parameters. Battle scripts like that are a pain in the butt, just have a look at the one for the Agincourt battle.










Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •