
lwcomputers.version ()
	Returns the lwcomputers version as a string. eg. "0.1.21".



lwcomputers.key_code (key)
	Returns the number key code for the given key. If key is invalid the
	return value is nil. Valid key values are:
		"KEY_BACKSPACE"
		"KEY_TAB"
		"KEY_LINE"
		"KEY_ENTER"
		"KEY_ESCAPE"
		"KEY_SPACE"
		"KEY_EXCLAIM"
		"KEY_QUOTE"
		"KEY_HASH"
		"KEY_CURRENCY"
		"KEY_PERCENT"
		"KEY_AMP"
		"KEY_APOSTROPHE"
		"KEY_OPENPAREN"
		"KEY_CLOSEPAREN"
		"KEY_MULTIPLY"
		"KEY_ADD"
		"KEY_COMMA"
		"KEY_SUBTRACT"
		"KEY_DOT"
		"KEY_DIVIDE"
		"KEY_0"
		"KEY_1"
		"KEY_2"
		"KEY_3"
		"KEY_4"
		"KEY_5"
		"KEY_6"
		"KEY_7"
		"KEY_8"
		"KEY_9"
		"KEY_COLON"
		"KEY_SEMICOLON"
		"KEY_LESS"
		"KEY_EQUAL"
		"KEY_GREATER"
		"KEY_QUESTION"
		"KEY_AT"
		"KEY_A"
		"KEY_B"
		"KEY_C"
		"KEY_D"
		"KEY_E"
		"KEY_F"
		"KEY_G"
		"KEY_H"
		"KEY_I"
		"KEY_J"
		"KEY_K"
		"KEY_L"
		"KEY_M"
		"KEY_N"
		"KEY_O"
		"KEY_P"
		"KEY_Q"
		"KEY_R"
		"KEY_S"
		"KEY_T"
		"KEY_U"
		"KEY_V"
		"KEY_W"
		"KEY_X"
		"KEY_Y"
		"KEY_Z"
		"KEY_OPENSQUARE"
		"KEY_SLASH"
		"KEY_CLOSESQUARE"
		"KEY_CARET"
		"KEY_UNDERSCORE"
		"KEY_TICK"
		"KEY_OPENBRACE"
		"KEY_BAR"
		"KEY_CLOSEBRACE"
		"KEY_TILDE"
		"KEY_DELETE"
		"KEY_INSERT"
		"KEY_HOME"
		"KEY_END"
		"KEY_PAGEUP"
		"KEY_PAGEDOWN"
		"KEY_SHIFT"
		"KEY_CAPS"
		"KEY_CTRL"
		"KEY_ALT"
		"KEY_UP"
		"KEY_DOWN"
		"KEY_LEFT"
		"KEY_RIGHT"
		"KEY_F1"
		"KEY_F2"
		"KEY_F3"
		"KEY_F4"
		"KEY_F5"
		"KEY_F6"
		"KEY_F7"
		"KEY_F8"
		"KEY_F9"
		"KEY_F10"
		"KEY_F11"
		"KEY_F12"



lwcomputers.color (color)
	Returns the number color code for the given color. If color is invalid
	the return value is nil. Valid color values are:
		"black"
		"orange"
		"magenta"
		"sky"
		"yellow"
		"pink"
		"cyan"
		"gray"
		"silver"
		"red"
		"green"
		"blue"
		"brown"
		"lime"
		"purple"
		"white"



lwcomputers.register_place_substitute (item, substitute)
	Adds a robot place substitution for robot.place_<side> functions. The
	item is removed from the robot's storage but the substitute is placed.
	Returns true if successfully added to the list, false if not.
	item: string name of the item to substitute.
	substitute: this can be a string value or a table with one indexed string
	of the default substitute item. This table can optionally contain key
	values of strings for each direction. Recognised keys are "up", "down",
	"left", "right", "front", "back".
	*	If the item already exits in the list the call is ignored and false
		is returned.

	eg:
	if lwcomputers.register_place_substitute ("farming:seed_wheat", "farming:wheat_1") then
	end

	local torch = { "default:torch_wall", down = "default:torch", up = "default:torch_ceiling" }
	if lwcomputers.register_place_substitute ("default:torch", torch) then
	end



lwcomputers.register_crafting_mods (item, adds, removes)
	Adds a crafting modification for the robot.craft function. The adds
	items are added to the robot's storage on crafting and the removes are
	removed. These actions are in additional to the crafting recipe.
	Returns true if successfully added to the list, false if not.
	item: string name of the item to substitute, eg. "farming:seed_wheat".
	adds: the string name of the item to add, or an indexed table of multiple
		item names.
	removes: the string name of the item to remove, or an indexed table of
		multiple item names.
	*	If the item already exits in the list the call is ignored and false
		is returned.
	*	The removed items are not checked for before crafting, and result in
		no error if they can't be removed.

	eg:
	if lwcomputers.register_crafting_mods ("farming:pineapple_ring", "farming:pineapple_top", nil) then
	end



