The ccemux
API
Along with the emu
command, CCEmuX provides an API which allows you to interact with the emulator,
providing functionality you wouldn't have under normal ComputerCraft.
If you do not want access to the emu
program or ccemux
API, one
can disable the "CCEmuX API" plugin.
# ccemux.getVersion():string
Returns the current emulator version.
# ccemux.openEmu([id: number, [props: table]]):number
Open a new emulator window. If the ID is given, a computer with the specific ID will be created, otherwise the next available ID will be used.
A table may be passed as the second argument the following (optional) properties:
width
,height
: The width/height of the new computer's terminal.scale
: The scale used by the terminal renderer. It is recommended this is an integer.
This function returns the ID of the new computer.
# ccemux.closeEmu()
Shutdown the computer and close the current emulator window.
# ccemux.openDataDir():boolean
Attempt to open CCEmuX's data directory in your file browser. This returns whether it could successfully be opened or not.
# ccemux.openConfig():boolean
Attempt to open CCEmuX's config editor. This returns whether it could successfully be opened or not. In the event of a failure, an error message should also be returned.
# ccemux.milliTime():number
Get the current time in milliseconds. This is equivalent to os.epoch("utc")
.
# ccemux.nanoTime():number
Get the current time in nanoseconds. Unlike ccemux.milliTime
, this is not related to any "real
world" time. It should only be compared with other values returned by ccemux.nanoTime
, generally to
measure how long something takes.
# ccemux.echo(message:string)
Log a message to CCEmuX's console. This may be useful when running CCEmuX on a headless server, where you still need to monitor the output of a program.
# ccemux.setClipboard(message:string)
Set the current system clipboard, allowing a string to be pasted into other applications more easily.
# ccemux.attach(side:string, peripheral:string[, options:table])
Attach a new peripheral on the given side, replacing whichever peripheral was there already. For more information about the various peripherals available, and how to interact with them see the peripheral documentation.
# ccemux.detach(side:string)
Detach whichever peripheral is on the given side.
# ccemux.screenshot(): string
Take a screenshot of the current window. This returns a filename in the emulators' screenshots folder.