Page 1 of 1

on_tick from the console

Posted: Wed Dec 16, 2015 1:15 pm
by JoeSchmoe
I'm thinking about creating a mod but from what little modding i've done so far you need to edit control.lua and reload the game to see if it works, this slows things down quite a bit.
Is there anyway to do my write a function in the console, and then once it works copy it to control.lua? I think this would help speed up development.

Re: on_tick from the console

Posted: Wed Dec 16, 2015 1:46 pm
by DaveMcW
Yes, you can write it the same way as in control.lua.

Code: Select all

/c
script.on_event(defines.events.on_tick, function(event)
	game.player.print(game.tick)
end)
Writing it again overwrites your old function.

Code: Select all

/c
script.on_event(defines.events.on_tick, nil)
Note that you won't have access to any of your mod variables unless you build a getter.

Re: on_tick from the console

Posted: Fri Dec 18, 2015 7:39 pm
by Julianus
Hi JoeSchmoe,

do you reload the entire game, or just the save?

My observation was, that control.lua is reloaded on each save game load.