Page 1 of 1

defines.lua - where is it?

Posted: Thu Sep 08, 2016 9:08 am
by ssilk
Lately I was experimenting again with writing mods. With 0.13 it seems, that defines.lua is removed from data/core, but seems to be "silently" required - I think some internal stuff, nice. :)

My problem with this: I found the defines.lue super-practical, cause my IDE was able to interpret it in a way, that it showed me the definitions.
(For interested: I use PHPStorm on MacOS and just needed to set an include-path to /Applications/factorio.app/Contents/data )

Cause I'm a friend of automatic code verification I would like to use this again.

Does anybody have a good idea to do that?

Re: defines.lua - where is it?

Posted: Thu Sep 08, 2016 12:14 pm
by Helfima
build defines.lua variable file and put in ur path
http://lua-api.factorio.com/latest/defines.html

Re: defines.lua - where is it?

Posted: Thu Sep 08, 2016 12:22 pm
by aubergine18
I'm not sure if there is a separate .lua file for it (if there is it will be in either core.zip or base.zip mods that are bundled with game).

You could possibly parse the documentation page linked in previous comment to generate a defines file? Or, easier, use serpent (already present in scripting env) to output the defines table in to a file on disk?

Code: Select all

-- something like...

-- make a copy that serpent can use
local definesCopy = table.deepcopy(defines)

-- use serpent to turn it in to string
local definesStr = serpent.block( definesCopy )

-- put it in a file
script.write_file('defines.lua', definesStr)

Re: defines.lua - where is it?

Posted: Thu Sep 08, 2016 3:51 pm
by DedlySpyder
I'm pretty sure that the Lua documentation is also included in the game files, so you wouldn't have to go put to the site to parse the info

Re: defines.lua - where is it?

Posted: Thu Sep 08, 2016 9:41 pm
by ssilk
Yes the docs are delivered with the binary.

Thanks for the help. I think the serialization idea is the most useful. :)

Re: defines.lua - where is it?

Posted: Thu Sep 08, 2016 10:37 pm
by Nexela
ssilk wrote:Yes the docs are delivered with the binary.

Thanks for the help. I think the serialization idea is the most useful. :)
Thanks for the serialization tip! I Am surprised I didn't think of it but I will use the heck out of it at least until I figure out how to parse it into an autocompletion file :)

Re: defines.lua - where is it?

Posted: Sat Sep 10, 2016 4:59 pm
by Afforess
ssilk wrote:Lately I was experimenting again with writing mods. With 0.13 it seems, that defines.lua is removed from data/core, but seems to be "silently" required - I think some internal stuff, nice. :)

My problem with this: I found the defines.lue super-practical, cause my IDE was able to interpret it in a way, that it showed me the definitions.
(For interested: I use PHPStorm on MacOS and just needed to set an include-path to /Applications/factorio.app/Contents/data )

Cause I'm a friend of automatic code verification I would like to use this again.

Does anybody have a good idea to do that?
You're welcome: https://raw.githubusercontent.com/Affor ... efines.lua

How to create your own: serialize the data to a file, game.write_file("defines.lua", serpent.block(_G.defines, {comments=false}))