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
Last revision Both sides next revision
component:component_access [2016/09/04 11:00]
sjx233
component:component_access [2018/11/27 14:52]
krakodeel [Addresses]
Line 19: Line 19:
  
 Note that item components will usually keep their address even when removed from a computer. So when removing a hard drive and inserting it back in, it will have the same address as before. This is *not* the case for block components, they will always get a new address after being broken and placed again. Note that item components will usually keep their address even when removed from a computer. So when removing a hard drive and inserting it back in, it will have the same address as before. This is *not* the case for block components, they will always get a new address after being broken and placed again.
 +
 +Optionally you can filter components list like this:
 +
 +This code will add every component which name contains "​adar"​ such as computronics radar or warpDrive radar to the local radars table
 +```lua
 +local component = require("​component"​)
 +local radars = {}
 +for address, name in component.list("​adar",​ false) do
 +  table.insert(radars,​ component.proxy(address))
 +end
 +```
 +
 +This code will adds all connected warpDrive radars only to the local radars table
 +```lua
 +local component = require("​component"​)
 +local radars = {}
 +for address, name in component.list("​warpdriveRadar",​ true) do
 +  table.insert(radars,​ component.proxy(address))
 +end
 +```
  
 Primary Components Primary Components