## Tasks control

Control Module - Tasks - Stores tasks for each force.

### Usage

    -- Making and then editing a new task
    local task_id = Tasks.add_task(game.player.force.name, nil, game.player.name)

    Tasks.update_task(task_id, 'We need more iron!', game.player.name)

### Dependencies

expcore.datastore
utils.global

### Getters

get_task(task_id) | Gets the task information that is linked with this id
get_force_task_ids(force_name) | Gets all the task ids that a force has
get_editing(task_id, player_name) | Gets the editing state for a player

### Setters

add_task(force_name[, player_name][, task_title][, task_body]) | Add a new task for a force, the task can be placed into a certain position for that force
remove_task(task_id) | Removes a task and any data that is linked with it
update_task(task_id, player_name, task_title, task_body) | Update the message and last edited information for a task
set_editing(task_id, player_name, state) | Set the editing state for a player, can be used as a warning or to display a text field
on_update(handler) | Adds an update handler for when a task is added, removed, or updated

### Dependencies

# expcore.datastore
# utils.global

### Getters

# get_task(task_id)

  Gets the task information that is linked with this id

  Parameters:
  - task_id : (string) the uid of the task you want to get
  Returns:
  - (table) the task information
  Usage:

      -- Getting task information outside of on_update
      local task = Tasks.get_task(task_id)

# get_force_task_ids(force_name)

  Gets all the task ids that a force has

  Parameters:
  - force_name : (string) the name of the force that you want the task ids for
  Returns:
  - (table) an array of all the task ids
  Usage:

      -- Getting the task ids for a force
      local task_ids = Tasks.get_force_task_ids(game.player.force.name)

# get_editing(task_id, player_name)

  Gets the editing state for a player

  Parameters:
  - task_id : (string) the uid of the task you want to check
  - player_name : (string) the name of the player that you want to check
  Returns:
  - (boolean) weather the player is currently editing this task
  Usage:

      -- Check if a player is editing a task or not
      local editing = Tasks.get_editing(task_id, game.player.name)

### Setters

# add_task(force_name[, player_name][, task_title][, task_body])

  Add a new task for a force, the task can be placed into a certain position for that force

  Parameters:
  - force_name : (string) the name of the force to add the task for
  - player_name : (string) the player who added this task, will cause them to be listed under editing (optional)
  - task_title : (string) the task title, if not given default is used (optional)
  - task_body : (string) the task body, if not given default is used (optional)
  Returns:
  - (string) the uid of the task which was created
  Usage:

      -- Adding a new task for your force
      local task_id = Tasks.add_task(game.player.force.name, game.player.name, nil, nil)

# remove_task(task_id)

  Removes a task and any data that is linked with it

  Parameters:
  - task_id : (string) the uid of the task which you want to remove
  Usage:

      -- Removing a task
      Tasks.remove_task(task_id)

# update_task(task_id, player_name, task_title, task_body)

  Update the message and last edited information for a task

  Parameters:
  - task_id : (string) the uid of the task to update
  - player_name : (string) the name of the player who made the edit
  - task_title : (string) the title of the task to update to
  - task_body : (string) the body of the task to update to
  Usage:

      -- Updating the message for on a task
      Task.update_task(task_id, game.player.name, 'We need more iron!', 'Build more iron outposts.')

# set_editing(task_id, player_name, state)

  Set the editing state for a player, can be used as a warning or to display a text field

  Parameters:
  - task_id : (string) the uid of the task that you want to effect
  - player_name : (string) the name of the player you want to set the state for
  - state : (boolean) the new state to set editing to
  Usage:

      -- Setting your editing state to true
      Tasks.set_editing(task_id, game.player.name, true)

# on_update(handler)

  Adds an update handler for when a task is added, removed, or updated

  Parameters:
  - handler : (function) the handler which is called when a task is updated
  Usage:

      -- Add a game print when a task is updated
      Tasks.on_update(function(task)
          game.print(task.force_name..' now has the task: '..task.message)
      end)