Total War Center Forums  
<a href="http://www.game-advertising-online.com/" target=_blank>Game Advertising Online</a><br> banner requires iframes

Go Back   Total War Center Forums > Total War: Eras > Rome Workshop > Tools, Tutorials and Resources > Tutorials on Scripting

Tutorials on Scripting Tutorials for scripting RTW and BI. Only post tutorials or questions relevant to the existing threads.

Reply
 
Thread Tools Search this Thread Display Modes
HouseOfHam
Old June 04, 2008, 01:42 PM / How-to: Setup your mod to have more than 2 turns per year   #1
 
HouseOfHam's Avatar
Lieutenant Colonel
 
Posts: 2,521
+++++++++++++++++++++++++++++++++++
2008 Modding Award Winner2009 Modding Award Winner
Unlike MTW2, there is no single place to configure the number of turns per year in RTW. This means you'll need to use a scripting solution to solve this challenge.

If your mod does not yet have a background script, start by adding one, as described here: http://www.twcenter.net/forums/showthread.php?p=3144502

Now, if you'd rather save yourself the time, you can use this tool to generate code for your script: http://www.totalwar.org/Downloads/Rtw_Uploads/RTWupload/xtpyScriptGenerator.rar (more about using this tool below).

If you'd like to know about how the generated script works and/or how to write your own, read on.

Ok, now... on to the details! The basic idea of such a script is to monitor the current turn number and change the year and season accordingly. Since the RTW scripting language does not provide any math operators, we cannot use a loop for this. This means that every turn needs to be explicitly coded for. Needless to say, the resulting script can get quite long, but that's just how it is.

Before you start coding:
- The only season descriptors recognized by the game are summer and winter.
- You must have at least one summer and one winter season per year. If you have more than one winter season in a year, they must be placed in such a way that they follow each other back-to-back. The reason for this restriction is that character age is incremented during the season change (from winter to summer, if I remember correctly). If you do not follow this rule and intermix summer and winter seasons at random, your characters will age faster than normal. If the season never changes, they'll never age at all.
- You can start the year with either summer or winter, as you like, but I'd recommend starting with summer so a full year goes by before your characters start aging.

The easiest way to show how it works is via an example. Let's say you want to have 4 turns per year, with 2 summer and 2 winter seasons, starting at 280 BC. The code that you would add to the script for the first 2 years would then be*:

Code:
;;; Turn 0
console_command date -280
console_command season summer

; wait till turn 0 is over
while I_TurnNumber < 1
    suspend_unscripted_advice true
end_while

;;; Turn 1
console_command date -280
console_command season summer
while I_TurnNumber < 2
    suspend_unscripted_advice true
end_while

;;; Turn 2
console_command date -280
console_command season winter
while I_TurnNumber < 3
    suspend_unscripted_advice true
end_while

;;; Turn 3
console_command date -280
console_command season winter
while I_TurnNumber < 4
    suspend_unscripted_advice true
end_while

;;; Turn 4
console_command date -279
console_command season summer
while I_TurnNumber < 5
    suspend_unscripted_advice true
end_while

;;; Turn 5
console_command date -279
console_command season summer
while I_TurnNumber < 6
    suspend_unscripted_advice true
end_while

;;; Turn 6
console_command date -279
console_command season winter
while I_TurnNumber < 7
    suspend_unscripted_advice true
end_while

;;; Turn 7
console_command date -279
console_command season winter
while I_TurnNumber < 8
    suspend_unscripted_advice true
end_while
*Note: Updated comparison logic to use "I_TurnNumber < n+1", rather than "I_TurnNumber = n", because it seems to work better when (re)loading a saved game.

Then, just keep following this pattern for as many turns as necessary to cover your mod's date range. If you play the campaign past what the script covers, the game will revert to the default 2-turns-per year method.

Note: Do not put any monitor_event blocks after the 4-(or however many)-turns-per year script. They will simply never be reached until the 4-tpy script finishes.

Oh, one more thing. There is no year 0. The date goes from -1 directly to 1.


Some technical mumbo-jumbo about the tool I mentioned above:

The tool is a simple Java program that you give some parameters to (start and end years, the number of turns per year, and the number of summer/winter seasons per year), then, it generates the script for you. You must have Java installed on your system to be able to use it. Most computers with a browser on it will also have Java installed and you'll have a copy of java.exe in %SystemRoot%\system32 (that usually maps to C:\Windows\system32), which should already be in your path.

If all you get when you run xtpyScriptGenerator.bat is a message that tells you to press any key, it means Windows could not find java.exe in its path. The "path" is a list of locations the system checks when it looks for the program you're trying to run. To check what your path is set to, right click on My Computer, go into Properties > Advanced System Settings > Advanced > Environment Variables, and find the PATH variable there. The value is a semicolon-delimited list of folders to search for programs. There might be a PATH variable in both the User and System variables sections.

