Page 1 of 1

Hooks for gui values

Posted: Fri Dec 02, 2016 4:10 pm
by Hopewelljnj
I have a friend who streams and does videos for youtube and he wanted to be able to pull some production stats and power stats into OBS. If I could access them it would be as simple as moving those values to a text file he could parse. However we currently have no hooks into that information.

My suggestion is that since you are already calculating all the data and naturally storing it somewhere in the memory, is to add hooks for modders to be able to pull data from the production and electric network screens.

Re: Hooks for gui values

Posted: Fri Dec 02, 2016 4:30 pm
by daniel34
You can write a small mod (or even include it into the control.lua of the savefile) that periodically gathers the information you're looking for and writes it to an external file with LuaGameScript.write_file, which you then can parse with an external tool.

Re: Hooks for gui values

Posted: Fri Dec 02, 2016 5:43 pm
by Hopewelljnj
This is what I would like to do. However currently to my knowledge there are no ways to grab the power usage or to grab production values. That is the issue.

Re: Hooks for gui values

Posted: Fri Dec 02, 2016 6:55 pm
by daniel34
Hopewelljnj wrote:This is what I would like to do. However currently to my knowledge there are no ways to grab the power usage or to grab production values. That is the issue.
For production values use http://lua-api.factorio.com/latest/LuaF ... stics.html
Example that shows the production values (the same as in the [P] Production window - tab All) for eg. iron plate:

Code: Select all

/c game.player.print(game.player.force.item_production_statistics.get_input_count("iron-plate"))
Use get_output_count for consumption values.
LuaForce also has values for fluid consumption, resources, entity build counts and kill counts.

I don't think there currently is an easy way to read power usage statistics using lua, you might ask in the Modding help or Modding interface requests forums.

Re: Hooks for gui values

Posted: Fri Dec 02, 2016 7:14 pm
by Hopewelljnj
Thanks.

Re: Hooks for gui values

Posted: Sat Dec 03, 2016 4:39 pm
by ssilk
Moved from suggestions to modding help