Warps control

Control Module - Warps - Stores warps for each force.

Usage


    -- import the module from the control modules
    local Warps = require 'modules.control.warps' --- @dep modules.control.warps

    -- Adding a warp require a force, surface and postion, and the option to set this as the spawn
    -- this function will also create the warp area unless set other wise
    Warps.new_warp('player',surface,{x=0,y=0})

    -- You can then update the warp information, name and icon, with the update function
    Warps.update_warp(warp_id,'Best Warp','iron-plate')

    -- Removeing a warp will restore the land that as under it, and remove any data linked with it
    Warps.remove_warp(warp_id)

    -- You can get the deatils for a warp which include last edit and postion
    Warps.get_details(warp_id)

    -- You can teleport a player to a warp, note that there is no limit on this action
    Warps.teleport_player(warp_id,player)

Dependencies

expcore.store
utils.global
utils.token
config.warps
expcore.common

Getters

get_warp_name(warp_id) Gets the name of a warp
get_warp_icon(warp_id) Gets the icon of a warp
get_details(warp_id) Gets the task details stored at this id
get_warps(force_name) Gets all warps for a force
get_all_warps() Gets all warps from all forces
is_editing(warp_id, player_name) Gets if a player is currently editing this warp
teleport_player(warp_id, player) Teleports a player to a warp point

Setters

add_handler(callback) Adds a new handler for when a warp is updated
set_editing(warp_id, player_name[, state]) Sets a player to be editing this warp, used with is_editing
update_warp(warp_id, name, icon[, player_name='server']) Updates a warp to a differecnt name and icon, both must be given

Generators

make_chart_tag(warp_id) Adds or updates the chart tag for a warp
new_warp(force_name, surface, position[, player_name='server'][, warp_name='New warp'][, block_generation=false][, set_spawn=false]) Adds a new warp to a force and makes the in game warp area
remove_warp(warp_id) Removes a warp and clears the area where it was added

Dependencies

# expcore.store
# utils.global
# utils.token
# config.warps
# expcore.common

Getters

# get_warp_name(warp_id)

Gets the name of a warp

Parameters:
  • warp_id : (string) the uid of the warp you want to get
Returns:
  • (string) the warp name that was stored here
# get_warp_icon(warp_id)

Gets the icon of a warp

Parameters:
  • warp_id : (string) the uid of the warp you want to get
Returns:
  • (string) the warp icon that was stored here
# get_details(warp_id)

Gets the task details stored at this id

Parameters:
  • warp_id : (string) the uid of the warp you want to get
Returns:
  • (table) the warp details that was stored here
# get_warps(force_name)

Gets all warps for a force

Parameters:
  • force_name : (string) the name of the force to get the warps for
Returns:
  • (table) an array of warp ids that belong to this force, spawn key is included
# get_all_warps()

Gets all warps from all forces

Returns:
  • (table) array of all warp details
# is_editing(warp_id, player_name)

Gets if a player is currently editing this warp

Parameters:
  • warp_id : (string) the uid of the warp 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 warp
# teleport_player(warp_id, player)

Teleports a player to a warp point

Parameters:
  • warp_id : (string) the uid of the warp to send the player to
  • player : (LuaPlayer) the player to teleport to the warp

Setters

# add_handler(callback)

Adds a new handler for when a warp is updated

Parameters:
  • callback : (function) the callback which is ran when a warp is updated
Returns:
  • (boolean) true if the callback was added
# set_editing(warp_id, player_name[, state])

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

Parameters:
  • warp_id : (string) the uid of the warp 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)
# update_warp(warp_id, name, icon[, player_name='server'])

Updates a warp to a differecnt name and icon, both must be given

Parameters:
  • warp_id : (string) the uid of the warp that you want to update
  • name : (string) the name that you want the warp to have
  • icon : (string) the new icon that you want the warp to have
  • player_name : (string) the name of the player that is updating the warp (default: 'server')

Generators

# make_chart_tag(warp_id)

Adds or updates the chart tag for a warp

Parameters:
  • warp_id : (string) the uid of the warp you want to make the chart tag for
Returns:
  • (boolean) true if a new tag was made, false if it was updated
# new_warp(force_name, surface, position[, player_name='server'][, warp_name='New warp'][, block_generation=false][, set_spawn=false])

Adds a new warp to a force and makes the in game warp area

Parameters:
  • force_name : (string) the name of the force to add a new warp for
  • surface : (LuaSurface) the surface to add the warp to
  • position : (Position) the postion to have the warp go to
  • player_name : (string) the name of the player who added this warp (default: 'server')
  • warp_name : (string) the name of the warp that will be made (default: 'New warp')
  • block_generation : (boolean) when true a in game area will not be made (default: false)
  • set_spawn : (boolean) when true this warp will become the spawn for the force (default: false)
# remove_warp(warp_id)

Removes a warp and clears the area where it was added

Parameters:
  • warp_id : (string) the uid of the warp that you want to remove