1. We have added a Gift Upgrades feature that allows you to gift an account upgrade to another member, just in time for the holiday season. You can see the gift option when going to the Account Upgrades screen, or on any user profile screen.
    Dismiss Notice

[NFP] Could I control Random Events using Lua?

Discussion in 'Mod Creation Help' started by Lenin1870, Sep 18, 2020.

  1. Lenin1870

    Lenin1870 Chieftain

    Joined:
    Mar 16, 2013
    Messages:
    50
    제목 없음.png
    I planned to make a panel manipulating custom natural disasters, but did not find related Lua API in Modding Companion. But I think SetProperty in Game context or SetValues in GameConfiguration context may be associated with Random Events. Are there way using it, or any other way to occur Random Events?
     
  2. LeeS

    LeeS Imperator Supporter

    Joined:
    Jul 23, 2013
    Messages:
    6,935
    Location:
    Illinois, USA
    Nope. Neither SetProperty nor SetValue are for doing anything with Random Events.

    SetProperty allows adding a marker to a game object that an lua script has done "X". Whether Game:SetProperty(args) or Player:SetProperty(args) or Unit:SetProperty(args) or Plot:SetProperty(args) or City:SetProperty(args) is used, the arguments ("args") are all the same:
    1. Argument #1 is a text string that you make up to identify the property you are recording
    2. Argument #2 is a value that will be associated with the "property" you are attaching to the object
    Properties assigned in this way via an lua script have no actual direct effect on the game one way or another -- they are merely markers that the game then automatically will keep track of for us so that we can use these properties as identifiers that our code has previously done "X" and which we then want to record against an lua object so that our code does not again do "X".

    SetValue in GameConfiguration is pretty much only used by the game setup menu lua scripts to send out to the rest of the game the option picks and other settings made by the user at game set-up. So there would be a GameConfiguration.SetValue("X", "Y", etc) for the level of Random Event intensity a user selects, but in and of itself this GameConfiguration.SetValue("X", "Y", etc) does not create random events or select which ones will occur -- the game does that under the hood once it recieves the intensity value from the user's game setup selections.

    -------------------------------------

    To create Random Events from an lua script you have to pretty much do as @Infixo did in his pre-GS mod Natural Disasters where he has scripts that create and control the effects of his natural disasters -- but the game engine does not really in any way "see" these as natural disasters, they are just commands from an lua script that burn down forests or damage buildings and whatnot.
     
    Last edited: Sep 20, 2020
  3. Lenin1870

    Lenin1870 Chieftain

    Joined:
    Mar 16, 2013
    Messages:
    50
    Umm... Thanks, but my intention was not to 'create' random events from an lua. Sorry to do inaccurate description. I exactly want to "load" random events from custom SQL/XML. I made the SQL to modify existing natural disasters added in GS. However, I did not absolutely find how to load random events and it seems to be impossible. Nevertheless, I would like to hope it is possible...
     

Share This Page