Tasks control

Control Module - Tasks - Stores tasks for each force.

Usage


    -- import the module from the control modules
    local Tasks = require 'modules.control.tasks' --- @dep modules.control.tasks

    -- To create a new task all you need is the name of the force you want to add the task to
    -- you can give a place to add it but this is optional
    Tasks.new_task('player')

    -- You can then update this task to what ever value that you want
    -- the task id is returned by new_task, or within an update handler
    -- if a player name is not given that it will assume '<server>'
    Tasks.update_task(task_id,'My number one task!','Cooldude2606')

    -- You can then remove the task and all data linked with it
    Tasks.remove_task(task_id)

    -- set_editing and is_editing may be used to block other or provide warnings
    -- none of this is enforced by this module and so you must do so in your own module
    Tasks.set_editing(task_id,'Cooldude2606',true)

Dependencies

expcore.store
utils.global
utils.token

Getters

get_task(task_id) Gets the task stored at this id
get_details(task_id) Gets the task details stored at this id
get_force_tasks(force_name) Gets the task ids for a force
is_editing(task_id, player_name) Gets if a player is currently editing this task

Setters

add_handler(callback) Adds a new handler for when a task is updated
new_task(force_name[, task_number][, player_name]) Adds a new task for a force, with option to place it in a certain order
remove_task(task_id) Removes a task and all data linked with it
update_task(task_id, task[, player_name='server']) Updates a task message
set_editing(task_id, player_name[, state]) Sets a player to be editing this task, used with is_editing

Dependencies

# expcore.store
# utils.global
# utils.token

Getters

# get_task(task_id)

Gets the task stored at this id

Parameters:
  • task_id : (string) the uid of the task you want to get
Returns:
  • (string) the task message that was stored here
# get_details(task_id)

Gets the task details stored at this id

Parameters:
  • task_id : (string) the uid of the task you want to get
Returns:
  • (table) the task details that was stored here
# get_force_tasks(force_name)

Gets the task ids for a force

Parameters:
  • force_name : (string) the name of the force that you want the ids for
Returns:
  • (table) an array of all the task ids
# is_editing(task_id, player_name)

Gets if a player is currently editing this task

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

Setters

# add_handler(callback)

Adds a new handler for when a task is updated

Parameters:
  • callback : (function) the callback which is ran when a task is updated
Returns:
  • (boolean) true if the callback was added
# new_task(force_name[, task_number][, player_name])

Adds a new task for a force, with option to place it in a certain order

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, adds to end if omited (optional)
  • player_name : (string) when given this player will be added to the editing list (optional)
Returns:
  • (string) the uid of the task which was created
# remove_task(task_id)

Removes a task and all data linked with it

Parameters:
  • task_id : (string) the uid of the task which you want to remove
# update_task(task_id, task[, player_name='server'])

Updates a task message

Parameters:
  • task_id : (string) the uid of the task that you want to update
  • task : (string) the message that you want to change the task to
  • player_name : (string) the name of the player who made the edit (default: 'server')
# set_editing(task_id, player_name[, state])

Sets a player to be editing this task, used with is_editing

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