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.
Modding Development Best Practices
Re: Modding Development Best Practices
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:otsukarci wrote:Is there any way to print debug logs other than using 'print' statements?
Code: Select all
game.player.print("text")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.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?
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

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

Re: Modding Development Best Practices
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.zer0t3ch wrote: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:otsukarci wrote:Is there any way to print debug logs other than using 'print' statements?Code: Select all
game.player.print("text")
Will ask the devs about launching a saved game.
Re: Modding Development Best Practices
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.
+ 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.
Re: Modding Development Best Practices
I just use notepad++, not an IDE, didnt even know lua had IDEs



