Advertisement
wccrawford

starboundparse.js

Dec 20th, 2013
6,564
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.74 KB | None | 0 0
  1. #!/usr/bin/nodejs
  2. var fs = require('fs');
  3. fs.readFile(process.argv[2], 'utf8', function(err, data) {
  4. try{
  5. data = data.replace(new RegExp('\\/\\*.*\\*\\/', 'gm'), '');
  6. var lines = data.split('\n');
  7. for(var l in lines) {
  8. if(lines[l].indexOf('//') != -1) {
  9. lines[l] = lines[l].substring(0, lines[l].indexOf('//'));
  10. }
  11. }
  12. var json = JSON.parse(lines.join('\n'));
  13. if(json.itemName || json.objectName) {
  14. var out = [];
  15. var parts = ['objectName', 'itemName', 'shortdescription', 'description'];
  16. for(var x in parts) {
  17. if(json[parts[x]]) {
  18. out.push(json[parts[x]]);
  19. }
  20. }
  21. //console.log(json.objectName + ' | ' + json.shortdescription + ' | ' + json.description);
  22. console.log(out.join(' | '));
  23. }
  24. } catch(exc) {}
  25. });
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement