Onboard Computer

by Relik77

Add a board computer to your cars and write a Lua program to give them an AI

Content
6 years ago
0.15 - 0.16
6
Logistics

g how to use this mod?

6 years ago

Interesting idea in theory, but is there any documentation at all for this mod?

Right now I have put the computer into the vehicle's grid. I can't bring up the console for a particular vehicle. I tried getting into the vehicle and using the console but that didn't work either.

Anyway this is all I get when I use the console I found:

help car
No such api 'car' available for this device

What am I missing?

API wise, looking at the Information tab on mods.factorio.com didn't help much at all. I'd suggest a function to calculate the direction to a position.

6 years ago

Hi,

To open the console of the on-board computer, just proceed as with the main mod (Default Shortcut: CONTROL + Left mouse button).
The car api is only available on a car, so it is normal that on another device (your personal computer for example) the API is not recognized.
Lately I have basically worked to improve the main mod and I can not be part of it at the same time ^^

You can use the waypoints system to register waypoints (use the command waypoint), then the API car.getWaypoint(name) to retrieve the coordinates. The API car.getPosition() return the current position of the vehicle, then there is only a little math and trigonometry.

I'm going to look to add some commands (for example: car.go_to_location) and examples ;)

6 years ago

got it. thanks. some way to contact / discover unlabeled computers would be useful.

6 years ago

Currently you can contact all computers with :
Computer 1:

local myLabel = os.getComputerLabel()
wlan.on("pong", function(data)
    term.write(data)
end)
wlan.broadcast("ping", myLabel)

Other Computer:

wlan.on("ping", function(computerLabel)
    wlan.emit(computerLabel, "pong", {
        id = os.getComputerID(),
        label = os.getComputerLabel()
    })
end)

You can also use an autorun now:

wlan.onBuiltComputer(function(event)
    term.write("wlan.onBuiltComputer", event)
    event.autorun(function()
        term.write("Hello World !")
    end)
end)

Otherwise, I initially planned to identify computers by their ids, but so far I have not found a practical case of use. As a consequence I do not know exactly which function must be fulfilled by this id and that can not be done by a label.

NB: I have not planned either "remote control" of one computer by another (a computer modifying the label of another computer for example), because I think that it can have too many effects of unwanted edge in multiplayer. (If necessary, I can review my position)

After, the case of the "remote control" can be developed if necessary by wlan.emit and wlan.on. Example:

wlan.on("rename", function(newLabel)
    os.setComputerLabel(newLabel)
end)

------

wlan.emit("aLabel", "rename", "new_label")

New response