Modding Development Best Practices

Place to post guides, observations, things related to modding that are not mods themselves.
otsukarci
Manual Inserter
Manual Inserter
Posts: 4
Joined: Mon Aug 05, 2013 1:58 am
Contact:

Modding Development Best Practices

Post by otsukarci »

I recently started experimenting with modding but wasn't able to setup an ideal development environment.

Is there a guide somewhere on this topic? If not can we please discuss best practices for modding development here so newbies can set up a development env. that makes mode developments easy?

Here are my development steps:

1- Open my IDE.
2- Write some code
3- Press 'Run' which deploys my code as a mode and then opens Factorio.
4- Play -> Load game -> (Find my save game and start)
5- Do some stuff, use in-game console for debugging to some degree.
6- Go to 2

I quit and launch game often to see my progress in small increments. I would like to merge step 3-4 so when my 'Run' script opens Factorio I can load my 'development' save automatically. Is there a way yo do this?

Is there any way to print debug logs other than using 'print' statements?

I think there will be more questions as I get experienced and try new things. For example managing and including lua dependencies.

User avatar
zer0t3ch
Fast Inserter
Fast Inserter
Posts: 118
Joined: Fri Jul 26, 2013 6:06 am
Contact:

Re: Modding Development Best Practices

Post by zer0t3ch »

otsukarci wrote:Is there any way to print debug logs other than using 'print' statements?
Is there any reason to use anything else? Also, I think the generic "print("text")" doesn't always work correctly, so get into the habit of using this:

Code: Select all

game.player.print("text")
otsukarci wrote:I would like to merge step 3-4 so when my 'Run' script opens Factorio I can load my 'development' save automatically. Is there a way yo do this?
I don't belive that this exists yet, but you could ask the devs to add an argument that can do that, which would theoretically make it possible to automate that.

Example: In Command Prompt* you would run something like this.

Code: Select all

"factorio.exe" -load=dev

* - Or a batch file
"F**k thy hater"
-George Watsky

Feel free to contact me!
Skype: Zer0t3ch
Razer Comms: Zer0t3ch
Email: zer0t3ch@live.com

Image

otsukarci
Manual Inserter
Manual Inserter
Posts: 4
Joined: Mon Aug 05, 2013 1:58 am
Contact:

Re: Modding Development Best Practices

Post by otsukarci »

zer0t3ch wrote:
otsukarci wrote:Is there any way to print debug logs other than using 'print' statements?
Is there any reason to use anything else? Also, I think the generic "print("text")" doesn't always work correctly, so get into the habit of using this:

Code: Select all

game.player.print("text")
Sorry, I meant "game.player.print('text')" by "'print' statement". Since this method is already being used in the game (although not often), I looked for another way that can be used only for logging purposes. This is not really a big deal.

Will ask the devs about launching a saved game.

drs9999
Filter Inserter
Filter Inserter
Posts: 831
Joined: Wed Mar 06, 2013 11:16 pm
Contact:

Re: Modding Development Best Practices

Post by drs9999 »

Actually I do it in the same way than you do.

+ I normally add a giveItems function to the onInit event, so you have all the items that have to be tested or needed for testing on start.
+ I use game.player.print in the code for debug messages (only if I want to check one or two values)

You can also use game.showmessagedialog(variable), that opens a messagewindow like the one you will receive on starting a freeplay.
Also useful is serpent.block(table). You can use it in connection with print or messagedialog.
So e.g. game.showmessagedialog(serpent.block(game.player.character.getinventory(1).getcontents())) will show you a table of the player's inventory.

P.S. If you only changed your control.lua file there is no need to close a factorio. Starting/loading a game is enough. The updated version is used then.

ficolas
Smart Inserter
Smart Inserter
Posts: 1068
Joined: Sun Feb 24, 2013 10:24 am
Contact:

Re: Modding Development Best Practices

Post by ficolas »

I just use notepad++, not an IDE, didnt even know lua had IDEs

Post Reply

Return to “Modding discussion”