I use "game.player" a few places in my Mod.
The attached mod has not yet been released. It's also here on GitHub
In "Natural_Evolution_Expansion_5.0.0" it is used in the below code:
If the player has build a Rocket Silo, I have the biters attack them by using: (so "game.player" is used twice here)
Code: Select all
if global.RocketSiloBuilt > 0 then
---- Attack the player, since you have a silo built
game.player.surface.set_multi_command({type=defines.command.attack,target=game.player.character,distraction=defines.distraction.by_enemy},Enemy_Count)
end
Code: Select all
game.player.print("WARNING!")
In "Natural_Evolution_Enemies_5.0.0" it is used in the below code: (so "game.player" is used twice here)
If the player kills a spawner, I have the nearby enemies attack him:
Code: Select all
if event.entity.type == "unit-spawner" then
game.player.surface.set_multi_command({type=defines.command.attack,target=game.player.character,distraction=defines.distraction.by_enemy},(20+math.floor(game.evolution_factor*100)))
end
I'm not sure if the same goes for "game.players"
In "Natural_Evolution_Buildings_5.0.0" it is used in the below code:
Code: Select all
game.on_event(defines.events.on_tick, function(event)
-- Evolution_MOD
if event.tick % update_com_count == 0 then
for index, player in ipairs(game.players) do
if player.character then
UpdateUnitsCommands(index)
end
end
end
end)