## 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.store
utils.global
utils.token

### 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[, task_number][, player_name][, task_message]) | 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, new_message[, player_name='server']) | 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.store
# utils.global
# utils.token

### 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[, task_number][, player_name][, task_message])

  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
  - task_number : (number) the order place to add the task to, appends to end if omited (optional)
  - player_name : (string) the player who added this task, will cause them to be listed under editing (optional)
  - task_message : (string) the message that is used for this task, 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,nil,game.player.name)

# 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, new_message[, player_name='server'])

  Update the message and last edited information for a task

  Parameters:
  - task_id : (string) the uid of the task that you want to update
  - new_message : (string) the message that you want to have for the task
  - player_name : (string) the name of the player who made the edit (default: 'server')
  Usage:

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

# 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)