Hi,
You're essentially doing everything correctly, all you've done wrong is just missed one of the nuances of the scripting used in the game, which is that many of the functions have the context parameter.
So when you used the treasury function in
Rome II you used it inside another function ("
OnFactionTurnStart") that had the
context argument. The "
conditions.FactionIsHuman" function needs the context argument passed to it for it to work, hence why when you remove the if statement you see your script as working. Likewise when you remove the "end" for this if statement the entire file has a syntax error which the game detects and hence the script isn't run, so you get a messed up camera as the intro scripts don't run.
i.e. This line gives you the context argument from you're script in Rome II:
Code:
local function OnFactionTurnStart(context)
Now in ATTILA you're using the treasury function, but this time you're using it inside of a different function ("
faction_new_sp_game_startup") that has no
context argument. Thus when you're if statements function that checks if that faction is human tries to execute it still uses the argument
context which you passed to it, however as context is not recieved from the encapsulating function it is nil, hence you crash the game as the function call breaks.
What I would suggest you do is this:
(I've commented some lines in to explain whats going on)
Code:
function faction_new_sp_game_startup()
output("faction_new_sp_game_startup() called");
-- Here we get the faction object of the key we pass to this function, store it in the 'roman_faction' variable.
local roman_faction = cm:model():world():faction_by_key("att_fact_western_roman_empire");
-- Now we access the faction object 'roman_faction' and check if it is a human player, if not run the treasury function.
if roman_faction:is_human() == false then
cm:treasury_mod("att_fact_western_roman_empire", 170000)
end;
-- put stuff here to be initialised on a new singleplayer game
end;
Hopefuly that should work, and you can see the issue you were having.
~ Mitch