How to make a factorio mod to trigger python script?

Place to get help with not working mods / modding interface.
Post Reply
Edris89
Burner Inserter
Burner Inserter
Posts: 8
Joined: Sun Mar 25, 2018 5:11 am
Contact:

How to make a factorio mod to trigger python script?

Post by Edris89 »

Hi there my name is Edris,

Me and my friends play alot of factorio in the weekend, And I thought hey wouldn't be awesome if my neopixel led strip would light up if there's is a alarm in my factorio headless server game.

So my setup is headless server of factorio on ubuntu server. attached to the server with usb is a arduino nano with neopixel ledstrip.
My serial communication is working not a problem with that.
But i wanted to make a mod or something that would read the electrical energy of the system and if its below a certain point it would trigger or toggle a variable in the api or mod.
mayby i could make a file and append to it so that python could read it out and so hence forth the arduino,

i am using the following tutorial i found on google.
https://wiki.factorio.com/Tutorial:Modding_tutorial/ru

it' s just that I want to read something out and throw it in a variable and make a file somewhere in the system so that python could read it out.
i don't know if this is the way so any help is appreciated.

thanks in advance
edris

User avatar
DaveMcW
Smart Inserter
Smart Inserter
Posts: 3700
Joined: Tue May 13, 2014 11:06 am
Contact:

Re: How to make a factorio mod to trigger python script?

Post by DaveMcW »

Code: Select all

game.write_file("power.txt", data)

Edris89
Burner Inserter
Burner Inserter
Posts: 8
Joined: Sun Mar 25, 2018 5:11 am
Contact:

Re: How to make a factorio mod to trigger python script?

Post by Edris89 »

Aright aright. That's a cool line of code to try.

Say I wanted to make a mod with a power switch.
How can I do that and where in which file?
I wanted to check in LUA if the modded power switch is on or off , I think in the control.lua ??

Then I could write it to a file like DaveMcW suggested


//Code to determine if the ingame modded power switch is on or off

//then
game.write_file("power.txt", data)

Post Reply

Return to “Modding help”