cc.completion

A collection of helper methods for working with input completion, such as that require by read.

See also

choice(text, choices[, add_space])Complete from a choice of one or more strings.
peripheral(text[, add_space])Complete the name of a currently attached peripheral.
side(text[, add_space])Complete the side of a computer.
setting(text[, add_space])Complete a setting.
command(text[, add_space])Complete the name of a Minecraft command.
choice(text, choices[, add_space])Source

Complete from a choice of one or more strings.

Parameters

  1. text string The input string to complete.
  2. choices { string... } The list of choices to complete from.
  3. add_space? boolean Whether to add a space after the completed item.

Returns

  1. { string... } A list of suffixes of matching strings.

Usage

  • Call read, completing the names of various animals.

    local animals = { "dog", "cat", "lion", "unicorn" }
    read(nil, nil, function(text) return choice(text, animals) end)
peripheral(text[, add_space])Source

Complete the name of a currently attached peripheral.

Parameters

  1. text string The input string to complete.
  2. add_space? boolean Whether to add a space after the completed name.

Returns

  1. { string... } A list of suffixes of matching peripherals.

Usage

  • read(nil, nil, peripheral)
side(text[, add_space])Source

Complete the side of a computer.

Parameters

  1. text string The input string to complete.
  2. add_space? boolean Whether to add a space after the completed side.

Returns

  1. { string... } A list of suffixes of matching sides.

Usage

  • read(nil, nil, side)
setting(text[, add_space])Source

Complete a setting.

Parameters

  1. text string The input string to complete.
  2. add_space? boolean Whether to add a space after the completed settings.

Returns

  1. { string... } A list of suffixes of matching settings.

Usage

  • read(nil, nil, setting)
command(text[, add_space])Source

Complete the name of a Minecraft command.

Parameters

  1. text string The input string to complete.
  2. add_space? boolean Whether to add a space after the completed command.

Returns

  1. { string... } A list of suffixes of matching commands.

Usage

  • read(nil, nil, command)