I have a 'constants' class, which, among other things, 'statically' defines the spawnable worm types as an array:
Code: Select all
worm_sizes = {"small-worm-turret", "medium-worm-turret", "big-worm-turret"}
Code: Select all
function getWormType(dist)
local s = getCosInterpolate(dist-min_worm_dist, full_spawn_dist, #worm_sizes)
s = math.min(s, #worm_sizes-0.25)
s = s+getRandPM(0.5) --randomize worm spawns a bit
s = math.floor(s+0.5) --round
if s > 0 and s <= #worm_sizes then
return worm_sizes[s]
else
return nil
end
end
Code: Select all
if game.entity_prototypes.turret["behemoth-worm-turret"] then
table.insert(worm_sizes, "behemoth-worm-turret")
end