Adding FOCS way to get empire meter value

Programmers discuss here anything related to FreeOrion programming. Primarily for the developers to discuss.

Moderator: Committer

Post Reply
Message
Author
Ophiuchus
Vacuum Dragon
Posts: 505
Joined: Tue Sep 30, 2014 10:01 am

Adding FOCS way to get empire meter value

#1 Post by Ophiuchus » Fri Jan 27, 2017 3:47 pm

There is SetEmpireMeter for set a meter and EmpireMeter for comparing in a query.
As far as I understand the parser and scripting system, there is currently no way to get the value of an empire meter (e.g. for using it in a sitrep).

In which of the parsers would I add this? I looked around awhile am not completely sure where to add it.
Any code or patches in anything posted here is released under the CC and GPL licences in use for the FO project.

dbenage-cx
Programmer
Posts: 389
Joined: Sun Feb 14, 2016 12:08 am

Re: Adding FOCS way to get empire meter value

#2 Post by dbenage-cx » Fri Jan 27, 2017 6:12 pm

Which value are you looking for, most are in parse/DoubleValueRefParser.cpp
e.g. for supply:

Code: Select all

tag = "rawtext" data = Target.Supply

Ophiuchus
Vacuum Dragon
Posts: 505
Joined: Tue Sep 30, 2014 10:01 am

Re: Adding FOCS way to get empire meter value

#3 Post by Ophiuchus » Fri Jan 27, 2017 10:10 pm

dbenage-cx wrote:Which value are you looking for, most are in parse/DoubleValueRefParser.cpp
e.g. for supply:

Code: Select all

tag = "rawtext" data = Target.Supply
I was not looking really looking for a specific value. You can add empire meters using FOCS. I think it would be good to have a scripting access to the current value as well.

And of course there is also a specific value. The reason is that i added empire meters (e.g. for yield) for the implementation of imperial stockpile. I want to give a sitrep indication about it.
And as long there is no automatic UI and effect accounting for an empire meter this might be the only way for a scripter to communicate values .
Any code or patches in anything posted here is released under the CC and GPL licences in use for the FO project.

User avatar
Geoff the Medio
Programming, Design, Admin
Posts: 12243
Joined: Wed Oct 08, 2003 1:33 am
Location: Munich

Re: Adding FOCS way to get empire meter value

#4 Post by Geoff the Medio » Sat Jan 28, 2017 7:17 am

You'd need to add cases in ComplexVariable<double>::Eval to handle "EmpireDetection", "EmpireProductionStockpileYield", "EmpireProductionStockpileMax", and perhaps others. Then add cases in DoubleComplexValueRefParser.cpp to parse this. Should add cases for all the empire meters in Empire::Init. Any new symbols need to be added to Tokens.h for the parser.

Ophiuchus
Vacuum Dragon
Posts: 505
Joined: Tue Sep 30, 2014 10:01 am

Re: Adding FOCS way to get empire meter value

#5 Post by Ophiuchus » Sat Jan 28, 2017 11:51 pm

Geoff the Medio wrote:You'd need to add cases in ComplexVariable<double>::Eval to handle "EmpireDetection", "EmpireProductionStockpileYield", "EmpireProductionStockpileMax", and perhaps others. Then add cases in DoubleComplexValueRefParser.cpp to parse this. Should add cases for all the empire meters in Empire::Init. Any new symbols need to be added to Tokens.h for the parser.
I addressed the general meter access first and created a pull request
Any code or patches in anything posted here is released under the CC and GPL licences in use for the FO project.

Ophiuchus
Vacuum Dragon
Posts: 505
Joined: Tue Sep 30, 2014 10:01 am

Re: Adding FOCS way to get empire meter value

#6 Post by Ophiuchus » Sun Jan 29, 2017 6:36 pm

Ophiuchus wrote:
Geoff the Medio wrote:You'd need to add cases in ComplexVariable<double>::Eval to handle "EmpireDetection", "EmpireProductionStockpileYield", "EmpireProductionStockpileMax", and perhaps others. Then add cases in DoubleComplexValueRefParser.cpp to parse this. Should add cases for all the empire meters in Empire::Init. Any new symbols need to be added to Tokens.h for the parser.
I addressed the general meter access first and created a pull request
The general case is merged.
So for those special cases, a question regarding the parser concepts.
Why should those be "complex" compared to not-complex variables?
Any code or patches in anything posted here is released under the CC and GPL licences in use for the FO project.

User avatar
Geoff the Medio
Programming, Design, Admin
Posts: 12243
Joined: Wed Oct 08, 2003 1:33 am
Location: Munich

Re: Adding FOCS way to get empire meter value

#7 Post by Geoff the Medio » Sun Jan 29, 2017 6:40 pm

Ophiuchus wrote:So for those special cases, a question regarding the parser concepts.
Why should those be "complex" compared to not-complex variables?
An empire meter is not a property of an UniverseObject. Target.Stealth make sense. Target.SomeEmpireShowhowRelatedToTargetOrMaybeNotsDetection doesn't really.

Ophiuchus
Vacuum Dragon
Posts: 505
Joined: Tue Sep 30, 2014 10:01 am

Re: Adding FOCS way to get empire meter value

#8 Post by Ophiuchus » Sun Jan 29, 2017 8:58 pm

Geoff the Medio wrote:
Ophiuchus wrote:So for those special cases, a question regarding the parser concepts.
Why should those be "complex" compared to not-complex variables?
An empire meter is not a property of an UniverseObject. Target.Stealth make sense. Target.SomeEmpireShowhowRelatedToTargetOrMaybeNotsDetection doesn't really.
Ok, thanks :)
Any code or patches in anything posted here is released under the CC and GPL licences in use for the FO project.

Post Reply