console command question
console command question
Hello factorio forum users and staff. I was wondering if i could write "batch files" to use console commands but i wasn't able to find much information on the subject in my searches so if you know of any threads explaining it that would be very helpful. Thanks in advance!
Re: console command question
Yes, you can copy/paste an entire lua file into the console.
You can also define functions that do a bunch of stuff at once.
Note that everything will be lost when you reload the game, unless you make it into a mod.
You can also define functions that do a bunch of stuff at once.
Code: Select all
/c print = function(text)
game.local_player.print(text)
end
Code: Select all
/c print("Hello world!")
Re: console command question
Thanks for your response!
Funny you should say that because i created this task for myself after this viewtopic.php?f=94&t=13863 had an error.DaveMcW wrote: Note that everything will be lost when you reload the game, unless you make it into a mod.
mind explaining that a bit more? do you mean copy/pasting the contents of a file in game or can i make a lua file and drop it somewhere in the factorio files and activate everything it contains with one command ?DaveMcW wrote: Yes, you can copy/paste an entire lua file into the console.
Re: console command question
You can copy paste any lua script code into the game console and it will run it,john wrote:mind explaining that a bit more? do you mean copy/pasting the contents of a file in game or can i make a lua file and drop it somewhere in the factorio files and activate everything it contains with one command ?DaveMcW wrote: Yes, you can copy/paste an entire lua file into the console.
This includes any event hooks and functions
so for instance you can start a game, and paste the following into console
Code: Select all
/c function give_coin()
if game.tick % 1500 == 0 then
game.players[1].insert{name = "coin", count = 1}
end
end
script.on_event(defines.events.on_tick, give_coin)
Re: console command question
Unless you are using replay or playing multiplayer, or save and load the game, as it will break.Klonan wrote:You can copy paste any lua script code into the game console and it will run it,john wrote:mind explaining that a bit more? do you mean copy/pasting the contents of a file in game or can i make a lua file and drop it somewhere in the factorio files and activate everything it contains with one command ?DaveMcW wrote: Yes, you can copy/paste an entire lua file into the console.
This includes any event hooks and functions
so for instance you can start a game, and paste the following into console
and it will run the same as if you had this in the control.lua of your mod/scenarioCode: Select all
/c function give_coin() if game.tick % 1500 == 0 then game.players[1].insert{name = "coin", count = 1} end end script.on_event(defines.events.on_tick, give_coin)