Topic: Lua production/consumption variables.
Lokimaros Topic Opener |
Posted at: 2016-12-31, 17:55
Hi, I'm thinking of wetting my feet in lua with an economic advisor script for myself. For this I would like to know actual production since last check for all products and actual consumption. Separately, I know I can get net gain or loss by checking the warehouse contents, even if that doesn't include products in transit. So, the question is: is there a way to find out how many trees/rocks/wheat/flour/etcetera there have been produced since the previous check and how many were used for building or in buildings? Or is there a hook or something that gets checked whenever anything is produced or consumed? Edited: 2016-12-31, 18:06
Top Quote |
SirVer |
Posted at: 2017-01-02, 16:39
You can check the total stock of a player using Lua: see here and also
unfortunately not. We have a functionality for lua hooks (grep for Top Quote |
Lokimaros Topic Opener |
Posted at: 2017-01-02, 19:30
Pity, a way to do it would be to create two virtual warehouses and add one in the creation warehouse every time something gets created, and add one in the other every time something gets taken out. Then I could compare those virtual warehouses in intervals and calculate creation and usage times in practice. Like this, I can only track the difference, which is better than nothing, but not what I was hoping for. Top Quote |
Tibor |
Posted at: 2017-01-02, 20:15
Theoretically each productionsite can have counter of produced goods, and there would be some method (f.e. LUA interface) to get the number. Top Quote |
Lokimaros Topic Opener |
Posted at: 2017-01-03, 14:07
And from that usage could be calculated with: total_prod - previous_total + previous_warehouse - current_warehouse. That would do me fine. Top Quote |
Tibor |
Posted at: 2017-01-03, 19:56
Hey, I just found we already have the information: current_produced_statistics_, that is vector of counts of produces goods. So we only need and LUA interface that would fetch the count from there... Top Quote |
SirVer |
Posted at: 2017-01-03, 21:59
Yes, this is the data used in the Ware menus - which contains exactly the data OP wants to access. Tab 1 is number of wares produced, Tab 2 is consumed and Tab 3 is (produced minus consumed), i.e. what OP would like to have in Lua. It is economy wide though, not per building. Top Quote |
Tibor |
Posted at: 2017-01-03, 22:53
My feeling is that overall production per player would be enough.. Top Quote |
Lokimaros Topic Opener |
Posted at: 2017-01-04, 02:19
It would be for my economic advisor script, though I can see use for per building to help find out whether a building is perhaps badly placed. But I don't need my script to tell me that, I just want it to thwack me in the head about the shortcomings in my economy in order of urgency. And if it finds no fault, it should play a soundfile of a purring kitten. Top Quote |
Tibor |
Posted at: 2017-01-04, 23:59
I spend 2 hours today just to debug why the hell current_produced_statistics_ contains always 0 or 1 (never grow higher in spite of the production running). Than I found that there is another vector ware_productions_, where content of the first one is pushed regularly. So now I believe I will be able to finish the LUA method and provide it for review... Top Quote |