• We are currently performing site maintenance, parts of civfanatics are currently offline, but will come back online in the coming days (this includes any time you see the message "account suspended"). For more updates please see here.

[NFP] Could I control Random Events using Lua?

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?
 
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:
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.
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...
 
Back
Top Bottom