Sometimes, Java Runtime Environment is installed somewhere else and there isn't a java.exe in %SystemRoot%\system32\. For example, if it's C:\Program Files\Java\jre6, you'd need to make sure your path includes ;C:\Program Files\Java\jre6\bin or, if there is a JAVA_HOME variable defined, ;%JAVA_HOME%\bin
Ex-RTR VII Developer / RS2 scripting advisor
Only doing RTR Web site and RTRVII/ExRM/RS2 SVN admin stuff now

- Settlement coordinate locator -for RTW/BI. Seems to work for M2TW, too, but needs more testing.
- EDB Validator - supports RTW/BI/M2TW
- RTW scripting tutorials
- n-turns per year script generator

Last edited by HouseOfHam; May 06, 2009 at 03:57 PM.
HouseOfHam is offline  
Reply With Quote
PatricianS
Old June 04, 2008, 02:14 PM / Re: How-to: Setup your mod to have more (or less) than 2 turns per year   #2
 
PatricianS's Avatar
ЯTR Developer
 
Posts: 9,823
++++++++++++++++++++++++++++++++
+
Well done HouseOfHam :
Rome Total Realism Developer
Get RTR VII: Fate of Empires now!

See all RTR VII previews here!
Under the patronage of Tony83
Proud patron of Kepper
My mod-tools and animations tutorial





PatricianS is offline  
Reply With Quote
Salvor Hardin
Old June 04, 2008, 03:16 PM / Re: How-to: Setup your mod to have more than 2 turns per year   #3
 
Salvor Hardin's Avatar
Artifex
 
Posts: 2,636
off
Great job, HouseOfHam,

Just to make myself understand this: are you saying that by placing the two winter seasons together, the characters will only increase their age one year? That is a big discovery to me
Salvor Hardin is offline  
Reply With Quote
HouseOfHam
Old June 23, 2008, 03:48 PM / Re: How-to: Setup your mod to have more than 2 turns per year   #4
 
HouseOfHam's Avatar
Lieutenant Colonel
 
Posts: 2,521
+++++++++++++++++++++++++++++++++++
2008 Modding Award Winner2009 Modding Award Winner
Quote:
Originally Posted by Salvor Hardin View Post
Great job, HouseOfHam,

Just to make myself understand this: are you saying that by placing the two winter seasons together, the characters will only increase their age one year? That is a big discovery to me
As long as you don't have the change from winter to summer more than once per year.
Ex-RTR VII Developer / RS2 scripting advisor
Only doing RTR Web site and RTRVII/ExRM/RS2 SVN admin stuff now

- Settlement coordinate locator -for RTW/BI. Seems to work for M2TW, too, but needs more testing.
- EDB Validator - supports RTW/BI/M2TW
- RTW scripting tutorials
- n-turns per year script generator
HouseOfHam is offline  
Reply With Quote
Agisilaos
Old October 14, 2008, 11:49 AM / Re: How-to: Setup your mod to have more than 2 turns per year   #5
 
Agisilaos's Avatar
Πάμε γερά Ελλαδάρα.....
 
Posts: 2,930
++++++++++++++++++++++++++++++++++++++++
+++++++++++++++++
very interesting. +rep HouseOfHam
Agisilaos is offline  
Reply With Quote
aorda14
Old October 23, 2009, 11:05 AM / Re: How-to: Setup your mod to have more than 2 turns per year   #6
Drummer and Fifer
 
Posts: 153
++
where do you put the files after the editor makes them
aorda14 is offline  
Reply With Quote
PatricianS
Old October 23, 2009, 12:27 PM / Re: How-to: Setup your mod to have more than 2 turns per year   #7
 
PatricianS's Avatar
ЯTR Developer
 
Posts: 9,823
++++++++++++++++++++++++++++++++
+
You can find that in those tutorials I think:

How-to: Add a background script to your mod

Beginner's Scripting Guide

Rome Total Realism Developer
Get RTR VII: Fate of Empires now!

See all RTR VII previews here!
Under the patronage of Tony83
Proud patron of Kepper
My mod-tools and animations tutorial





PatricianS is offline  
Reply With Quote
aorda14
Old October 26, 2009, 02:34 PM / Re: How-to: Setup your mod to have more than 2 turns per year   #8
Drummer and Fifer
 
Posts: 153
++
maybe im just stupid...but that doesnt help....it creates a file...does anyone know where i put it? when using the genarator
aorda14 is offline  
Reply With Quote
PatricianS
Old October 26, 2009, 02:37 PM / Re: How-to: Setup your mod to have more than 2 turns per year   #9
 
PatricianS's Avatar
ЯTR Developer
 
