Is it possible to get a .write_file() that's accessible from data.lua and data-final-fixes.lua?
Sometimes I make stupid mistake in my prototypes and it takes ages to try and work out where I've gone wrong because I can't serpent objects to file.
The only write_file() I'm aware of is part of the _G.game object, which isn't available from data.lua or data-final-fixes.lua scope.
If not available, serpent would also be a useful addition to the _G that's present during data.lua and data-final-fixes.lua.
[solved] data.write_file() - serpent to disk within data.lua
- aubergine18
- Smart Inserter
- Posts: 1264
- Joined: Fri Jul 22, 2016 8:51 pm
- Contact:
[solved] data.write_file() - serpent to disk within data.lua
Last edited by aubergine18 on Tue Sep 20, 2016 11:49 pm, edited 1 time in total.
Better forum search for modders: Enclose your search term in quotes, eg. "font_color" or "custom-input" - it prevents the forum search from splitting on hypens and underscores, resulting in much more accurate results.
Re: data.write_file() - for serpent to disk within data.lua
serpent is already available during the data loading phase. You can use print() or log() to get at its output.
Automatic Belt (and pipe) Planner—Automate yet another aspect of constructing your factory!
- aubergine18
- Smart Inserter
- Posts: 1264
- Joined: Fri Jul 22, 2016 8:51 pm
- Contact:
Re: data.write_file() - for serpent to disk within data.lua
Do you have an example? I couldn't find the info about print() (other than game.player.print() which isn't avail in data load stage) or log() in the API docs..
Better forum search for modders: Enclose your search term in quotes, eg. "font_color" or "custom-input" - it prevents the forum search from splitting on hypens and underscores, resulting in much more accurate results.
Re: data.write_file() - for serpent to disk within data.lua
print() simply writes to stdout, where you can watch the output in a terminal or redirect it to a file manually.
log() produces an entry in the log file, like "0.320 Script data.lua:7: bla".
log() produces an entry in the log file, like "0.320 Script data.lua:7: bla".
Automatic Belt (and pipe) Planner—Automate yet another aspect of constructing your factory!
- aubergine18
- Smart Inserter
- Posts: 1264
- Joined: Fri Jul 22, 2016 8:51 pm
- Contact:
Re: data.write_file() - for serpent to disk within data.lua
I'm a bit useless when it comes to command line stuff so looks like log() is the right approach for me Thanks for the infos!
Better forum search for modders: Enclose your search term in quotes, eg. "font_color" or "custom-input" - it prevents the forum search from splitting on hypens and underscores, resulting in much more accurate results.
- aubergine18
- Smart Inserter
- Posts: 1264
- Joined: Fri Jul 22, 2016 8:51 pm
- Contact:
Re: data.write_file() - for serpent to disk within data.lua
Using serpent to dump data.raw to log:
Result: https://raw.githubusercontent.com/auber ... r/data.raw
Code: Select all
log( serpent.block( data.raw, {comment = false, numformat = '%1.8g' } ) )
Better forum search for modders: Enclose your search term in quotes, eg. "font_color" or "custom-input" - it prevents the forum search from splitting on hypens and underscores, resulting in much more accurate results.