defines.lua - where is it?

Place to get help with not working mods / modding interface.
Post Reply
User avatar
ssilk
Global Moderator
Global Moderator
Posts: 12888
Joined: Tue Apr 16, 2013 10:35 pm
Contact:

defines.lua - where is it?

Post 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?
Cool suggestion: Eatable MOUSE-pointers.
Have you used the Advanced Search today?
Need help, question? FAQ - Wiki - Forum help
I still like small signatures...

Helfima
Fast Inserter
Fast Inserter
Posts: 199
Joined: Tue Jun 28, 2016 11:40 am
Contact:

Re: defines.lua - where is it?

Post by Helfima »

build defines.lua variable file and put in ur path
http://lua-api.factorio.com/latest/defines.html

User avatar
aubergine18
Smart Inserter
Smart Inserter
Posts: 1264
Joined: Fri Jul 22, 2016 8:51 pm
Contact:

Re: defines.lua - where is it?

Post 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)
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.

User avatar
DedlySpyder
Filter Inserter
Filter Inserter
Posts: 253
Joined: Fri Jun 20, 2014 11:42 am
Contact:

Re: defines.lua - where is it?

Post 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

User avatar
ssilk
Global Moderator
Global Moderator
Posts: 12888
Joined: Tue Apr 16, 2013 10:35 pm
Contact:

Re: defines.lua - where is it?

Post by ssilk »

Yes the docs are delivered with the binary.

Thanks for the help. I think the serialization idea is the most useful. :)
Cool suggestion: Eatable MOUSE-pointers.
Have you used the Advanced Search today?
Need help, question? FAQ - Wiki - Forum help
I still like small signatures...

Nexela
Smart Inserter
Smart Inserter
Posts: 1828
Joined: Wed May 25, 2016 11:09 am
Contact:

Re: defines.lua - where is it?

Post 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 :)

User avatar
Afforess
Filter Inserter
Filter Inserter
Posts: 422
Joined: Tue May 05, 2015 6:07 pm
Contact:

Re: defines.lua - where is it?

Post 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}))

Post Reply

Return to “Modding help”