Skip to content

Modifying CONSULT

Sammy edited this page Aug 15, 2022 · 5 revisions

This section is about how to modify or add content to CONSULT.

Widgets

Widgets are small icons that sit in the upper right corner. They can be clicked on or a defined key can be used to perform an action. To create one, you only need to add the following table in 'tWidgets' under the to be displayed string:

[":)"] = {
	["name"]      = "send happy message",
	["color"]     = term.isColor() and colors.purple or colors.white,
	["func"]      = function()
		local side = "top"
		rednet.open(side)
		rednet.send(1337, "You are great!")
		rednet.close(side)
	end,
	["shortcut"] = cosuConf.tKeyboard.sendRednetMessage
}

Lets go through it step by step:

  • Although "name" is defined, it is currently not really used by CONSULT. But it can be usefull to identify your widget, if you want it to modify during runtime somehow.
  • The given function under "func", cannot accept arguments. It will be executed by CONSULT, if it gets clicked or the key gets pressed.
  • "color" is the color for the widget. It is important that you keep the given color in shades of grey for non-advanced PCs! Otherwise, whose will crash! (In the example we use a conditional type based value to pretend this.)
  • "shortcut" uses a value from the keys API. But here, because we want the end user be able to customize the key, a diversion is made via cosuConf.tKeyboard.
Clone this wiki locally