Page 1 of 1

Random Spawns For Weather, Day/Night, & Lua Script Troub

Posted: Wed Apr 27, 2016 10:42 pm
by Minesae
Trying to implement some simple weather scripts on a per map basis and/or for a global script if possible.

Started working on some new weather systems and I while I would love the ability to change World WeatherOverlayparticle traits mid-game, I'm more concerned with random spawning across the map. In the case of a thunderstorm, I'm trying to spawn in lightning actors on random cells across the map, but I can't seem to figure out how to use RandomCell() properly. There are no cases of it being used in any scripts currently on the GitHub. Below is my current spawn code attempt, just yields and error of "Object reference not set to an instance of an object."

Code: Select all

Actor.Create("Lightning", true, { Owner = neutral, Location = Map.RandomCell() })
Also trying to implement a day/night cycle through a script, but quickly came across an issue, even by trying to change the value of Lighting.Ambient or any other Lighting variable, no noticeable changes to the lighting seem to occur. Tried adding GlobalLightingPaletteEffect with some default values to the World traits to see if perhaps that was an issue, but the lighting still seemed unaffected.

Are these lighting variables adjustable mid-game? I can add on new World traits to a map's script just fine, but trying to modify them through a Lua script doesn't seem possible at this time.

Posted: Thu Apr 28, 2016 2:04 am
by Norman_

Re: Random Spawns For Weather, Day/Night, & Lua Script T

Posted: Thu Apr 28, 2016 2:19 pm
by abcdefg30
Minesae wrote: Trying to implement some simple weather scripts on a per map basis and/or for a global script if possible.
Unfortunately changing the WeatherOverlay with lua is currently not possible. :\
Minesae wrote: Started working on some new weather systems and I while I would love the ability to change World WeatherOverlayparticle traits mid-game, I'm more concerned with random spawning across the map. In the case of a thunderstorm, I'm trying to spawn in lightning actors on random cells across the map, but I can't seem to figure out how to use RandomCell() properly. There are no cases of it being used in any scripts currently on the GitHub. Below is my current spawn code attempt, just yields and error of "Object reference not set to an instance of an object."

Code: Select all

Actor.Create("Lightning", true, { Owner = neutral, Location = Map.RandomCell() })
That sounds more like something else is broken than Map.RandomCell(). Are you sure that e.g. "neutral" is defined (neutral = Player.GetPlayer("Neutral") somewhere)?

Anyway, our shipped Fort Lonestar map has lighting strikes and thunder. I suggest you have a look yourself:
https://github.com/OpenRA/OpenRA/blob/b ... r.lua#L179
https://github.com/OpenRA/OpenRA/blob/b ... ml#L27-L28
Minesae wrote: Also trying to implement a day/night cycle through a script, but quickly came across an issue, even by trying to change the value of Lighting.Ambient or any other Lighting variable, no noticeable changes to the lighting seem to occur. Tried adding GlobalLightingPaletteEffect with some default values to the World traits to see if perhaps that was an issue, but the lighting still seemed unaffected.

Are these lighting variables adjustable mid-game? I can add on new World traits to a map's script just fine, but trying to modify them through a Lua script doesn't seem possible at this time.
They certainly are. You need to add the GlobalLightingPaletteEffect trait to the World actor (like here in Fort Lonestar, for example:
https://github.com/OpenRA/OpenRA/blob/b ... s.yaml#L20 ). Then you can change those by using Lighting.Ambient or Lighting.Red etc.,
so actually what you did should have worked. I suggest you post the script and the yaml rules as well if it still doesn't work.

Posted: Fri Apr 29, 2016 1:47 am
by Minesae
Norman_ wrote: check materias new maps:
These have actually been really helpful to look over, thank you!
abcdefg30 wrote: That sounds more like something else is broken than Map.RandomCell(). Are you sure that e.g. "neutral" is defined (neutral = Player.GetPlayer("Neutral") somewhere)?
That's something I noticed in Materia's scripts that I did not include, may have been the main issue. Thank you for pointing that out. I actually used Fort Lone Star already for its lighting scripts, but it just doesn't spawn a physical lightning actor, as in an Ion Storm in Tiberian Sun which is the effect I was going for, we made that just fine and actually implemented it as a crate effect too.

As for GlobalLightingPaletteEffect, yes implementing that as a World trait within the rules file of that specific map always worked fine. I should have been a little clearer on that. The issue is when you try to make a global script and edit the base World traits for the entire mod that the lighting does not seem to be modifiable. I was trying to make a day/night cycle script as a test that would affect all maps (that don't already have custom World rules defined anyway), so that I wouldn't have to implement it on every single map file we have for our mod.

Posted: Fri Apr 29, 2016 12:29 pm
by Graion Dilach
Minesae wrote: As for GlobalLightingPaletteEffect, yes implementing that as a World trait within the rules file of that specific map always worked fine. I should have been a little clearer on that. The issue is when you try to make a global script and edit the base World traits for the entire mod that the lighting does not seem to be modifiable. I was trying to make a day/night cycle script as a test that would affect all maps (that don't already have custom World rules defined anyway), so that I wouldn't have to implement it on every single map file we have for our mod.
You can list the lua/have the traits in your rules/world.yaml World actor (not ^BaseWorld!) to get it working on all the maps - however custom map lighting will probably get messed up by it. Maybe you can also have a WorldLoaded() LUA function to cache the starting custom map lighting so that the day-night script can restore map lighting after night (make it relative instead of absolute).