EDIT: I think I got it, go to the end.
OK, I could use a bit of help, if possible.
I've expanded the planet issues for labs, so that it accounts for both Orthin liking labs, and Scavengers being afraid of them. That works fine.
I've added an event, using copy and paste, so that both Lummox and Gaiad like farms.
Code: Select all
function RacePlanetIssues.labs(empire,race,planet)
if remove_race_suffix(race)=='orthin' and (planet.labs>0)
local rep = race_improvement_morale_bonuses.orthin.labs * planet.labs
if planet.labs>=3
return {
..rep,
short = 'Labs(<LAB>)',
desc = [[These research facilities are excellent!]],
}
else
return {
..rep,
short = 'Labs(<LAB>)',
desc = [[The local research facilities are acceptable.]],
}
end
end
if remove_race_suffix(race)=='scavenger' and (planet.labs>0)
local rep = race_improvement_morale_bonuses.scavenger.labs * planet.labs
if planet.labs>=3
return {
..rep,
short = 'Labs(<LAB>)',
desc = [[You, too, will bring death here!]],
}
else
return {
..rep,
short = 'Labs(<LAB>)',
desc = [[We are not sure you can control this magic. The ones before could not.]],
}
end
end
end
function RacePlanetIssues.farms(empire,race,planet)
if remove_race_suffix(race)=='lummox' and (planet.farms>0)
local rep = race_improvement_morale_bonuses.lummox.farms * planet.farms
if planet.farms>=4
return {
..rep,
short = 'Farms (<FARM>)',
desc = [[Our children may never know starvation.]],
}
else
return {
..rep,
short = 'Farms (<FARM>)',
desc = [[We don't have to compete with predators for food now?]],
}
end
end
if remove_race_suffix(race)=='gaiad' and (planet.farms>0)
local rep = race_improvement_morale_bonuses.gaiad.farms * planet.farms
if planet.farms>=4
return {
..rep,
short = 'Farms (<FARM>)',
desc = [[Sustain Forest, and Forest will sustain you.]],
}
else
return {
..rep,
short = 'Farms (<FARM>)',
desc = [[Not ideal, but you are trying to enrich the land. Thank you.]],
}
end
end
end
If I remove the IF clause for the Gaiad, all seems to be well. When the clause is there, going to a planet with Gaiad produces this error:
Code: Select all
Mods\Lua state\Galaxy\RaceIssues.lua:289: attempt to perform arithmetic on field 'farms' (a nil value)
Mods\Lua state\Galaxy\RaceIssues.lua:289:issue_fun:
Mods\Lua state\Galaxy\pop_morale.lua:136:
Mods\Lua state\Galaxy\pop_morale.lua:122:calc_morale_issues:
Mods\Lua state\Galaxy\pop_morale.lua:159:calc_race_morale:
Lua state\Galaxy\apply_morale_effects.lua:327:calc_rebel_defender_power
Lua state\debuggee\debugtest.lua:70: looks like visual studio isn't setup to receive file open hints.
Lua state\debuggee\debugtest.lua:70:meta_debug_file_and_line:
Lua state\@@util\~exception_callbacks.lua:31:
Lua state\GUI\@EventDispatcher.lua:287:~exception_callbacks.lua:43:
Lua state\GUI\~GalaxyMap\GalaxyMap.lua:707:
Lua state\GUI\new_screen_layout.lua:94
Now, I've actually done a bit of troubleshooting.
If I remove the if clause for the Gaiad, everything works.
If I take the working file, Lummox and not Gaiad, and change the text "lummox" to "gaiad" so it's using the same IF clause, I get the same crash.
It is not the fact that two races are in the same function. I have Scavengers and Orthin on the same planet getting science lab modifications. (Editing universe for testing, so things are odd.) I also have Humans and Tacheed Tacheed both getting City Planning bonus on the same planet, using the same function.
It is also not the Unruly trait, unless it only affects positive events.
I'm using Pell as a testing ground, and the population is currently:
pell = 8.7795509999999996609,
haduir = 3.3105919999999993131,
phidi = 3.8954380000000004003,
teros = 4.0167309999999973869,
orthin = 2.7801499999999998991,
algorian = 1,
lummox = 1,
gaiad = 1,
None of those are my races, so it should not be an issue with one of mine not being able to fight, but I don't know why there would be conflict. I do have a slightly modded pop_morale.lua file, but that section of the file was not touched. I have only added my races to the section near the top that indicates what races can become "unhappy".
To my technically ignorant view, it really looks as if the Gaiad are not good hippies and cannot be made to like farms. How else would they get their artisanal vegan soy cheese substitute?
Any help, suggestions, or insights would be greatly appreciated. Thank you.
EDIT: It's not the Insurgent trait, I tried commenting it out.
I've also had the same issue with mines. As of now, Tzidpah get annoyed by mines on their planet, with a message that it damages their only breeding pools. I copy the same IF clause and change it to gaiad, and the game crashes as soon as I open a system with Gaiad colonists.
Also, the happiness effect from mines is a negative and farms is a positive, but both fail.
EDIT 2: So, it looks as if you can only assign one suffix in race_improvement_morale_bonuses in RaceIssues.Lua. The last one sticks, if I am reading my successes and failures correctly.
If I am correct, that means the races get one modifier, good or bad.
That's a bit disappointing, but I guess I will have to scale back my plans and be very selective. It can still make things interesting, though.