Posts: 9,823
++++++++++++++++++++++++++++++++
+
Quote:
Originally Posted by aorda14 View Post
maybe im just stupid...but that doesnt help....it creates a file...does anyone know where i put it? when using the genarator
Uhm...

Quote:
Originally Posted by PatricianS View Post
You can find that in those tutorials I think:

How-to: Add a background script to your mod

Rome Total Realism Developer
Get RTR VII: Fate of Empires now!

See all RTR VII previews here!
Under the patronage of Tony83
Proud patron of Kepper
My mod-tools and animations tutorial





PatricianS is offline  
Reply With Quote
aorda14
Old October 26, 2009, 02:42 PM   #10
Drummer and Fifer
 
Posts: 153
++
but is this a campaign file?

ahhh i see it now lol...im a noob

Last edited by Sqυιd; October 26, 2009 at 03:02 PM. Reason: double post
aorda14 is offline  
Reply With Quote
PatricianS
Old October 26, 2009, 02:44 PM / Re: How-to: Setup your mod to have more than 2 turns per year   #11
 
PatricianS's Avatar
ЯTR Developer
 
Posts: 9,823
++++++++++++++++++++++++++++++++
+
You have to include it in a script, and the links I gave explain how to set up such a script

Edit:
No worries
Rome Total Realism Developer
Get RTR VII: Fate of Empires now!

See all RTR VII previews here!
Under the patronage of Tony83
Proud patron of Kepper
My mod-tools and animations tutorial





PatricianS is offline  
Reply With Quote
HouseOfHam
Old October 27, 2009, 10:22 AM / Re: How-to: Setup your mod to have more than 2 turns per year   #12
 
HouseOfHam's Avatar
Lieutenant Colonel
 
Posts: 2,521
+++++++++++++++++++++++++++++++++++
2008 Modding Award Winner2009 Modding Award Winner
Welcome to the club.
Ex-RTR VII Developer / RS2 scripting advisor
Only doing RTR Web site and RTRVII/ExRM/RS2 SVN admin stuff now

- Settlement coordinate locator -for RTW/BI. Seems to work for M2TW, too, but needs more testing.
- EDB Validator - supports RTW/BI/M2TW
- RTW scripting tutorials
- n-turns per year script generator
HouseOfHam is offline  
Reply With Quote
GER
Old November 24, 2009, 10:41 AM / Re: How-to: Setup your mod to have more than 2 turns per year   #13
 
GER's Avatar
Light Infantryman
 
Posts: 4
?
I have done the scripting and followed the steps, i start a campaign, i get a black screen and then it shuts down to the desktop

can you help me PLEASE?

Last edited by GER; November 24, 2009 at 11:15 AM.
GER is offline  
Send a message via ICQ to GER
Reply With Quote
PatricianS
Old November 24, 2009, 12:07 PM / Re: How-to: Setup your mod to have more than 2 turns per year   #14
 
PatricianS's Avatar
ЯTR Developer
 
Posts: 9,823
++++++++++++++++++++++++++++++++
+
I know your problem... You did something wrong!
To fix it, you should try again, without doing it wrong.


