Computer Core
This the main part of computer mod, is required to use another computer module
Computer is a modification for Factorio that’s all about computer programming.
It allows you to write programs using the Lua programming language.
For modders, computer adds an interface for you to add your own APIs to the operating system (see below).
You can find examples here : https://github.com/Relik77/factorio_computer_core/tree/master/examples
more examples will be added as and when ;-)
Open Computer Console
Default Shortcut: "CONTROL + Left mouse button"
You can change it's in Options > Shortcut > Mods > Computer Core
Command Line Usage
The command line simulates a basic shell
These shell commands are internally defined.
Enter help
to see this list.\
Type help apis
to see list of available APIs.\
Type help name
to find out more about the API called "name".
Some main commands :
cat <filename> ...
: concatenate files and return resultcd <dirname>
: Moving in the directory treecp <srcfile> <dstfile>
: copy a fileedit <file>
: Edit the filehelp [apis | apiname]
: Print helplabel <get|set|clear> [<label>]
: Label is a built in program for computers that will create a label for the computerls
: List directory contentsmkdir <dirname>
: Make directoriesrm <file>
: remove files or directoriesrun <file>
: Run a script filetree
: list contents of directories in a tree-like formatposition
: Return the current computer positionwaypoint
: Edit saved waypoints
Computer Label
You can add a label for any computer with label set my_label
.\
Adding a label will create a mount point for this computer and make it available to any other computer.
So you can copy files from one computer to another.
Exemple:
-- computer 1
> label set my_computer
> tree
.
├─┬ mnt
│ └── my_computer
└── my_file
> cat my_file
Hello World !
-- computer 2
> tree
.
└─┬ mnt
└── my_computer
> cp /tmp/mycomputer/my_file copied_file
> tree
.
├─┬ mnt
│ └── my_computer
└── copied_file
> cat copied_file
Hello World !
Core APIs
An API (Application Programming Interface) is a collection of code that, rather than being run directly by the user as a program, is meant to be used by other programs (your program).
Computer itself ships with a collection of APIs :
os API
: The Operating System API allows for interfacing with the Lua based Operating System itself.
Exemple:os.wait(callback, seconds)
wait a number of seconds before executing callback function.term API
: The Terminal API provides functions for writing text to the terminal. Exemple:term.write(text)
writes text to the screenlan API
: The LAN API provides functions to communicate using circuit networkwlan API
: The WLAN API provides functions to communicate using wirless networkspeaker API
: The Speaker API makes it possible to issue map alerts
More information available with help os
and help term
.
Official computer mods
- OnBoard Computer : Add a board computer to your cars and write a Lua program to give them an AI