cc.completion

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

See also

Changes

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 _G.read, completing the names of various animals.

    local completion = require "cc.completion"
    local animals = { "dog", "cat", "lion", "unicorn" }
    read(nil, nil, function(text) return completion.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

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

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

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