Page 5 of 5 FirstFirst 12345
Results 81 to 92 of 92

Thread: [scripting] The "does this code work" - Thread

  1. #81
    Foederatus
    Join Date
    Apr 2010
    Location
    Russia, Volgograd
    Posts
    27

    Default Re: [scripting] The "does this code work" - Thread

    thanks,
    local settlement_name = context:garrison_residence():region():settlement():name()
    local region = context:garrison_residence():region():name()
    "settlement:"..region..":"settlement_name

    but, SETTLEMENT_SCRIPT_INTERFACE not contain name(), how get it?

  2. #82
    Foederatus
    Join Date
    Apr 2010
    Location
    Russia, Volgograd
    Posts
    27

    Default Re: [scripting] The "does this code work" - Thread

    thanks,
    local settlement_name = context:garrison_residence():region():settlement():name()
    local region = context:garrison_residence():region():name()
    "settlement:"..region..":"settlement_name

    but, SETTLEMENT_SCRIPT_INTERFACE not contain name(), how get it?

  3. #83
    Semisalis
    Join Date
    Sep 2011
    Location
    New Zealand
    Posts
    412

    Default Re: [scripting] The "does this code work" - Thread

    Sorry, don't understand your question. There is only one settlement per region so you only need the region name.
    ~ Too soon old, too late smart ~

  4. #84
    Foederatus
    Join Date
    Apr 2010
    Location
    Russia, Volgograd
    Posts
    27

    Default Re: [scripting] The "does this code work" - Thread

    sorry for my english, command :
    scripting.game_interface:grant_unit("settlement:rom_scythia_scythia:gelonus","Mer_Ibe_Noble_Fighters")
    i want get region and settlement name from event(settlement selected) and command :
    scripting.game_interface:grant_unit("settlement:"..region..":"..settlement..,"Mer_Ibe_Noble_Fighters")
    region = context:garrison_residence():region():name(), but settlement = ???

  5. #85
    Foederatus
    Join Date
    Apr 2010
    Location
    Russia, Volgograd
    Posts
    27

    Default Re: [scripting] The "does this code work" - Thread

    local function OnGrantUnits(context)
    local var1 =
    TCS_Log_Update(var1)
    local owning_faction = context:garrison_residence():faction():name()
    if owning_faction == "rom_roxolani" then
    scripting.game_interface:grant_unit(var1,"Mer_Ibe_Noble_Fighters")
    end
    end

    i dont get a settlement names for my variable(

  6. #86
    Foederatus
    Join Date
    Apr 2010
    Location
    Russia, Volgograd
    Posts
    27

    Default Re: [scripting] The "does this code work" - Thread

    hmm, in wrath of sparta campaign settlement_id = "settlement:"+region key, in rome campaign "settlement:"+region key":"+settlement name. Anyone could find a settlement_id ?

  7. #87

    Default Re: [scripting] The "does this code work" - Thread

    @Seregavg, I fully share your frustration because I have been trying to make those game_interface add/grant unit commands work for 3 hours until now. I have been trying to RE it to understand which parameters formats are requested (the "settlement:" prefix for example), which fields must be used (region names don't work, settlement ids from ESF don't work, combinations don't work), which parameters must be adapted from Attila's documentation (the only one which is available on the web and containing the function interfaces) but i'm still in a black hole.
    __________

    I'm disappointed because this community is good, many modders are even helpful but as soon as anyone wants to push on the "advanced customizations" pedal, then the effort becomes exponential. Actually not even exponential because you don't have any way to estimate how long it will take to get to a final statement, be it red or green. The effort becomes huge and totally unpredictable. I don't want to make assumptions about the real backstage reasons that make this happen but it happens because the available documentation is poor.

    I don't have a whole Tbyte of code samples from CA or from top-tier modders and I must rebuild the wheel everytime I face an undocumented or scarcely documented function. This is not progress.

    What I also know is that you can't fully rely on forums because the skilled "community" able to provide advanced answers is a dozen of persons, maybe less, with their jobs and life.

    I'm humbly working to try out something that the community of players might enjoy but it's a lost battle. It takes too much time, too many "black box" experimentations and after 1 script and 4 mods with low/very low popularity, my bright side pushes me to improve my newbie performances but my dark side, the pragmatical one, suggests me to focus on something that makes a better use of my time than reverse-engineering badly documented functions as a precondition for every creative development.

    This is why I warmly ask some enlighted modders, possibly close to CA, to take this post as a "constructive" complaint (actually it's pure frustration by now) and to support with more vitality the creation proposal of a programming reference manual. Considering the small amount of modders that have time/skills to script and the low frequency at which new discoveries are achieved, I would elaborate something if i was in charge to decide.

    Don't take this as a "please open all interfaces" post. I can presume there are reasons behind, that involve corporate strategies. Take it as a "guys, limit reached, we should proactively share some more details now or our modders' wives will ask for divorce. Massively.".

    Prime

  8. #88
    Foederatus
    Join Date
    Apr 2010
    Location
    Russia, Volgograd
    Posts
    27

    Default Re: [scripting] The "does this code work" - Thread

    totally agree with you,
    local function OnGrantUnits(context)
    if context:garrison_residence():settlement_interface():region():owning_faction():name() == "rom_roxolani" then
    scripting.game_interface:grant_unit("settlement:rom_scythia_scythia:gelonus","Mer_Ibe_Noble_Fighters")
    end
    end
    scripting.AddEventCallBack("FactionTurnStart", OnGrantUnits)
    is work, but
    scripting.game_interface:grant_unit("settlement:???????????????settlement_id?????????","Mer_Ibe_Noble_Fighters")
    in rome campaign does not want.

  9. #89
    Foederatus
    Join Date
    Apr 2010
    Location
    Russia, Volgograd
    Posts
    27

    Default Re: [scripting] The "does this code work" - Thread

    and where to find information - it is not clear

  10. #90

    Default Re: [scripting] The "does this code work" - Thread

    Hey guys,


    I would like to add some money to the faction if its treasury was more than a fixed amount or subtract some money if its treasury was less than a fixed amount.


    Adding money way has works, it looks like this:
    Code:
    local function AddMoney(context) 
    local current_faction = context.string;
      local treasury_count = context:faction():treasury();
        if treasury_count <= 500 then
            scripting.game_interface:treasury_mod(current_faction, 250);
        end 
    end 
    scripting.AddEventCallBack("FactionTurnStart", AddMoney)
    But I was not able to get it to work with scripting.game_interface:treasury_mod(current_faction, -250)


    So I turned to other methods.
    Has someone any experiences with the losing_money function and its parameters?
    Code:
    local function SubtractMoney(context) 
    local current_faction = context.string;
      local treasury_count = context:faction():treasury();
        if treasury_count >= 20000 then
            -- Here I wanna subtract the faction's money when it more than 20000.
            scripting.game_interface:losing_money(current_faction, 3000);    
        end 
    end 
    scripting.AddEventCallBack("FactionTurnStart", SubtractMoney)
    I've tried to written this but it didn't work.


    And the set_tax_disabled function doesn't work either.
    Code:
    local function SubtractMoney(context) 
    local current_faction = context.string;
      local treasury_count = context:faction():treasury();
        if treasury_count >= 20000 then
            scripting.game_interface:set_tax_disabled(current_faction);
        end 
    end 
    scripting.AddEventCallBack("FactionTurnStart", SubtractMoney)

    Is there a way to subtract a faction's treatury?
    Thanks in advance!

  11. #91
    Emperor Caesar's Avatar Ordinarius
    Join Date
    Nov 2009
    Location
    United States
    Posts
    756

    Default Re: [scripting] The "does this code work" - Thread

    Hey so I've replaced a number of vanilla traits with new ethnic traits for my upcoming mod. So now the Roman characters can get traits that describe them as an Illyrian-Roman or an Italo-Roman, etc. I set the chance to 100 and the value to 1 for each trait. I want every Roman general to have 1 of these traits. Below is the code I'm using at the moment, and its working for the most part. The traits work, and appear, but the code doesn't know how to limit them. So when I spawn a new general he ends up with 2-3 of them. My commanders are Iberian, Brito, and Dacian-Romans at the same time haha. The last piece of the code needed is a way stop that and ensure that the general only receives 1 of them.

    char_is_general(context:character()) and context:character():faction():name() == "emp_antony" or context:character():faction():name() == "emp_lepidus" or context:character():faction():name() == "emp_octavian" or context:character():faction():name() == "emp_pompey" and context:character():model():campaign_name("main_emperor") and context:character():number_of_traits() <1
    Avatar courtesy of Joar.

  12. #92

    Default Re: [scripting] The "does this code work" - Thread

    Quote Originally Posted by Fridericus Secundus View Post
    That's what I did, however, it still crashes:
    Spoiler Alert, click show to read: 
    Code:
    function addSqualor(context)
        if context:faction():imperium_level() <=4 and context:faction():is_human() == true then
        scripting.game_interface:apply_effect_bundle("festive_delphi", "rom_macedon", "1");
        end
    end
    scripting.AddEventCallBack("FactionTurnStart", addSqualor)

    I didn't get Mitch's logging script to work either (simply doesn't put out any results), really frustrating.
    I'm not sure if you're active anymore Fridericus but I tried your code here on both grand campaign and empire divided campaign but I cannot get it to work. So I'm just wondering if you ever got this to actually work about 9 years ago haha.

    Here is my full code so you (or someone looking at this thread) know what I did:


    -- Load libraries
    local scripting = require "lua_scripts.EpisodicScripting"
    events = require "data.lua_scripts.events"
    module(..., package.seeall)


    function addSqualor(context)
    if context:faction():imperium_level() <=2 and context:faction():is_human() == true then
    scripting.game_interface:apply_effect_bundle("3c_plague_region", "3c_marcomanni", 1);


    end
    end
    scripting.AddEventCallBack("FactionTurnStart", addSqualor)


    Anyone know why this isn't working? Maybe the log is just not compatible with empire divided, or possibly the effect bundle just doesn't work with it. Who knows lol

Page 5 of 5 FirstFirst 12345

Posting Permissions

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