Skip to content

Getting_Started

ArjanSeijs edited this page Feb 1, 2021 · 4 revisions

Getting Started

If you are not yet familiar with LUA and Open Computers check this guide first: OC Tutorial: Getting Started

Setting up

Connect an adapter to your ICBM component, and use cables to connect it to your computer case. Don't forget to also connect power to everything using your favourite power generator mod.

Example Setup

Accessing components

There are three ways of accessing the components:

By Name

local component = require("component")
local missile_launcher = component.icbm_missile_launcher
local emp_tower = component.icbm_emp_tower
local radar_staiton = component.icbm_radar_station
local cruise_launcher = component.icbm_cruise_launcher

Address

You can use the analyzer to get the address of the components

local component = require("component")
local proxy = component.proxy("xxxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx")

!! Know issue, the address of the missile launcher is not persistent arccos world reloads. This is not a issue I can fix on my end, so use one of the other methods instead!!

Searching

By searching through all the components on and checking if it is a ICBM component.

local component = require("component")
local proxy = nil

-- Possible values: 
-- "icbm_missile_launcher", 
-- "icbm_emp_tower",
-- "icbm_radar_station", 
-- "icbm_cruise_launcher"
local component_name = "icbm_missile_launcher" 

for k,v in component.list("icbm") do
  local p = component.proxy(k)
  if not (p.isICBM == nil) and p.isICBM(component_name) then
    proxy = p
  end
end

Making a defense system

A simple defense system that waits for a missile to be detected, and then launches your own missile towards it. (Be warned, the detected missile will probally be somewhere else before your missile gets there)

local component = require("component")
local radar = component.icbm_radar_station
local launcher = component.icbm_missile_launcher

while true do
  local missiles = radar.getMissiles()
  if len(missiles) > 0 then
    local missile = missiles[0]
    launcher.setDetonationHeight(missile.y)
    launcher.launch(missile.x, missile.z)
    break
  end
  os.sleep(1)
end

That is it, you are now ready to write your own programs, see the navigation links for documnentation on all the usable methods.

Navigation

Clone this wiki locally