lwcomputers.register_floppy_disk (name, label, itemdef)
	Registers a craftitem as a floppy disk type item, that can be inserted
	into a computer's slot and given a files system. Returns true if
	successfully registered, false if not.
	name: string name of the item.
	label: string initial label for the disk. This can be nil.
	itemdef: craftitem definition, as passed to minetest.register_craftitem.
		The definition can contain an extra field named diskfiles. This must
		be an indexed list of files to create on the disk when initialised.
		The indexed list has a series of, or one, nested tables. Each
		one defines one file on the disk. Each has two keys: source whose
		value is the full path to the file containing the contents of the
		file; and target whose value is the full path on disk for the file.
		This field can be nil, for no files.
	*	If the item already exits in the list the call is ignored and false
		is returned.
	*	After being placed in a computer's slot the item's metadata will have
		two field which can be queried: "lwcomputer_id" with the unique integer
		id of the item; and "label" which contains the currently set label
		string. If not using disk metadata, a folder will be created under
		the lwcomputers folder in the world save folder for the disk, named
		floppy_<id>. The byte size and disk items restrictions from the mod's
		floppy disk settings will be applied.
	*	The on_drop handler is set, overriding if present.

	eg:
	local result = lwcomputers.register_floppy_disk ("mymod:usb", "usb_label", {
		description = S("USB"),
		short_description = S("USB"),
		inventory_image = "usb.png",
		diskfiles =
		{
			{
				source = minetest.get_modpath ("mymod").."/files/usb_file_1",
				target = "/boot"
			},
			{
				source = minetest.get_modpath ("mymod").."/files/usb_file_2",
				target = "/progs/myprog"
			}
		}
	})



lwcomputers.register_clipboard (name, size, itemdef)
	Registers a craftitem as a clipboard type item, that can be inserted
	into a computer's slot and pass data between itself and the computer.
	Returns true if successfully registered, false if not.
	name: string name of the item.
	size: the maximum byte size of the contents. This value will be trimmed
		to the 'Maximum clipboard content length' lwcomputer's mod setting.
		This field can be nil, in which case the mod setting will be used.
	itemdef: craftitem definition, as passed to minetest.register_craftitem.
	*	If the item already exits in the list the call is ignored and false
		is returned.
	*	The contents of the clipboard is held in a metadata string named
		"contents".
	*	The on_drop handler is set, overriding if present. The stack_max is
		set to 1.

	eg:
	local result = lwcomputers.register_clipboard ("mymod:clipboard", nil, {
		description = S("My Clipboard"),
		short_description = S("My Clipboard"),
		inventory_image = "my_clipboard_item.png",
		on_use = my_on_use_handler_to_view_contents
	})



lwcomputers.format_character (ascii, fg, bg)
	Returns a single number value for a character in the monitor's display.
	ascii: Number of the character ascii code to set (0 to 255).
	fg: Number of the foreground color for the character (0 to 15) (see
		 api_ref.txt term.colors).
	bg: Number of the background color for the character (0 to 15) (see
		 api_ref.txt term.colors).



lwcomputers.unformat_character (character)
	Returns ascii, fg, bg for the character value (reverse of
	lwcomputers.format_character).
	character: Number character value to decipher.



lwcomputers.get_monitor_interface (pos, channel)
	Returns an interface for the monitor on the given channel.
	pos: World position of the block containing the returned interface,
		  as table.
	channel: string of monitor's channel.


lwcomputers.get_multimonitor_interface (pos, width, height, ... )
	Returns an interface for multiple monitors on the given channels. The
	monitors must be arranged in a grid. The returned interface acts on
	them as a single display.
	pos: World position of the block containing the returned interface,
		  as table.
	width: Number of monitors per row in the grid.
	height: Number of monitors high in the grid.
	... : string monitor channels for each monitor in the grid, left to
			right, top to bottom.


Querying the returned interface does not query the monitor/s, but returns
an internal cache of the value. Querying before setting a value through
the interface will return an initial default.

The returned interface provides the follow. In the following the
interface name 'monitor' is a place holder for the returned interface.
Single and multi-monitor interface act the same except where stated.

monitor.channel ([index])
	For single monitor interface, returns the monitor's channel as a
	string.

	For multi-monitor interface, returns the monitor's channel as a
	string at the given index.

	index: This parameter is only used on multi-monitor interfaces. The
			 one based index of the monitor whose channel is returned. The
			 index is from left, top to right, bottom. If omitted 1 is
			 assumed.

