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
Programmer
Posts: 3433
Joined: Tue Sep 30, 2014 10:01 am
Location: Wall IV

Adding FOCS way to get empire meter value

#1 Post by Ophiuchus »

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.

Look, ma... four combat bouts!

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 »

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
Programmer
Posts: 3433
Joined: Tue Sep 30, 2014 10:01 am
Location: Wall IV

Re: Adding FOCS way to get empire meter value

#3 Post by Ophiuchus »

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.

Look, ma... four combat bouts!

User avatar
Geoff the Medio
Programming, Design, Admin
Posts: 13587
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 »

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
Programmer
Posts: 3433
Joined: Tue Sep 30, 2014 10:01 am
Location: Wall IV

Re: Adding FOCS way to get empire meter value

#5 Post by Ophiuchus »

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.

Look, ma... four combat bouts!

Ophiuchus
Programmer
Posts: 3433
Joined: Tue Sep 30, 2014 10:01 am
Location: Wall IV

Re: Adding FOCS way to get empire meter value

#6 Post by Ophiuchus »

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.

Look, ma... four combat bouts!

User avatar
Geoff the Medio
Programming, Design, Admin
Posts: 13587
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 »

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
Programmer
Posts: 3433
Joined: Tue Sep 30, 2014 10:01 am
Location: Wall IV

Re: Adding FOCS way to get empire meter value

#8 Post by Ophiuchus »

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.

Look, ma... four combat bouts!

Post Reply