Front Buttons
Overview
The Front Buttons section in the cee API provides functions for interacting with and managing the physical buttons located beneath the screen of an Electric Computer in a ComputerCraft/CC:Tweaked environment.
The Electric Computer features three buttons under its screen: event, screen, and terminate, from left to right. The event button queues a cee_button event when pressed. The screen button toggles the screen power by default, but can be reconfigured using cee.setScreenButtonMode() to act as a second event button. The terminate button always terminates the running program.
Calling Conventions / Prefixes
All methods within the Front Buttons section are accessed through the global cee namespace, meaning they can be invoked directly as:
cee.setScreenButtonMode("event")
local mode = cee.getScreenButtonMode()
These functions do not require any object instantiation and operate on the current computer state. They should not be confused with methods that are part of other sections like speaker or monitor, which may have their own peripheral handles.
API Reference Table
| Signature | Arguments & Types | Description |
|---|---|---|
cee.setScreenButtonMode(mode) |
mode (string) |
Sets the screen button mode to 'screen' or 'event', until reboot. |
cee.getScreenButtonMode() |
None | Returns the current screen button mode ('screen' or 'event'). |
Lua Code Examples
Example 1: Listening for Front Button Events
print("Press the physical buttons under the screen...")
while true do
local _, name = os.pullEvent('cee_button')
if name == 'event' then
print('Event button pressed!')
elseif name == 'screen' then
print('Screen button pressed!')
elseif name == 'terminate' then
print('Terminate button triggered!')
end
end
Example 2: Configuring Screen Button Mode
-- Change the screen button to act as an event button
cee.setScreenButtonMode('event')
print("Screen button is now in event mode.")
while true do
local _, name = os.pullEvent('cee_button')
if name == 'screen' then
print('Screen button event received!')
end
end
Example 3: Querying Current Screen Button Mode
local currentMode = cee.getScreenButtonMode()
print("Current screen button mode:", currentMode)
Notes
- The event button does nothing on its own; a press queues an event for your program while the computer is on.
cee.setScreenButtonMode('event')turns the screen button into a second event button: a press queuescee_buttonwith'screen'and leaves the screen display alone.- The screen button goes back to switching the screen when the computer shuts down or reboots.
- The terminate button only ever terminates the program.