Template Modification Factorio



  • Hello Everyone.

    I am looking for a way to edit the content of the server-settings.json file from the installation/template for a Factorio server.

    Are they any way in the template we can edit files ?

    Thank You



  • I found a first answer from Creating pufferd templates

    writefile - Writes text into a file, ${ip} and ${port} are variables from the data section
    
            {
              "type": "writefile",
              "text": "server-ip=${ip}\nserver-port=${port}\n",
              "target": "server.properties"
            },
    

    Second problem now, the script delete everything in my server-setting.json and I only get the "name: nameset"

    {
      "pufferd": {
        "type": "factorio",
        "display": "FactorioP",
        "install": {
          "commands": [
            {
              "commands": [
                "curl -L -o factorio.tar.xz https://www.factorio.com/get-download/latest/headless/linux64",
                "mkdir factorio",
                "tar --no-same-owner -xvf factorio.tar.xz",
                "cp factorio/data/server-settings.example.json factorio/data/server-settings.json",
                "./factorio/bin/x64/factorio --create saves/default.zip"
              ],
              "type": "command"
            },
    
    	{
    	    "type": "writefile",
    	    "text": "name:${name}",
    	    "target":"factorio/data/server-settings.json"
    	}
     
          ]
        },
        "run": {
          "stop": "/quit",
          "pre": [],
          "post": [],
          "arguments": [
            "--port",
            "${port}",
            "--bind",
            "${ip}",
            "--start-server",
            "${save}",
            "--server-settings",
            "${server-settings}"
          ],
          "program": "./factorio/bin/x64/factorio"
        },
        "environment": {
          "type": "tty"
        },
        "data": {
          "save": {
            "value": "saves/default.zip",
            "required": true,
            "desc": "Save File to Use",
            "display": "Save File to Use",
            "internal": false
          },
          "ip": {
            "value": "0.0.0.0",
            "required": true,
            "desc": "What IP to bind the server to",
            "display": "IP",
            "internal": false
          },
          "port": {
            "value": "34197",
            "required": true,
            "desc": "What port to bind the server to",
            "display": "Port",
            "internal": false,
            "type": "integer"
          },
    
          "name":{
    	"value": "FactoName",
    	"required": true,
    	"desc": "Server Display Name",
    	"display": "name",
    	"internal":false
          },
    
          "server-settings": {
            "value": "factorio/data/server-settings.json",
            "required": true,
            "desc": "Server Settings File Location",
            "display": "Server Settings JSON",
            "internal": false
          }
        }
      }
    }
    
    


  • Problem solved i need to wrote myself the whole config from this command.

    Example :

    {
    	    "type": "writefile",
    	    "text": "{\n\"name\":\"${name}\",\n\"description\":\"${description}\",\n\"tags\":[\"${tag1}\"],\n\"max_players\":${max_players},\n\n\"visibility\":\n{\n\"public\":${Pvisibility},\n\"lan\":${Lvisibility}\n},\n\n\"username\":${username},\n\"password\":${password},\n\"token\":${token},\n}",
    	    "target":"factorio/data/server-settings.json"
    	}
    

    I will come back with a Factorio template more complete in the future.


 

4
Online

789
Users

819
Topics

3.5k
Posts