Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revision Previous revision
Next revision
Previous revision
tutorial:custom_oses [2014/12/24 03:02]
sangar
tutorial:custom_oses [2020/03/29 21:04] (current)
thepuzzlemaker [What's Available?] Add some undocumented functions/libraries available in OSes without compatibility libraries or OS-level libraries
Line 16: Line 16:
 What's Available? What's Available?
 ----------------- -----------------
-There are a few libraries documented on the wiki that are in fact part of OpenOS, so when you're implementing your own operation system, those won't be at your disposal. Most notably that includes the `io`, `package` and `filesystem` libraries. For a definite reference for what's available in an init script, check the kernel. The following list isn't guaranteed to be complete and/or up-to-date!+There are a few libraries documented on the wiki that are in fact part of OpenOS, so when you're implementing your own operation system, those won't be at your disposal. Most notably that includes the `io`, `package` and `filesystem` libraries. For a definite reference for what's available in an init script, check the kernel ​or [[https://​github.com/​MightyPirates/​OpenComputers/​blob/​master-MC1.12/​src/​main/​resources/​assets/​opencomputers/​lua/​machine.lua|machine.lua script for your current OpenComputers version]]. The following list isn't guaranteed to be complete and/or up-to-date!
  
 ```lua ```lua
Line 61: Line 61:
 coroutine.yield coroutine.yield
  
 +debug.getinfo
 debug.traceback debug.traceback
 +debug.getlocal
 +debug.getupvalue
  
 math.abs math.abs
Line 123: Line 126:
  
 component.doc component.doc
 +component.fields
 component.invoke component.invoke
 component.list component.list
 component.methods component.methods
 component.proxy component.proxy
 +component.slot
 component.type component.type
  
Line 134: Line 139:
 computer.energy computer.energy
 computer.freeMemory computer.freeMemory
 +computer.getArchitectures
 +computer.getArchitecture
 computer.getBootAddress computer.getBootAddress
 +computer.getDeviceInfo
 +computer.getProgramLocations
 +computer.isRobot
 computer.maxEnergy computer.maxEnergy
 computer.pullSignal computer.pullSignal
 computer.pushSignal computer.pushSignal
 computer.removeUser computer.removeUser
 +computer.setArchitecture
 computer.setBootAddress computer.setBootAddress
 computer.shutdown computer.shutdown
Line 156: Line 167:
 unicode.wlen unicode.wlen
 unicode.wtrunc unicode.wtrunc
 +
 +-- Lua 5.3 only:
 +coroutine.isyieldable
 +
 +string.pack
 +string.unpack
 +string.packsize
 +
 +table.move
 +
 +math.maxinteger
 +math.mininteger
 +math.tointeger
 +math.type
 +math.ult
 +
 +utf8.char
 +utf8.charpattern
 +utf8.codes
 +utf8.codepoint
 +utf8.len
 +utf8.offset
 +```
 +
 +Accessing components in BIOS
 +-----------------
 +Unlike in OpenOS you don't have the primary system for components in BIOS. That means you cannot just write `component.redstone.setOutput`,​ you have to manually create your proxy for the component first. For several reasons the proxy system is provided via the machine itself, so you can still use that. To get a proxy, use the `component.proxy` method. It expects the address of the component to wrap. You can either write that down manually, or get the list of components using `component.list` and go from there.
 +
 +For example, to get the first best redstone component, you can do the following:
 +```lua
 +local r = component.proxy(component.list("​redstone"​)())
 ``` ```
 +This works because `component.list` returns a Lua iterator: a function that can be called repeatedly to get the next element in whatever it iterates over, returning `nil` once there are no more elements.
  
 A few more things A few more things