Results 1 to 5 of 5

Thread: Complete Beginner Scripting Questions

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1

    Default Complete Beginner Scripting Questions

    Hey guys, I have a couple of questions regarding scripting. One that I'd like to add, and one that I'd like to edit. I just have no idea how to go about either of them

    Firstly, I would like to add a script that removes a certain amount of money from the Maratha Confederacy's treasury every turn. At this point I'm willing to try anything to be able to fight someone other than the Marathas in the late game, endless battles against the Orange Plague are boring me to death!

    Secondly, I would like to edit the script that gives the American Colony factions (New Spain, Louisiana, 13 Colonies) to their parent faction if that parent faction is AI controlled. These factions always vanish much to quickly, so I was wondering if it was possible to edit the script so that the earliest date for any merge to occur is sometime in the late 1790s.

    Any suggestions would be most welcome!

  2. #2

    Default Re: Complete Beginner Scripting Questions

    You're looking for the scripting.lua file for whatever campaign you're modding (not in a pack, but in the empire data folder)
    You'll have to add code that looks something like
    Code:
    local function OnFactionTurnStart(context)
    	if conditions.FactionName("maratha", context) then
    		effect.adjust_treasury(-1000,context)
    	end
    end
    http://www.twcenter.net/forums/showthread.php?t=243427 for a few small scripting samples, there are also some mods that contain a lot of scripting (e.g. ape:ti) that you could look at to see how they do it.
    http://www.twcenter.net/forums/showthread.php?t=243201 for an overview of functions you can call from your scripts

  3. #3

    Default Re: Complete Beginner Scripting Questions

    Heh, sorry for being a total n00b at this, but how do you open the .lua files? I tried and it just says I don't have anything to read them with.

  4. #4

    Default Re: Complete Beginner Scripting Questions

    Notepad (comes with Windows) will work.

  5. #5

    Default Re: Complete Beginner Scripting Questions

    Thanks for that, I've included the above script at the end of the file. Now, regarding my second question about the American Protectorates, I found the part of the script that mentions the Protectorates being handed over if the home faction is controlled by the AI. There were a couple of numbers there, a 6 and a 15. These, I assume, are the turn numbers for the earliest and latest that this event can happen? I've changed them to 195 and 200 respectively. Am I right in thinking, therefore, that the Protectorates will not join their AI home factions before 1795?

Posting Permissions

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