Re: All LUA functions/variables/modules exposed by Empire
What you need to know about calling those functions:
- When you give too few arguments you get CTD.
- When you give enough or too many arguments you might get: "bad argument #1 to 'IsCharacterPlayerControlled' (Pointer<CHARACTER> expected, got userdata)"
So, for each function that exists you do (in a Lua script):
- use pcall to call that function with say 9 arguments that are likely of the wrong type.
- It should give an error, parse the error message, change the first argument to the right one, then try again, change second, etc (there is also chance that the first argument is already of the right type and the error message is about the second argument, be sure to handle that case as well).
- Once the function succeeds remove all extraneous arguments, and try again. If it CTDs you removed too much, which means that the argument type you removed was of the right type and required.
- Be sure to log before and after each action what was succeeded, if empire CTDs restart empire (have it set to automatically start a campaign) and read the logs to find where you were when it crashed and skip that or fix what you did wrong.
For the program you write to auto restart Empire there something you need to be aware of:
- When you start empire.exe it will activate steam (or start it if it's disabled) then quit empire, then steam will restart empire. So take that into account when you check if empire is still running.
Re: All LUA functions/variables/modules exposed by Empire
Quote:
Originally Posted by
just
Unfortunately I haven't managed to extract arguments yet. Some functions give error messages when you give the wrong type, but usually Empire just crashes, so I can't automate it. Check out Alpaca's script-o-rama thread for a couple of functions with arguments.
There is no specific script file for campaign battles, you can simply hook an event in the regular scripting.lua that gets fired during battles (like BattleDeploymentPhase).
Ok, thanks
Re: All LUA functions/variables/modules exposed by Empire
What does the condition RegionIsLocal check for, exactly? Does it mean that the region is owned by the player (or the faction whose turn it is when the function is called)?
If not, is there such a condition?
Re: All LUA functions/variables/modules exposed by Empire
Quote:
Originally Posted by
The Vicar
What does the condition RegionIsLocal check for, exactly? Does it mean that the region is owned by the player (or the faction whose turn it is when the function is called)?
If not, is there such a condition?
Yeah local means player. Don't ask me what it will do with the MP campaign though, maybe it will check for the player who's playing at the computer in question.
Re: All LUA functions/variables/modules exposed by Empire
Please provide me a piece of code to create rebellion at a region at turn 2.
I tried the fallowing with a few variants, but couldn't make it work.
Quote:
local function OnFactionTurnStart(context) if conditions.TurnNumber(context) == 1 then
if conditions.FactionName("cherokee", context) then
scripting.game_interface:force_rebellion_in_region("Canartica",10, context)
end
end
end