Skip to content

Standard Modules

Alan edited this page May 6, 2026 · 12 revisions

Standard modules are modules available to all the bots by default. These modules either allow you to control bots' movement, manage their inventories, connect to other bots, or access some language features like instantiating arrays and dicts.

Lang Module

Language module is a standard module. Importing it is not necessary as its functions are imported by default. You can access them simply by calling them. However, if the import is necessary (if you have conflicting function names), you can import this module with import lang. Language module has the following functions:

// Checks if input string is a valid integer
is_int(input)

// Checks if input string is a valid float
is_float(input)

// Attempt to convert string into an integer
// Example: to_int("5")
to_int(input)

// Attempt to convert string into a decimal number
// Example: to_float("0.3")
to_float(input)

// Pauses the bot for the specified duration
// duration uses bot ticks as a unit of time, 1 tick equals to 0.1 seconds, 10 ticks are exactly 1 second
sleep(duration)

Bot Module

Bot module is a module that comes bundled with CodeBots and one that you will use the most often. You can import it using import bot, and it has the following functions:

// Prints the message in the chat
chat(message) // message must be a string

// Displays the message above the bot for "duration" (in seconds) amount of time
set_status(message, duration [optional]) // Duration is optional, it's 5 seconds by default

// Move the bot in the specified direction
move(direction) // direction can be: "up", "down", "forward", "back", "north", "east", "south", "west"

// Rotate the bot counter-clockwise
rotate_left()

// Rotate the bot clockwise
rotate_right()

// Get the direction the bot is facing
get_direction() // returns "north", "east", "south" or "west"

// Returns a type of the block in the direction relative to the bot
// For example, get_block("down") will return "pumpkin" if the bot is above a pumpkin
get_block(direction)

// Mine a block in the specified direction
mine(direction)

// Get selected slot number in the bot's inventory
get_selected_slot()

// Select a slot in the bot's inventory
// - specified slot must be a number between 0 and 6 (inclusive)
set_selected_slot(slot)

// Returns a name of an item in the specified slot
// - specified slot must be a number between 0 and 6 (inclusive)
get_item_in_slot(slot)

// Returns a name of an item in the bot's selected slot
get_selected_item() // i.e: "pumpkin"

Monitor Module

Monitor module is a standard module and it's used for controlling monitors. It has the following functions:

// Connects to the monitor. Bot must connect to a monitor before using its functions!
connect(monitor_id) // monitor_id is displayed on monitors

// Prints the message on the monitor
print(message) // message must be a string

// Prints the message on the monitor, and adds a new line
println(message) // message 

// Removes previous messages and only displays the specified message
set_text(message)

// Removes all text from the monitor
clear()

// Returns the hex value of the current text color
get_text_color()

// Sets the color of text. Color is only applied to text that comes after setting it.
set_text_color(color) // color is a string representing a color (i.e: "black", "#f0f0f0")

// Sets the color of text. Color is only applied to text that comes after setting it.
set_text_color_rgb(red, green, blue) // red, green and blue are numbers (0-255)

// Sets text alignment for entire display
set_text_alignment(alignment) // alignment can be "left", "center" and "right"

Redstone Module

Redstone module is a standard module and it's used for reading redstone input and signals, and controlling redstone output. It has the following functions:

// Gets redstone power value for the bots current location
get_input()

// Gets redstone signal from Redstone Transmissions located at provided coordinates
get_signal(x, y, z) // x, y and z are numbers

// Outputs redstone power at the bots current location (DOES NOT WORK YET)
set_output(power) // power is a number

Clone this wiki locally