(But serious, without more information on what you did, you won't get any better answer than that )
Rome Total Realism Developer
Get RTR VII: Fate of Empires now!

See all RTR VII previews here!
Under the patronage of Tony83
Proud patron of Kepper
My mod-tools and animations tutorial





PatricianS is offline  
Reply With Quote
GER
Old November 25, 2009, 07:21 AM / Re: How-to: Setup your mod to have more than 2 turns per year   #15
 
GER's Avatar
Light Infantryman
 
Posts: 4
?
well man, i've tried it again and again, but i couldn't find my fault (i don't know much about those things)

1. Add a new thread to export_descr_advice.txt: (i've added it at the beginning of the document, but after the "== ADVICE THREAD DATA STARTS HERE ==", so that it should work

2. At the end of the export_descr_advice.txt file, add the following triggers for the above advice thread. (i've added it at the end of the document)

3. Add the following lines at the end of the text\export_advice.txt file: (also this lines i've added at the end)

1. Add the following at the very end of descr_strat.txt:

2. In the same folder with the descr_strat.txt file for your mod, create a new file called campaign_script.txt (our campaign script) and put these lines into it:

1. In the scripts\show_me folder, create a new file called background_script.txt <-- This is the file referenced by the On_display line in the advice thread in Section I. Traditionally, everyone puts their scripts into scripts\show_me, but you can put it anywhere you like and call it anything you want, as long as you update the On_display line to point to it.

then i've used the script generator (6 turns per year, 3 summers, 3 winters), and i've added the threats to text\export_advice.txt and export_descr_advice.txt, i've also put the xtpy.txt to the scripts/show me folder, and because i was not sure, i've copied the text also in the backgroundscript.txt

you know where's my fault?? (maybe i just didn't understand one step, my english is not very well.....)
oh, one thing, i've got RTR Platinum and The Fourth Age-TW, i hope it doesn't matter

Last edited by GER; November 25, 2009 at 02:19 PM.
GER is offline  
Send a message via ICQ to GER
Reply With Quote
HouseOfHam
Old November 30, 2009, 01:24 AM / Re: How-to: Setup your mod to have more than 2 turns per year   #16
 
HouseOfHam's Avatar
Lieutenant Colonel
 
Posts: 2,521
+++++++++++++++++++++++++++++++++++
2008 Modding Award Winner2009 Modding Award Winner
Most likely, filenames are not matching between what's in export_descr_advice.txt/descr_strat.txt and what you actually called them.
Ex-RTR VII Developer / RS2 scripting advisor
Only doing RTR Web site and RTRVII/ExRM/RS2 SVN admin stuff now

- Settlement coordinate locator -for RTW/BI. Seems to work for M2TW, too, but needs more testing.
- EDB Validator - supports RTW/BI/M2TW
- RTW scripting tutorials
- n-turns per year script generator
HouseOfHam is offline  
Reply With Quote
Ciisar
Old December 17, 2009, 05:54 PM / Re: How-to: Setup your mod to have more than 2 turns per year   #17
Ensign
 
Posts: 1,167
++++++++++
I have one problem. I have already one 4 turn per-year script, but i wanna change it to 12.
I have done the 12 turns per-year script, but how i can delete old one? Where it is?
Ciisar is offline  
Reply With Quote
HouseOfHam
Old December 18, 2009, 09:54 AM / Re: How-to: Setup your mod to have more than 2 turns per year   #18
 
HouseOfHam's Avatar
Lieutenant Colonel
 
Posts: 2,521
+++++++++++++++++++++++++++++++++++
2008 Modding Award Winner2009 Modding Award Winner
Well, the script itself is most likely in the scripts\show_me folder. Take a look at the files there to see which one it is. Once you've identified it, just replace the contents with your own. Just be careful, there might be other code besides the 4tpy in there.
Ex-RTR VII Developer / RS2 scripting advisor
Only doing RTR Web site and RTRVII/ExRM/RS2 SVN admin stuff now

- Settlement coordinate locator -for RTW/BI. Seems to work for M2TW, too, but needs more testing.
- EDB Validator - supports RTW/BI/M2TW
- RTW scripting tutorials
- n-turns per year script generator
HouseOfHam is offline  
Reply With Quote
CPT Worsham
Old April 27, 2010, 09:37 PM / Re: How-to: Setup your mod to have more than 2 turns per year   #19
 
CPT Worsham's Avatar
Chosen Man
 
Posts: 203
+++
Quote:
Originally Posted by HouseOfHam View Post
Sometimes, Java Runtime Environment is installed somewhere else and there isn't a java.exe in %SystemRoot%\system32\. For example, if it's C:\Program Files\Java\jre6, you'd need to make sure your path includes ;C:\Program Files\Java\jre6\bin or, if there is a JAVA_HOME variable defined, ;%JAVA_HOME%\bin
The script generator is not recognizing that I have java installed but I do. My java.exe is installed in this path: C:\Program Files (x86)\Java\jre6\bin. How do I make the script generator read that path to my java.exe?
Respectfully,

CPT Worsham
CPT Worsham is offline  
Reply With Quote
HouseOfHam
Old April 28, 2010, 12:24 PM / Re: How-to: Setup your mod to have more than 2 turns per year   #20
 
HouseOfHam's Avatar
Lieutenant Colonel
 
Posts: 2,521
+++++++++++++++++++++++++++++++++++
2008 Modding Award Winner2009 Modding Award Winner
Add that directory to your path.

If using Vista:
- right-click on My Computer
- select Properties
- Advanced System Settings > Advanced > Environment Variables
- find the PATH variable in the system section and edit it. At the end of the Variable value line, append a semicolon, then C:\Program Files (x86)\Java\jre6\bin
Ex-RTR VII Developer / RS2 scripting advisor
Only doing RTR Web site and RTRVII/ExRM/RS2 SVN admin stuff now

- Settlement coordinate locator -for RTW/BI. Seems to work for M2TW, too, but needs more testing.
- EDB Validator - supports RTW/BI/M2TW
- RTW scripting tutorials
- n-turns per year script generator
HouseOfHam is offline  
Reply With Quote
Reply


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off


<a href="http://www.game-advertising-online.com/" target=_blank>Game Advertising Online</a><br> banner requires iframes

All times are GMT -5. The time now is 03:47 AM.


Forums powered by vBulletin® Version 3.8.5 - Copyright ©2000 - 2010, Jelsoft Enterprises Ltd.