-
Notifications
You must be signed in to change notification settings - Fork 42
Laser setup (advanced)
This is the programming tutorial on how to setup basic and amplified lasers. This is a follow up, on the basic tutorial here. While only ComputerCraft is covered here, keep in mind that OpenComputers uses the same WarpDrive API. The only difference is about networking, which isn't the object of this tutorial, so we won't describe it here.
You need at least:
- one [Laser Camera](Laser Camera) with a few [Laser mediums](Laser medium),
- one monitor,
- a power source (RF or EU based),
- one computer (ComputerCraft or OpenComputers) per Laser or Laser Camera,
- a temporary computer to setup the Monitor (see Basic tutorial). Ideally, you would use 1 Laser Camera with a few [Laser mediums](Laser medium) and a bunch of lasers setup with lots of [Laser mediums](Laser medium).
Laser Camera is the head/output of the laser cannon. It's used to designate the target.
Any Laser or Laser Camera should have clear view to its target and at least 1 laser medium. All laser mediums shall be placed on a single line with their related Laser or Laser Camera. More laser medium provide more power and more range.
Laser frequency 1420 is reserved for scanning. Any other frequency is for attacking or boosting.
For the non-geeky, non-amplified version, check the basic setup in the related [page](Laser setup (basic)). Here's the geeky setup used by Cr0s:
Place a computer with modem next to your Laser Camera. Type this program:
modem = peripheral.wrap("right")
laser = peripheral.wrap("left")
laser.beamFrequency(1420)
laser.videoChannel(100)
-- Shoots fired count
firedCount = 0
while true do
-- pull a laser head for new target
type, x_, y_, z_, id, meta, res = laser.getScanResult()
if res ~= -1 then
firedCount = firedCount + 1
-- send serialized target info
target = textutils.serialize( { x = x_, y = y_, z = z_ } )
print("Target#" .. firedCount .. " is " .. target)
-- init main laser with target
modem.transmit(3, 1, target)
-- init boost (remove comment on next line if you use boosters)
-- modem.transmit(4, 1, "go")
end
sleep(0.05)
end
Place a monitor and set its frequency to match the Laser Camera videoChannel (100 in our case). To set its frequency, place a computer on its left and type:
lua
peripheral.wrap("right").freq(100)
(you can then break the computer afterward)
Place a laser 'head' with a few laser medium blocks and a computer (below) with a modem on its left. Type this program:
laser = peripheral.wrap("top")
laser.freq(1010)
modem = peripheral.wrap("left")
-- listening for targets
modem.open(3)
while true do
-- receive target info
local event, _, ch, _, msg, _ = os.pullEvent("modem_message")
-- is targeting channel ?
if ch == 3 then
print("Got target: " .. msg)
-- get coordinates
target = textutils.unserialize(msg)
-- calculate targeting vector
myX, myY, myZ = laser.pos()
dx = target.x - myX
dy = target.y - myY
dz = target.z - myZ
-- shoot (due to bug in older versions, you were required to use -dz here)
laser.emitBeam(dx, dy, dz)
end
sleep(0)
end
Repeat step 3 with laser boosters and a modem on channel 4 (optional) Each laser booster should be targeting the laser head to boost its charge (increasing it's destructive power). Each laser booster should have the same frequency as the laser head (otherwise it'll break it). As said earlier, each laser booster should have a clear view to the laser head. Here's an example program, remember to adjust the coordinates in emitBeam calls:
modem = peripheral.wrap("bottom")
laser1 = peripheral.wrap("top")
laser2 = peripheral.wrap("left")
laser3 = peripheral.wrap("right")
laser1.freq(1010)
laser2.freq(1010)
laser3.freq(1010)
modem.open(4)
while true do
local event, _, ch, _, _, _ = os.pullEvent("modem_message")
-- is boosting channel ?
if ch == 4 then
laser1.emitBeam( 0, 1, 4)
laser2.emitBeam( 1, 0, 4)
laser3.emitBeam(-1, 0, 4)
end
sleep(0)
end
Power all the particle boosters with your favorite energy (all blocks accept both RF & EU)
Here's an example with IndustrialCraft2 Fiber cables:
Right click the monitor:
- move your mouse around to select a target
- use left click to cycle zoom level
- press space to shoot!
- use right click to exit the monitor
A first blue laser from the targeting laser will acquire the target, then the boosting lasers will charge the head laser then the main laser will shoot.
This is a very lag-inducing example, it'll kill your server resources pretty fast (loop on sleep(0) and 3 computers per weapon).
It's strongly advised to use wired modems instead of wireless ones to have a single loop on a single computer. A wired version is notably more stable and you can't be 'hacked' by your enemy.
Home
Dependencies
Frequently Asked Questions
Changelog
Tutorials
* First ship, first jump
* Tuning Tools
* Programmable blocks
* Lasers - Basic Tutorial
* Lasers - Advanced Boosting
Exploration
* World generation
* Air in space
* Planets and Transition Planes
* Warp Jump Checklist
Atomic
* Large Hadron Collider
* Accelerator Controller
* Accelerator Control Point
* Chiller
* Electromagnet
* Particles Collider
* Particles Injector
* Void Shell
* Electromagnetic Cell
Breathing
* Breathing
* Air Canister
* Air Generator
* Air Tank
* Energy Air Shield
* Warp armor
Collection
* Laser Tree Farm
* Mining Laser
Detection
* Camera and Monitor
* Cloaking
* Radar
* Siren
* Warp Field Isolation Block
Energy
* IC2 Reactor Laser
* Subspace Capacitor
* Enantiomorphic Reactor
Movement
* Lift
* Transporter Room
* Transporter Core
* Transporter Scanner
* Transporter Containment
* Transporter Beacon
Protection
* Hull
* Force field projector
* Force field relay
* Force field upgrades
Weapons
* Lasers - Basic Tutorial
* Lasers - Advanced Boosting
LUA API
* LUA methods
- for Detection
- for Energy
- for Movement
* LUA properties
- for Energy
- for Movement
* LUA events
* LUA change logs