Officesessions any X rounds -LuckyNumber-

    This site uses cookies. By continuing to browse this site, you are agreeing to our Cookie Policy.

    • Officesessions any X rounds -LuckyNumber-

      [LuckyNumber]





      I thought, it would be convenient, to have a simple option to set the frequency of office sessions to happen all 3 Rounds.
      Thanks to the help of Fajeth and ThreeOfMe, I was able to take a look at the scripts and to provide you the LuckyNumbers-Snippet.
      This solution is as clean as it can get under the current circumstances.


      What it does :

      When pasted into /GameDir/Scripts/Library/WorldAmbient.lua, the snippet is ready to start, so no tinkering in the lua-scripts is needed.
      To activate the default of 3, which means there will be officesessions all 3 rounds, you have to click the "Ambient" checkbox at the top right of the InGameSetup-menu.
      This comes for a small price, you can no longer set Ambient to on or off in the ingame menu, but the snippet will set it to lowAmbient, because this is the current defined default in the /GameDir/Scripts/GameState/GameStartUp.lua. If the top-right InGameSetup-checkbox is NOT ticked the LuckyNumbers-mod-snippet is off, and the officesessions frequency is chosen by its original dropdownmenu while in InGameSetup but LowAmbientMode is still active.



      If you prefer to play with HighAmbient active and LuckyNumbers active or with any other OfficeSession frequency then 1,2,3,4, you could very simply edit the WorldAmbient.lua, therefor LuckyNumbers provides three switches at the top of the mod-snippet.


      Switch 1 is called "LuckyNumberOn", this is per default active, when you turn it off, useLowAmbient is still valid (*switch 3) but the InGame switch is out of order

      Switch 2 is called "LuckyNumber", this is were you could change the frequency of office sessions to any number you would prefer.

      Switch 3 is called "useLowAmbient", this switches HighAmbient or LowAmbient mode, regardless of the GameStartUp.lua setting for Ambient mode.


      How it works:

      After starting a new game, the LuckyNumbers-snippet triggers once, for all follow ups it just passes an "if" statement which does not perform any further changes, so the performance impact should be negelectable, anyways its just while map initialization.

      After this first pass, the LuckyNumbers-snippet will output its current state once into: GameDir/LogFile.log, just search for "LuckyNumber"

      How to install:

      1. please create a copy of your /GameDir/Scripts folder or atleast of the WorldAmbient.lua file
      2. open the WorldAmbient.lua located at /GameDir/Scripts/Library/WorldAmbient.lua
      3. Paste the whole Spoiler-Code just below:

      Lua Source Code

      1. function CheckAmbient()
      2. GetScenario("World")

      Display Spoiler

      Lua Source Code

      1. -----Start LuckyNumbers
      2. --------------------------- LuckyNumber ModMod------------------------
      3. local LuckyNumberOn = 1 -- Turn it On/Off
      4. local LuckyNumber = 3 -- Frequency of office sessions
      5. local useLowAmbient = 0 -- Set to 0 to use HighAmbient-Setting
      6. ----------------------------------------------------------------------
      7. local Options = FindNode("\\Settings\\Options")
      8. local InGameActive = Options:GetValueInt("Ambient")
      9. local FirstRun = Options:GetValueInt("AmbientNextStep")
      10. local YearsPerRound = Options:GetValueInt("YearsPerRound")
      11. local RNGEvents = Options:GetValueInt("Messages")
      12. local ambientProperty = GetProperty("World", "ambient") ---if it returns 0 then LowAmbient is active
      13. local fos = GetProperty("World","fos")
      14. if InGameActive == 1 and LuckyNumberOn == 1 and fos ~= LuckyNumber and FirstRun == 0 then
      15. SetProperty("World", "fos", LuckyNumber)
      16. Options:SetValueInt("AmbientNextStep",1)
      17. fos = LuckyNumber
      18. Options:SetValueInt("Ambient", useLowAmbient)
      19. InGameActive = Options:GetValueInt("Ambient")
      20. if useLowAmbient == 1 then
      21. SetProperty("World", "ambient", 0)
      22. ambientProperty = GetProperty("World", "ambient")
      23. else
      24. SetProperty("World", "ambient", 1)
      25. ambientProperty = GetProperty("World", "ambient")
      26. end
      27. if ambientProperty == 1 then
      28. LogMessage("LuckyNumber -1stPass- *HighAmbientMode* - useLowAmbient = "..InGameActive.." LuckyNumber = "..fos.." YearsPerRound = "..YearsPerRound.." Ambient = "..ambientProperty.." Events = "..RNGEvents)
      29. else
      30. LogMessage("LuckyNumber -1stPass- _LowAmbientMode_ - useLowAmbient = "..InGameActive.." LuckyNumber = "..fos.." YearsPerRound = "..YearsPerRound.." Ambient = "..ambientProperty.." Events = "..RNGEvents)
      31. end
      32. else
      33. if FirstRun == 0 then
      34. Options:SetValueInt("AmbientNextStep",1)
      35. Options:SetValueInt("Ambient", useLowAmbient)
      36. if useLowAmbient == 1 then
      37. SetProperty("World", "ambient", 0)
      38. ambientProperty = GetProperty("World", "ambient")
      39. else
      40. SetProperty("World", "ambient", 1)
      41. ambientProperty = GetProperty("World", "ambient")
      42. end
      43. InGameActive = Options:GetValueInt("Ambient")
      44. if ambientProperty == 1 then
      45. LogMessage("LuckyNumber -OFF- *HighAmbientMode* - useLowAmbient = "..InGameActive.." FrequencyOfficeSessions = "..fos.." YearsPerRound = "..YearsPerRound.." Ambient = "..ambientProperty.." Events = "..RNGEvents)
      46. else
      47. LogMessage("LuckyNumber -OFF- _LowAmbientMode_ - useLowAmbient = "..InGameActive.." FrequencyOfficeSessions = "..fos.." YearsPerRound = "..YearsPerRound.." Ambient = "..ambientProperty.." Events = "..RNGEvents)
      48. end
      49. end
      50. --LogMessage("DEBUG LuckyNumber -OFF- useLowAmbient = "..InGameActive.." FrequencyOfficeSessions = "..fos.." YearsPerRound = "..YearsPerRound.." Ambient = "..ambientProperty.." Events = "..RNGEvents)
      51. end
      52. --- end of LuckyNumber
      Display All


      Technically, this is all you need, IF you want to also change the description text and tooltip text, then you could edit Text.dbt located at /GameDir/DB/ folder

      Entry 2836 and 2837 are related to the Tooltip- and Description-Text for the top right InGameSetup-Ambient Checkbox.

      As an example, for german language you could use:

      Display Spoiler


      Source Code

      1. 2836 "_SCENARIO_OPTIONS_AMBIENT_+0" "Hier könnt Ihr entscheiden, ob alle 3 Runden Amtswahlen einberufen werden. Wenn Aktiv werden alle 3 Runden Amtsratssitzungen durchgeführt, ungeachtet des gewählten Wertes im Dropdownmenu-Amtswahlen! " |
      2. 2837 "_SCENARIO_OPTIONS_AMBIENT_DESC_+0" "3 Runden je Amtswahl" |


      I also provide a download link for a zip-file that could be extracted to /GameDir, for easy installation, but be aware, for those that are too lazy to change the script as described above and using the zip-file, there will be a nasty little secret :P
      For now the zip-variant is just for german installments of the game, I will add an english version a bit later.

      German-Version-Zip-Download:

      LuckyNumbers-GerText.zip


      Compatibility: unmodded Game Vers. 4.21 and Fajeths MegaMod Vers. 0.95

      -- start of a new game is required, after ANY change in the lua-files



      Edit: moved the whole snippet, to hook at WorldAmbient.lua

      The post was edited 21 times, last by barra ().

    • Edit:
      If someone had already followed the install instructions before 1st Nov. 2020, please REDO , Im really sorry for the inconvenience.

      Had to re-wrote some parts of the topic description

      Had to move the snippet, to hook to /GameDir/Scripts/Library/WorldAmbient.lua

      because when hooked to OfficeSessions.lua the world was already initialized allowing no further changes in terms of turning on or off ambient graphics.

      Because of lazy sunday I heavy tested all the circumstances on/off switches, now it should work as promised :)

      The post was edited 2 times, last by barra ().