FreeOrion

Forums for the FreeOrion project
It is currently Thu Dec 14, 2017 8:37 pm

All times are UTC




Post new topic Reply to topic  [ 3 posts ] 
Author Message
 Post subject: SortedNumberOf
PostPosted: Wed Nov 23, 2016 8:09 am 
Offline
Programmer

Joined: Sun Feb 14, 2016 12:08 am
Posts: 359
Will likely take me a few days to thoroughly test, so I wanted to check if this was a correct use:

Code:
MaximumNumberOf Number = 1 SortKey = Source.Planet.Happiness Condition = And [
    Planet
    InSystem id = Source.SystemID
    OwnedBy empire = Source.Owner
    Contains
        Building name = "BLD_SHIPYARD_ORBITAL_DRYDOCK"
]


The intent here is to get the owned planet in the system with the highest happiness (and has a drydock).
I'm not sure on this, since SortKey is only passing a double.
I assume the "property_name" is gathered from the scripting context (I don't see any reference to property other than in comments)

_________________
Any content posted should be considered licensed GNU GPL 2.0 and/or CC-BY-SA 3.0 as appropriate.


Top
 Profile  
 
 Post subject: Re: SortedNumberOf
PostPosted: Wed Nov 23, 2016 4:07 pm 
Offline
Programming, Design, Admin
User avatar

Joined: Wed Oct 08, 2003 1:33 am
Posts: 12041
Location: Munich
dbenage-cx wrote:
Code:
SortKey = Source.Planet.Happiness
This doesn't make sense. The source object will always be the same, so the sort key will always evaluate to the same result for every object being tested, so nothing will be sorted. You want / need to sort by objects that mach the sampling condition. What you probably want to do is refer to LocalCandiate.Happiness, since the sampling condition matches planets, the objects whose sort keys are calculated will be planets, and when evalulating the sort key on objects that have be matched by the sampling condition, each object can be referred to as the local candidate while the sort key is being evaluated on it.


Top
 Profile  
 
 Post subject: Re: SortedNumberOf
PostPosted: Fri Nov 25, 2016 3:46 am 
Offline
Programmer

Joined: Sun Feb 14, 2016 12:08 am
Posts: 359
Thank you Geoff, in that context it makes more sense ;)


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 3 posts ] 

All times are UTC


Who is online

Users browsing this forum: No registered users and 1 guest


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
Powered by phpBB® Forum Software © phpBB Group