They are but only once or perhaps only one faction because you didn't include the following at the very of the script.
Code:while I_TurnNumber < 99999 suspend_unscripted_advice true end_while
They are but only once or perhaps only one faction because you didn't include the following at the very of the script.
Code:while I_TurnNumber < 99999 suspend_unscripted_advice true end_while
Under the patronage of Roman_Man#3, Patron of Ishan
Click for my tools and tutorials
"Two things are infinite: the universe and human stupidity; and I'm not sure about the universe." -----Albert Einstein
Thanks now it's works
Creator of modification The Great Ancient World IV
Team-leader of Polish Project translation modifications:
Kingdoms Grand Campaign Mod 4.2 (v1.0)
Third Age: Total War 2.0/2.1 (v1.01)
Third Age: Total War 1.4/1.4.1 (v1.0)
Broken Crescent 2.02 (v0.95)
Stainless Steel 6.2 RC4 (v0.60)
INVASIO BARBARORVM 2:AFRICA VANDALORVM v1.2 (v0.7)
Hi guys!
Sorry if you consider this a dig but this thread seems to be the most comprehensive coverage of the background script execution problematic.
Therefore I wanna share my own finds here - even though it's been years since anyone worried about this.
GAMERELOADED EVENT
Indeed Bardo's final method is probably as far as we get towards automatic execution of background scripts.
But I've done some aditional testing and discovered a little bit more. First, an explanation of why the trigger on GameReloaded event works the way it does. Bardo explains on the ORG:
My testing shows the following and I'm confident this is the real way things work:Originally Posted by Bardo
- AdviceThread Lotr_Script_Thread 1 - there's no confusion here it adds 1 to the counter and opens the advise up, if Threshold is reached
- AdviceThread Lotr_Script_Thread 0 - This resets the counter first to 0 and then increases by 1.
Now the GameReloaded event. Many people suspect it doesn't work, Bardo claims it does, since his method works (and it really does). Well, both camps are right.
Mys testing shows this trigger gets fired, no doubt about it:
it does effect the counter towards the Threshold. But the Advisor never shows up and my guess here is that the moment this trigger gets fired the engine doesn't have the UI ready yet to show the advisor.Code:;------------------------------------------ LOTR-TW trigger Trigger Reload_Script_Trigger WhenToTest GameReloaded AdviceThread Lotr_Script_Thread 0
These finds brought me to an idea. Bardo uses the GameReloaded event in the background script to terminate the script when a game is reloaded (again, this really works):
Well, how about this?Code:monitor_event GameReloaded TrueCondition terminate_script end_monitor
it doesn't work - hopefully yet . The logic would seem right but I'm really new to RTW scripting so I might be missing some obvious flaw in this concept...Code:declare_counter C_GameReloaded monitor_event GameReloaded TrueCondition set_counter C_GameReloaded 1 end_monitor monitor_conditions I_CompareCounter C_GameReloaded = 1 wait 5 console_command trigger_advice Lotr_Script_Thread advance_advice_thread Lotr_Script_Thread no_dismiss set_counter C_GameReloaded 0 terminate_script end_monitor
I'll certainly keep on testing this
ADDITIONAL SMALL FINDS
When you reload a game, occasionally, showing the advisor with the current season and date(advance_advice_thread Season_Year_TurnXX_Thread), it shows only the Startup advisor (Lotr_Script_Thread). Yet, the script is started - when you end the turn, you get the season and year when your turn begins.
Using "suspend_unscripted_advice true" at the start of the script does seem to prevent that.
Next, the following in Bardo's script somehow messed things up:
I have removed it and experienced no problems at all.Code:wait 1 select_ui_element advisor_dismiss_button simulate_mouse_click lclick_up
So this is my version of the background script:
Hope this helps and we're not done yet with this .Code:script suspend_unscripted_advice true declare_show_me ...
Last edited by Greno Zee; December 15, 2010 at 06:06 AM.
Hey, I'm glad people still continues reasearching on this. I feel we still need a complete guide about the advice file, but after many test, all I got was some theories about how it works, nothing really confirmed.
Good point about this:
Your explanation seems to confirm my experiments with threshold=1. But then, if threshold is 2, this advice is never launched?Code:AdviceThread Lotr_Script_Thread 0 - This resets the counter first to 0 and then increases by 1.
This code is not needed, it simply closes the advisor when the script is executed:
About the line:Code:wait 1 select_ui_element advisor_dismiss_button simulate_mouse_click lclick_up
I do not use it because our mod launches unscripted advices and that line would avoid them.Code:suspend_unscripted_advice true
In fact, all my reaserch about launching scripts was focused to avoid the use of that command suspend_unscripted_advice. Many scripters seems to use HouseOfHam method, that is simpler and gets similar results. But there is one little advantage of my method, that it is very important to me:
- When you are playing a campaign with scripts activated, and you reload a savegame, the script is reactivated automatically.
(It is not completely automatic because: If you load a savegame when you just entered the game, you need to press on advisor portrait, the same with both methods).
About this...
I'd say it is exactly the same than this:Code:declare_counter C_GameReloaded monitor_event GameReloaded TrueCondition set_counter C_GameReloaded 1 end_monitor monitor_conditions I_CompareCounter C_GameReloaded = 1 wait 5 console_command trigger_advice Lotr_Script_Thread advance_advice_thread Lotr_Script_Thread no_dismiss set_counter C_GameReloaded 0 terminate_script end_monitor
I tested something similar, with different waiting times, and I had no luck.Code:monitor_event GameReloaded TrueCondition wait 5 console_command trigger_advice Lotr_Script_Thread advance_advice_thread Lotr_Script_Thread no_dismiss terminate_script end_monitor
As you say, I'm sure GameReloaded does work, but I have been unable to use it directly to launch the advices.
I wish you more luck.
Last edited by Bardo; December 15, 2010 at 12:25 PM.
Hey Bardo, great you're still interested!
AdviceThread Lotr_Script_Thread 0
I found out how it works exactly by setting the Threshold to higher numbers. I put to CharacterSelected trigger
AdviceThread Lotr_Script_Thread 0 and to SettlementSelected trigger AdviceThread Lotr_Script_Thread 1. Whenever I selected any character, I needed Threshold - 1 selected settlements to get the Advisor show up
Now I'm very interested in your comment that when you don't use
suspend_unscripted_advice true, the script stays running after loading a campaign. I've got a very simple script, where there is one event monitor declared. Whenever I reload the game, it stops executing the monitor. So I wondered, is there anything else needed to keep it running after reloading?
According to the discussion in this very thread wait command in event monitors doesn't work:
That's why I split it as suggested in the discussion here...Code:monitor_event GameReloaded TrueCondition wait 5 ; won't work console_command trigger_advice Lotr_Script_Thread advance_advice_thread Lotr_Script_Thread no_dismiss terminate_script end_monitor
Hm, please, let me correct myself.
You never said "suspend_unscripted_advice true" would have anything to do with scripts staying in memory after reload. No idea why i interpreted your message this way .
In any case:
In none of my tests I've been able to confirm that the background script stays active after you reload a game. I'd be very happy if anyone can prove me wrong. But if I'm not, it means:
- The following event monitor has got no use:
Code:monitor_event GameReloaded TrueCondition terminate_script end_monitor- The trigger counts do keep their values after reload, so this trigger is indeed required to reset the counter and fire the script up again after the reload:
There is no doubt this trigger does fire, it only seems not to be able to access the user interface and can't be used directly to fire the script, only to reset the count.Code:Trigger Reload_Script_Trigger WhenToTest GameReloaded AdviceThread Lotr_Script_Thread 0
On top of that, I've been able to confirm one of the scariest behaviors I've ever seen in scripting: the scripting engine survives the application shutdown! Even if I close the game using the menus, I've been able to confirm that sometimes some AdviceThread counters keep their values between RTW sessions.
Very, very frightening!
You are right about "wait" command not working inside monitors, I forgot. Altough I remember to test it with GameReloaded, just in case.
Don't be scary , the advice counters are saved at this file:
\preferences\advice
If you remove it, the file is regenerated with counters to 0.
Once, I had the idea to use this feature to save the state of script counters, but the advice counters are affected by every campaign and every game you play, so I do not think it would be useful.
I do not think scripts can keep active after you reload a savegame, I would say they stop working when you load a different game. But sometimes when you load a savegame (always when you reload an autosave) and there is already a script running, the new script does not take effect until the next turn (as you have also verified).
Well, I'm almost sure that the event GameReloaded is detected by the script previously running (before you reload), probably it is the latest event it detects. And I have verified that I can use it with terminate_script to allow the new script (launched after you reload) to be activated just when you press end turn.
It is hard to explain. I mean, if you remove this part
the new script will not work until the start of your next turn, and it will miss all the events from the first AI turn.Code:monitor_event GameReloaded TrueCondition terminate_script end_monitor
As you said, this is not a problem if you are using "suspend_unscripted_advice true".
I think the problem if you use "suspend_unscripted_advice true" is it prevents the advisor from being showed automatically, and you need to click on the advisor portrait to activate the script. Although I never used that method and I would need to verify the cause.
With my method, if the advice is declared as "on_display" and the script is declared as "declare_show_me", the advisor is opened automatically and so the scripts are executed automatically as soon as the player press any button.
In our mod, if you are playing a campaign and you decide to reload a savegame, you do not need to do anything to reactivate the scripts. As soon as you press any button (for example end turn):
the advisor will be launched thanks to "Gamereload" event, it will be opened automatically thanks to "declare_show_me", and the scripts will be executed automatically thanks to "on_display".
However, it does not work the first time you load a savegame when you just entered the game. The first time, you need to click the advisor portrait. And this is the only non-automatic issue that I never solved.
Then it will be automatic again with every reload, at least until another script declared as "declare_show_me" is executed.
I do not know if you understood something (sorry my english), but I think mine was an important discovery, and I didn't get anyone interested to help me researching that feature: "declare_show_me" + "on_display".
It took me many time to develop an alternative method without "suspend_unscripted_advice true", but people here considered it just a variant of HouseOfHam's method. I think I advanced one step, and we still need another step to automatize it completely.
Last edited by Bardo; December 16, 2010 at 05:06 PM.
Thanks for the explanation! I think I perfectly understand all you say.
And it all makes sense and perfectly fits the results of my own testing.
Now the good news:
I've been playing around a bit, reloading games from the main menu, from the game, starting new campaigns, reloading again and the only time I needed to touch the Advisor to launch the script was when I exited the game and started a new campaign. Not after loading anymore .
But before I tell you, there's one thing I need to ask you. In none of my attempts I was able to lanch the script after loading with the End Turn button. How do you manage that? Whatever I tried, the Advisor started to appear but before it could launch the script, another faction took over and the Advisor moved away.
And here goes: How did I manage that when I start the game and then load my save, I don't need to click on the advisor to launch the script? Actually, by a workaround, not a real solution.
I'm sure you provide your users with a shortcut to launch your mod, right? Well, put the -strat:... option in there. It starts a new campaign directly and then your users can either load their game, go to the main menu, whatever. I know many people will find this clumsy but it works for me .
Good job! it works for me too. We can create this shortcut named "play campaign" or something similar and people who use it would not need to be worried about activation of scripts.And here goes: How did I manage that when I start the game and then load my save, I don't need to click on the advisor to launch the script? Actually, by a workaround, not a real solution.
I'm sure you provide your users with a shortcut to launch your mod, right? Well, put the -strat:... option in there. It starts a new campaign directly and then your users can either load their game, go to the main menu, whatever. I know many people will find this clumsy but it works for me
I guess there is a mistake in your sentence, and you wanted to say it fails when you start a new campaign without exiting the game. Doesn't it?I've been playing around a bit, reloading games from the main menu, from the game, starting new campaigns, reloading again and the only time I needed to touch the Advisor to launch the script was when I exited the game and started a new campaign.
Else, I have good news for you, because that issue was solved long time ago. Both systems described in this topic should launch the script automatically when you start a new campaign.
These lines in the "Campaign Script" (placed in the campaign folder) makes the trick in my case:
I don't remember now, but I think I needed 2 triggers to increase the advice counter and to prepare it for the gamereloaded event.script
declare_show_me
;...
wait 1
console_command trigger_advice Lotr_Script_Thread
advance_advice_thread Lotr_Script_Thread no_dismiss
end_script
I have just tested in my new pc and you are right, the advisor does not have time to appear before the AI starts to move.But before I tell you, there's one thing I need to ask you. In none of my attempts I was able to lanch the script after loading with the End Turn button. How do you manage that? Whatever I tried, the Advisor started to appear but before it could launch the script, another faction took over and the Advisor moved away.
But I promiss you it worked in my old pc. I even verified if the scripts were active all along the AI turn, and the scripts didn't miss any AI faction turn.
It might depend on the speed of the pc. I already noticed my only script that used the "wait" command with a timer (a question to the player to control the fellowship of the ring) stoped working when I changed to a faster pc.
Then, I guess the "end turn" button is not a reliable way to activate the background script... it is a pitty.
Actually, not even that. Force your users to always open RTW this way if they want to play your mod. If you do, even when they launch and want to load a previous save, the advisor button will not come up flashing anymore and the script launches smoothly without any user interaction.
Sorry, wrong terminology. I meant game as a game in progress - exiting the game to main menu, without exiting RTW (the applications). But we understand each other .
I know, I'm using this trick and it works . But when you play a game, then quit to main menu and then start a new campaign, the Advisor comes up flashing and the user has to click it to launch the script. Just the same what you had when you start the application and load a game that's no autosave - which gets cured by using the -strat:... parameter.
Looks like that. Lucky enough, I can hardly imagine anyone loading a game and ending a turn without checking the status of their empire at all, so I wouldn't worry about this much .
Thanks for pointing this out - there's still a lot I don't know about the internal of RTW .Originally Posted by Bardo
AFAIK, \preferences\advice only stored values for threads marked as Supressible, the ones where you get a little checkbox you can hit not to see them again.
RTR website/SVN admin
- Settlement coordinate locator -for RTW/M2TW
- EDB Validator v1.2.8 (Oct 16, 2012) - for RTW/M2TW
- RTW scripting tutorials
- n-turns per year script generator
Well, after reading part of the debate, I feel a bit stupid asking the following, but anyway, I'll do it. Here it goes:
I have followed the whole explanation, and the xtpy_script is working (I'm using 4 turns per year). However, I had to put everything into the background script .txt file. Is there a way of keep everything on separate files? Do I need some kind of trigger? Any help on that matter will be great
PS: I have read the Beginner's Scripting guide and still, I couldn't get the answer. Someone should release a scripting guide for dummies.
There are none so enslaved as those who falsely believe they are free
What do you mean by "everything"? Is something not working? 4tpy script is normally incorporated into the background script, so what you've done shouldn't be causing any problems.
RTR website/SVN admin
- Settlement coordinate locator -for RTW/M2TW
- EDB Validator v1.2.8 (Oct 16, 2012) - for RTW/M2TW
- RTW scripting tutorials
- n-turns per year script generator
Ok, so that's all. Just another thing: do I have to include the whole code? I mean, at the beginning of the xtpy_script.txt file I get the following lines:
Do I have to include all that into the monitor's part of the background script?Code:script declare_show_me ; Used to automatically open the advisor text bubble when advance_advice_thread is called suspend_during_battle on suspend_unscripted_advice true ;console_command toggle_perfect_spy
PS: Sorry for posting here, I thought this was the "How-to: Setup your mod to have more than 2 turns per year" thread
There are none so enslaved as those who falsely believe they are free
Nope, just the stuff that sets year, season, and checks for turn numbers. If you took background_script.txt from this tutorial, it already has everything else.
RTR website/SVN admin
- Settlement coordinate locator -for RTW/M2TW
- EDB Validator v1.2.8 (Oct 16, 2012) - for RTW/M2TW
- RTW scripting tutorials
- n-turns per year script generator
Thanks! This is the last one: shall I include other pieces of code before the 4tpy script or after it? I mean, does it change anything the position of the code in the background script file?
There are none so enslaved as those who falsely believe they are free
The 4tpy code pauses at while loops on every turn, so any monitors that need to be active from the beginning would need to be declared before it. If necessary, you could also embed code between turns.
RTR website/SVN admin
- Settlement coordinate locator -for RTW/M2TW
- EDB Validator v1.2.8 (Oct 16, 2012) - for RTW/M2TW
- RTW scripting tutorials
- n-turns per year script generator
Can anyone help me with this code?
How can I make this deliver when the human faction owns a particular region?Code:--------------------------------------------------------------------------------------------------------------------------- -- DOPSHOGUN -- local current_dopshogun = "" local function OnFactionTurnedShogun(context) local current_dopshogun = context.string; scripting.game_interface:create_force(--[FACTION]-- current_dopshogun, --[SPECIFIC ARMY LIST]-- "Cav_Spear_Great_Guard,Cav_Spear_Yari_Cavalry,Cav_Spear_Yari_Cavalry", --[COORDINATES]-- -44.0, -124.0, --[ID]-- "Great Guard", --[USE_COMMAND_QUEUE]-- true) scripting.game_interface:create_force(--[FACTION]-- current_dopshogun, --[SPECIFIC ARMY LIST]-- "Heavy_Ship_Nihon_Maru,Light_Ship_Bow_Kobaya,Light_Ship_Bow_Kobaya", --[COORDINATES]-- -64.0, -130.5, --[ID]-- "Epic Ship", --[USE_COMMAND_QUEUE]-- true) end
Evening all,
I was able to successfully install and operate the Rome Total Realism mod, which looks great. It was my impression that a 4tpy script was integral to it, however it does not appear to be so. I have had little luck in locating a 4tpy script that currently works for my mac app store version of RTW, and have not had any luck creating my own script, despite following the directions earlier in this thread. I was wondering if anyone might be able to point me in the right direction or offer some advice, as most expertise appears to either be focused on the pc version, or on the newer RTWII.
Thanks in advance.