Skip to content

Instantly share code, notes, and snippets.

@ennorehling
Created July 30, 2018 18:17
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ennorehling/5c78fe51196a581c2861c0f53efe11cf to your computer and use it in GitHub Desktop.
Save ennorehling/5c78fe51196a581c2861c0f53efe11cf to your computer and use it in GitHub Desktop.
Fix peasants in new player area
require 'config'
filename = get_turn() .. '.dat'
eressea.read_game(filename)
maxps = {
['plain'] = 10000,
['mountain'] = 1000,
['glacier'] = 100,
['highland'] = 4000,
['swamp'] = 2000,
['desert'] = 500,
['volcano'] = 500,
['ocean'] = 0,
['firewall'] = 0
}
function fixit(r)
maxp = maxps[r.terrain] or 500
minp = maxp / 10
if r.peasants < minp then
r.peasants = math.random(minp, maxp)
print(tostring(r) .. ', ' .. r.terrain .. ': ' .. r.peasants .. ' peasants')
end
end
function fix()
for f in factions() do
if f.age<30 then
for u in f.units do
fixit(u.region)
for _, r in ipairs(u.region.adj) do
fixit(r)
end
end
end
end
end
fix()
eressea.write_game(filename)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment