Advertisement
Guest User

Factorio basic RCON

a guest
Dec 2nd, 2016
1,974
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. // Remember to npm install simple-rcon
  2. var Rcon = require('simple-rcon');
  3. var client = new Rcon({
  4.     host: 'localhost',
  5.     port: instanceconfig.clientPort, // port factorio listens after RCON connections on
  6.     password: instanceconfig.clientPassword, // RCON password
  7.     timeout: 0
  8. });
  9. setTimeout(() => { client.connect(); }, 5000);
  10.  
  11. client.on('authenticated', function() {
  12.     console.log('Authenticated!');
  13. }).on('connected', function() {
  14.     console.log('Connected!');
  15. }).on('disconnected', function() {
  16.     console.log('Disconnected!');
  17.     // now reconnect
  18.     client.connect();
  19. });
  20.  
  21. // Now do whatever you want!
  22. // silent-command doesn't show up in chat, nice to avoid spam :)
  23. client.exec("/silent-command remote.call('clusterio', 'doStuff', 'Some data of some kind')");
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement