Currently Online

Latest Posts

Topic: Lua production/consumption variables.

Tibor
Joined: 2009-03-23, 23:24
Posts: 1348
Ranking
One Elder of Players
Location: Slovakia
Posted at: 2017-01-05, 20:20

I prepared the branch lp:~widelands-dev/widelands/production_statistics, the syntax can be seen here e.g.:

http://bazaar.launchpad.net/~widelands-dev/widelands/production_statistics/view/head:/test/maps/expedition.wmf/scripting/test_check_transportation_works_one_ship.lua#L5


Top Quote
SirVer
Joined: 2009-02-19, 15:18
Posts: 1440
Ranking
One Elder of Players
Location: Germany - Munich
Posted at: 2017-01-05, 23:32

I prepared the branch lp:~widelands-dev/widelands/production_statistics, the syntax can be seen here e.g.:

Very cool, Tibor! Thanks for working on this. I have one comment though: creating the LuaTable with all possible entries is pretty expensive. For that reason, I used a function and gave the caller the choice what she is interested in in (most) other classes that give access to wares or workers. I think you can reuse this API (and the parsing functions for the parameters are already implemented). The API is described here: HasWares and here is the example implementation for Flag. There are other implementors in the Lua API.


Top Quote
Tibor
Joined: 2009-03-23, 23:24
Posts: 1348
Ranking
One Elder of Players
Location: Slovakia
Posted at: 2017-01-05, 23:45

I was considering this approach, but e.g. small problem is here: http://bazaar.launchpad.net/~widelands-dev/widelands/animation_manager/view/8190/src/scripting/lua_map.cc#L173 - this is defined in lua_map.cc and I would need it in lua_game.cc. Maybe if I moved it in other file?


Top Quote
SirVer
Joined: 2009-02-19, 15:18
Posts: 1440
Ranking
One Elder of Players
Location: Germany - Munich
Posted at: 2017-01-08, 17:25

Maybe if I moved it in other file?

Yes, why not. Just create a new one just for these functions seems fine.


Top Quote
Tibor
Joined: 2009-03-23, 23:24
Posts: 1348
Ranking
One Elder of Players
Location: Slovakia
Posted at: 2017-01-08, 18:07

In the meantime I wrote it from scratch in my function, it is now waiting for review, "production_statistics" branch.

But I can rewrite it once more as separate function and in separate branch, if needed


Top Quote