Hello,
Could you add a cpu and memory properties to the game object please?
It could be useful to implement "smart" coroutines for heavy calculations, it does not need to be precise, just an indication like low, mid, high.
Is it also possible to add integer and bit ops to the lua VM? It could tremendously help performance for, say, neural networks
Edit:
I forgot, can you also add a function get_tiles(area) ?
Thanks!
CPU, memory info and lua VM
- aubergine18
- Smart Inserter
- Posts: 1264
- Joined: Fri Jul 22, 2016 8:51 pm
- Contact:
Re: CPU, memory info and lua VM
Using coroutines will likely break MP games due to desync...
I thought the bitop stuff was already present (vague memory - have a root around on _G)...
For getting tiles in area, you could use these from any LuaSurface:
.get_tileproperties(x, y) → TileProperties Get tile properties.
.set_tiles(tiles, correct_tiles) Set tiles at specified locations.
I thought the bitop stuff was already present (vague memory - have a root around on _G)...
For getting tiles in area, you could use these from any LuaSurface:
.get_tileproperties(x, y) → TileProperties Get tile properties.
.set_tiles(tiles, correct_tiles) Set tiles at specified locations.
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.
Re: CPU, memory info and lua VM
This already exists. Just hit F4 in-game and enable the debug times option to see how much CPU time is spent on each mod.
If you want to get ahold of me I'm almost always on Discord.
Re: CPU, memory info and lua VM
I meant in-game routines, based on the on_tick event, although true MP co routines would be niceaubergine18 wrote:Using coroutines will likely break MP games due to desync...
I thought the bitop stuff was already present (vague memory - have a root around on _G)...
For getting tiles in area, you could use these from any LuaSurface:
.get_tileproperties(x, y) → TileProperties Get tile properties.
.set_tiles(tiles, correct_tiles) Set tiles at specified locations.
And about get_tiles, i meant a function returning an array of tiles.
Thanks for your answer though
Re: CPU, memory info and lua VM
No, i meant programatically get the CPU load, in a mod. There's nothing like that on http://lua-api.factorio.com unless i'm missing something?Rseding91 wrote:This already exists. Just hit F4 in-game and enable the debug times option to see how much CPU time is spent on each mod.
Thanks for your time
Re: CPU, memory info and lua VM
That information wouldn't be deterministic at all and as such would desync and break replays if mods had access to it - which is why they don't.sebgggg wrote:No, i meant programatically get the CPU load, in a mod. There's nothing like that on http://lua-api.factorio.com unless i'm missing something?Rseding91 wrote:This already exists. Just hit F4 in-game and enable the debug times option to see how much CPU time is spent on each mod.
Thanks for your time
If you want to get ahold of me I'm almost always on Discord.
Re: CPU, memory info and lua VM
Essentially what you really need is a way to schedule lazy execution of certain code when the game has free time slices available. Right now there isn't a way to do that, and I gather what @sebgggg is asking for would let him build one.
Sure, code execution can be smeared over on_tick but that's not a perfect solution, as it gives no indication of what else might also be running.
Sure, code execution can be smeared over on_tick but that's not a perfect solution, as it gives no indication of what else might also be running.
- aubergine18
- Smart Inserter
- Posts: 1264
- Joined: Fri Jul 22, 2016 8:51 pm
- Contact:
Re: CPU, memory info and lua VM
I'm sure I read somewhere in these forums that events will wait until later tick before triggering handlers if too much time has been taken on tick where event fired (not sure if this is only vanilla events of if it works for custom events too?)
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.