Computer Core

by Relik77

Computer is a modification for Factorio that’s all about computer programming. It allows you to write programs using the Lua programming language.

Utilities
6 years ago
0.15 - 0.16
25
Owner:
Relik77
Source:
https://github.com/Relik77/factorio_c...
Homepage:
N/A
License:
MIT
Created:
7 years ago
Latest Version:
1.3.12 (6 years ago)
Factorio version:
0.15 - 0.16
Downloaded by:
25 users

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 result
  • cd <dirname> : Moving in the directory tree
  • cp <srcfile> <dstfile> : copy a file
  • edit <file> : Edit the file
  • help [apis | apiname] : Print help
  • label <get|set|clear> [<label>] : Label is a built in program for computers that will create a label for the computer
  • ls : List directory contents
  • mkdir <dirname> : Make directories
  • rm <file> : remove files or directories
  • run <file> : Run a script file
  • tree : list contents of directories in a tree-like format
  • position : Return the current computer position
  • waypoint : 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 screen
  • lan API : The LAN API provides functions to communicate using circuit network
  • wlan API : The WLAN API provides functions to communicate using wirless network
  • speaker 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