Programmable blocks - LemADEC/WarpDrive GitHub Wiki
Using Computers
Most machines include pre-loaded scripts for both ComputerCraft and OpenComputers: just place a computer next to the block to start using it. You may also connect them remotely using Wired modems or Cables.
Right click the computer to open its console.
For major machines like Ship controller, Accelerator controller, Weapon controller and Enantiomorphic reactor core, a 'startup' script will automatically boot and show a user interface.
For simpler machines, scripts are listed on the respective machine's wiki page and you need to apply a Computer Interface upgrade.
Right click a WarpDrive machine or check its tooltips to see if it requires a Computer Interface upgrade.
Wireless remote control is also possible using custom scripts.
Usage with ComputerCraft
To check the pre-loaded scripts type the following command:
ls
If you see only "rom", your computer couldn't connect to a machine: check that it's actually right next to the machine you want to interface with, or check the Networking cables are not cut and Wired modem are red/online, check that you don't need to apply a Computer Interface upgrade by right-clicking the WarpDrive block.
Installation
With ComputerCraft, you don't need to install: just connect your blocks and reboot!
Reset and terminate
You can reset the computer by holding Ctrl-R for a few seconds.
You can exit the current program by holding Ctrl-T for a few seconds.
Screen redirection
You can redirect a program to an attached ComputerCraft monitor like so:
monitor <connection side> <program to execute>
where <connection side> is the monitor position relative to the computer (top, bottom, left, right, back).
Customization
You can customize the pre-loaded scripts like so:
- connect your computer to the WarpDrive block
- boot the computer
- terminate the script by holding Ctrl-T for a few seconds
- copy the scripts file with the copy command
copy startup mystartup
- disconnect the computer from the WarpDrive block
- restart the computer by holding Ctrl-R for a few seconds
- rename the script
move mystartup startup
- change the script to your liking
- reconnect the WarpDrive block Remember to update the script when the mod as a new version out.
References
To learn more, check the mod wiki here or simply type
help
Usage with OpenComputers
To check your connection and the WarpDrive machine mount name, type the following command to see a list of connected devices:
df
You should see a line starting with "warpdrive". At the end of this line, there's the mount name "/mnt/xxx" where xxx is a set of hexadecimal digits. Change to that mount by typing the following:
cd /mnt/xxx
If you can't find a line starting with "warpdrive", your computer couldn't see a machine: check that it's actually right next to the machine you want to interface with, check that you don't need to apply a Computer Interface upgrade by right-clicking the WarpDrive block.
OpenComputers is a bit more 'old school', so you need to mount an floppy or HDD to save your configurations. You may refer to their wiki here.
Automated installation
When using OpenComputers 1.6.1 or later, you can use the install script, as such:
1- boot with an OpenOS floppy and a new HDD.
2- type install
, select OpenOS, wait a bit, reboot and remove the floppy.
3- type install
, select the machine you want, wait a bit, reboot.
4- enjoy!
For older version, you'll have to do it manually.
Reset and terminate
You can reset the computer by holding Ctrl-R for a few seconds.
You can interrupt the running program using Ctrl-C.
Customization
Once the scripts are installed, you can directly customize them to your liking.
References
To learn more, check the mod wiki here.
Programming with WarpDrive
All WarpDrive machines comes with a LUA API to program them using ComputerCraft or OpenComputers. Use it to unlock the full potential of your setup or build a command center.
Pre-loaded scripts are a good way to get started. You can read them in-game or directly check them on repository for both ComputerCraft and OpenComputers.
To boot with your own startup script, create it before connecting the computer to a WarpDrive machine.
Tips and tricks
When writing LUA code, remember to use the interactive console to test code snippets. From this console, you can print variables and function call return values with print() or = (only with OpenComputers), like so:
lua
x = 3.14159
x -- works only with ComputerCraft
print(x) -- works with ComputerCraft and OpenComputers
=x -- works only with OpenComputers
LUA doesn't natively support printing objects like arrays.
With ComputerCraft you can use the rPrint method, like so:
lua
function rPrint(s, l, i) l = (l) or 100; i = i or ""; if (l<1) then print "ERROR: Item limit reached."; return l-1 end; local ts = type(s); if (ts ~= "table") then print (i,ts,s); return l-1 end print (i,ts); for k,v in pairs(s) do l = rPrint(v, l, i.."\t["..tostring(k).."]"); if (l < 0) then break end end return l; end
x = {1, 2, 3, {a=5, b=6}}
rPrint(x)
With OpenComputers you can use the inspect method, like so:
lua
local inspect = require("inspect")
x = {1, 2, 3, {a=5, b=6}}
=x
=inspect(x)
print(inspect(x))