This API mainly provides information about the computer a Lua state is running on, such as its address and uptime. It also contains functions for user management. This could belong to the os table, but in order to keep that “clean” it's in its own API.
computer.tmpAddress(): stringcomputer.freeMemory(): numbercomputer.totalMemory(): numbercomputer.energy(): numbercomputer.maxEnergy(): numbercomputer.uptime(): numbercomputer.shutdown([reboot: boolean])reboot is true, i.e. shuts down, then starts it again automatically. This function never returns.
This example will reboot the computer if it has been running for at least 300 seconds(5 minutes)local computer = require("computer") if computer.uptime() >= 300 then computer.shutdown(true) end
computer.getBootAddress():stringcomputer.setBootAddress([address:string])computer.runlevel(): string|number
Returns the current runlevel the computer is in. Current Runlevels in OpenOS are:
S: Single-User mode, no components or filesystems initialized yet1: Single-User mode, filesystems and components initialized - OpenOS finished bootingcomputer.users(): string, ...table.pack on it, first.
Please see the user rights documentation.computer.addUser(name: string): boolean or nil, stringtrue if the user was successfully added. Returns nil and an error message otherwise.useradd USER is a command line option to invoke this method.computer.removeUser(name: string): booleantrue if the user was removed, false if they weren't registered in the first place.userdel USER is a command line option to invoke this method.computer.pushSignal(name: string[, ...])computer.pullSignal([timeout: number]): name, ...nil. If no timeout is specified waits forever.pushSignal, for example. These vary based on the event type.
Generally it is more convenient to use event.pull from the event library. The return value is the very same, but the event library provides some more options.
computer.beep([frequency:string or number[, duration: number])
if frequency is a number it value must be between 20 and 2000.
Causes the computer to produce a beep sound at frequency Hz for duration seconds. This method is overloaded taking a single string parameter as a pattern of dots . and dashes - for short and long beeps respectively.
computer.getDeviceInfo(): table
Returns a table of information about installed devices in the computer.
Every api from computer component.
computer.getBootAddress():string|nil
filesystem that used to start OS. Interesting fact, function can return nil if OS running at standard Floppy Disk in external Disk Drive, if you don't need crash of your OS at external Floppy, use this hook from LuaNT 4.0 Scroll down for hook. This only for other OS's that have own init.lua, in 1.8.9a, this function realised in EEPROM (Lua BIOS).
computer.setBootAddress(address:string)
bios.lua in EEPROM, removing of EEPROM, make this function with get variant don't make anything.
computer.getArchitecture():string
computer.setArchitecture(arch:string)
computer.getArchitectures():table
{"Lua 5.2", "Lua 5.3"}
computer.getProgramLocations():table
table, in result we have 17 tables in table, every table of 17 is possible 1:filename, 2:loot_disk_id, scroll down to see dump.Other methods for component same that in API
Hook from LuaNT to load from external floppy:
local orig = computer.getBootAddress function computer.getBootAddress() if orig()==nil then if _G.CachedBootAddress~=nil then return _G.CachedBootAddress end return component.proxy(component.disk_drive.media()) else return orig() end end _G.CachedBootAddress =computer.getBootAddress() -- don't crash OS if EEPROM removed from computer
Dump of Program Locations:
[1970-01-25 02:14:16] 1:table: 00000000261fb260 [1970-01-25 02:14:16] 1:dig [1970-01-25 02:14:20] 2:dig [1970-01-25 02:14:20] 2:table: 00000000261fa460 [1970-01-25 02:14:24] 1:oppm [1970-01-25 02:14:24] 2:oppm [1970-01-25 02:14:27] 3:table: 00000000261fa7a0 [1970-01-25 02:14:27] 1:md5sum [1970-01-25 02:14:31] 2:data [1970-01-25 02:14:31] 4:table: 00000000261faf60 [1970-01-25 02:14:34] 1:maze [1970-01-25 02:14:34] 2:maze [1970-01-25 02:14:38] 5:table: 00000000261faea0 [1970-01-25 02:14:38] 1:sha256sum [1970-01-25 02:14:42] 2:data [1970-01-25 02:14:42] 6:table: 00000000261fabe0 [1970-01-25 02:14:45] 1:irc [1970-01-25 02:14:45] 2:irc [1970-01-25 02:14:49] 7:table: 00000000261fac20 [1970-01-25 02:14:49] 1:deflate [1970-01-25 02:14:52] 2:data [1970-01-25 02:14:52] 8:table: 00000000261face0 [1970-01-25 02:14:56] 1:gpg [1970-01-25 02:14:56] 2:data [1970-01-25 02:15:00] 9:table: 00000000261faee0 [1970-01-25 02:15:00] 1:ifconfig [1970-01-25 02:15:03] 2:network [1970-01-25 02:15:03] 10:table: 00000000261fa4a0 [1970-01-25 02:15:07] 1:ping [1970-01-25 02:15:07] 2:network [1970-01-25 02:15:10] 11:table: 00000000261fa820 [1970-01-25 02:15:10] 1:base64 [1970-01-25 02:15:14] 2:data [1970-01-25 02:15:14] 12:table: 00000000261fac60 [1970-01-25 02:15:18] 1:route [1970-01-25 02:15:18] 2:network [1970-01-25 02:15:21] 13:table: 00000000261fa8e0 [1970-01-25 02:15:21] 1:inflate [1970-01-25 02:15:25] 2:data [1970-01-25 02:15:25] 14:table: 00000000261fa920 [1970-01-25 02:15:28] 1:arp [1970-01-25 02:15:28] 2:network [1970-01-25 02:15:32] 15:table: 00000000261fa960 [1970-01-25 02:15:32] 1:opl-flash [1970-01-25 02:15:36] 2:openloader [1970-01-25 02:15:36] 16:table: 00000000261fafa0 [1970-01-25 02:15:39] 1:build [1970-01-25 02:15:39] 2:builder [1970-01-25 02:15:43] 17:table: 00000000261fa4e0 [1970-01-25 02:15:43] 1:refuel [1970-01-25 02:15:46] 2:generator