Colombo wrote:hoho: with 10.1, there were bug repaired and when you run factorio from console, all errors are properly logged.
This fails to work for me (on windows with cmd and powershell ...yes, I know neither is a proper console lol)
hoho wrote:Apparently game.createfile doesn't work when it's inside data.lua but works just fine inside control.lua. [snip] Looking around the wiki it seems as I can access data.raw only from within data.lua and not from within control.lua.
Both of these are true, the game object does not exist until ingame and data does not exist ingame (it's split into the proper locations of game.force.recipes/technologies etc., but it's only partially accessible). From the error I was assuming that you were working from the control.lua (data.lua, as far as I can remember, has always given me the name of the nil variable like it did with game)... Sorry for the assumption there. No way to write data from data.lua to a file since the lua io (and os) library are not available.
hoho wrote:Could I somehow make a copy of the data.raw so I could access it later from control.lua
The data.raw is just the prototypes added by the base game (and mods) via data:extend so you don't need to dump it from control.lua, just look at the files. It's layout has been created on the wiki
here (essentially each type has it's own index which is then indexed by the name of the prototypes). If you needed to actually
use some of that data from the control.lua then first call .help() on one to see what data they contain (ex. game.player.force.recipes["iron-plate"].help(), ingame. if you do it in the control.lua you'd need to print it out yourself or pass it to makefile), if it's not there then in the belt-replacer mod that I'm working on I created recipes (that will never be unlocked) with the information I needed as the name of the recipe (the recipe names can be accessed quite easily in the control.lua, at which point I can split the name with string.find or string.match into the various pieces of info that I'd placed into the name)...be aware that the names can not contain a '.' (and possibly a few other things) and Factorio responds with a somewhat cryptic message about a 'note' recipe not having a name lol (I needed the belt speeds so to remove the '.' I multiplied the speed by 1000000, if it was something else I probably could have used string.gsub to replace the '.' with some other string of characters that I could reliably convert back in control.lua)
why not post the code and let one of us see where the problem is being caused if you can't find it? (it seems obvious enough that somewhere you are doing math, intentionally or not, on a variable that doesn't have an actual value, either because it wasn't given one or because it's not being accessed properly (ie misspelled)), the error should give the line number so that helps narrow it down further if you are using math in multiple places