monitor.monitors ()
	Returns the width, height of the multi-monitor grid, as passed to the
	interface function. For single monitor interface 1, 1 is returned.

monitor.update ()
	Flushes the interface's contents to the monitor/s.

monitor.set_colors (fg, bg)
	Sets the current foreground, background colors.
	If either color is nil, that color is not changed. See api_ref.txt
	term.colors.

monitor.get_colors ()
	Returns the current foreground, background colors.

monitor.set_scale (scale)
	Sets the monitor/s' display scale.
	scale: an integer between 1 to 5.
	* This call resets the cursor position to 0, 0.

monitor.get_scale ()
	Returns an integer of the monitor/s' display scale.

monitor.get_resolution ()
	Returns character width, height of the monitor/s' display. These
	values are dependant on the current scale, and possibly the number of
	monitors.

monitor.get_cursor ()
	Returns x, y of current cursor position. Note, the monitor does not
	display a cursor. This is the current write position.

monitor.set_cursor (x, y)
	Sets cursors current position. Position is clipped to monitor/s'
	resolution. Note, the monitor does not display a cursor. This is the
	current write position.

monitor.set_char (x, y, char, fg, bg, update)
	Sets the character at zero based coordinate x, y.
	char: the ascii code to set (0 to 255), or single character string.
	fg: the foreground color to set or nil for no current color.
	bg: the background color to set or nil for no current color.
	update: if not false the changes are flushed to the monitor.

monitor.get_char (x, y)
	Returns the character at zero based coordinate x, y as
	asciicode, forecolor, backcolor, or nil if x or y are out of range.

monitor.write (str, update)
	Write the string at the current cursor position. Lines wrap but terminal
	doesn't scroll. Excess is not written.
	str: the string to write.
	update: if not false the changes are flushed to the monitor.
	* Cursor position is not updated.

monitor.blit (buff, x, y, w, h)
	Blits a rectangular section to the terminal from a buffer.
	Returns true if successful, or false and an error message if not.
	buff: The buffer holding the data to write.
	x: zero based left coordinate to write to.
	y: zero based top coordinate to write to.
	w: the width of the rectangular section to write to.
	h: the height of the rectangular section to write to.
	Any section of the rectangle which is not on the screen is omitted. x
	and y can be negative.
	The buffer is an indexed table of character data from left to right, top
	to bottom in order. Each character data should be formed as:
	{ char = <asciicode>, fg = <forecolor>, bg = <backcolor> }. If any table
	cell is not a table that character is not altered (transparent).

monitor.cache (x, y, w, h)
	Returns a buffer of the character data from the terminal buffer, of the
	form used by `monitor.blit`, or nil if w * h has no size.
	x: zero based left coordinate to read from.
	y: zero based top coordinate to read from.
	w: the width of the rectangular section to read from.
	h: the height of the rectangular section to read from.
	Any section of the rectangle which is not on the screen is set to zero
	(not a table, will blit as transparent).
	x and y can be negative.

monitor.clear (char, x, y, w, h, update)
	Clears a rectangular section of the monitor's display.
	char: the ascii code to set (0 to 255), or single character string. nil
			defaults to zero.
	x: zero based left coordinate to clear, nil defaults to zero.
	y: zero based top coordinate to clear, nil defaults to zero.
	w: width of rectangular section to clear, nil defaults to monitor's right.
	h: height of rectangular section to clear, nil defaults to monitor's bottom.
	update: if not false the changes are flushed to the monitor.
	`monitor.clear ()` will clear to whole monitor to black.
	* The cursor position is not moved.

monitor.scroll (lines, x, y, w, h, update)
	Scrolls a rectangular section the given lines.
	lines: the lines to scroll, negative moves up, positive moves down.
	x: zero based left coordinate to scroll, nil defaults to zero.
	y: zero based top coordinate to scroll, nil defaults to zero.
	w: width of rectangular section to scroll, nil defaults to monitor's right.
	h: height of rectangular section to scroll, nil defaults to monitor's bottom.
	update: if not false the changes are flushed to the monitor.
	`monitor.scroll (-1)` scrolls the whole monitor up one line.
	* Lines not overwritten by the scrolling are not cleared.

monitor.print (fmt, ... )
	Writes the string to the current cursor position updating the cursor
	position. Lines wrap and the terminal scrolls if the write goes beyond
	the bottom line.
	Parameter are as for `string.format`.
	Changes are flushed to the monitor.

monitor.is_touch (channel, msg)
	Determines if a digilines message is a touch message from the
	monitor/s of this interface. If it is x, y of the touched character
	position is returned as numbers. If not nil is returned.
	channel: Channel of the digilines message. For a touch message the
				channel will be the channel of the monitor.
	msg: The digilines message.


--
