Page 2 of 2 FirstFirst 12
Results 21 to 25 of 25

Thread: All LUA functions/variables/modules exposed by Empire

  1. #21

    Default 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.

  2. #22

    Default Re: All LUA functions/variables/modules exposed by Empire

    Quote Originally Posted by just View Post
    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

  3. #23

    Default 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?
    Every day takes figuring out all over again how to live.

  4. #24
    alpaca's Avatar Harbinger of saliva
    Join Date
    Sep 2005
    Location
    Germany
    Posts
    4,811

    Default Re: All LUA functions/variables/modules exposed by Empire

    Quote Originally Posted by The Vicar View Post
    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.

    No thing is everything. Every thing is nothing.

  5. #25

    Default 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.
    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

Page 2 of 2 FirstFirst 12

Posting Permissions

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