function on_ai_command_completed(event) log(serpent.block(event)) if event.result == defines.behavior_result.success then local c = storage.player.character log("attack: " .. c.position.x .. "," .. c.position.y) storage.group.set_command{ type = defines.command.attack, target = c } end end function on_player_joined_game(event) local player = game.get_player(event.player_index) if not player then return end storage.player = player local surface = player.surface local position = { x = 0, y = -40 } local biter = surface.create_entity{ name = "small-biter", position = position, } local group = surface.create_unit_group{ position = position, } group.add_member(biter) storage.group = group local destination = { x = 0, y = -70 } group.set_command{ type = defines.command.go_to_location, destination = destination, radius = 0 } end script.on_event(defines.events.on_ai_command_completed, on_ai_command_completed) script.on_event(defines.events.on_player_joined_game, on_player_joined_game)