FreeOrion

Forums for the FreeOrion project
It is currently Tue Jul 17, 2018 4:17 am

All times are UTC




Post new topic Reply to topic  [ 8 posts ] 
Author Message
PostPosted: Sat Jul 07, 2018 8:02 pm 
Offline
Space Krill

Joined: Sat Jul 07, 2018 7:24 pm
Posts: 9
I'm trying to fully understand how EffectsGroup is used.

From what I understood, scope is required and selects the targets that the EffectsGroup will affect.

Looking at focs files I see scope = Source all over the place.
I don't understand what it means when selecting targets...
if it means all targets, then shouldn't scope be optional (keeping all targets when missing, the most common case) or use a truth value?


Top
 Profile  
 
PostPosted: Sat Jul 07, 2018 8:43 pm 
Offline
AI Lead, Programmer
User avatar

Joined: Sat Sep 22, 2012 6:25 pm
Posts: 4679
The Source is always a single object. Which particular object depends on the kind of content the script is specifying. Have you reviewed our Scripting Tutorial and Scripting Details pages? The latter has a section specifically talking about what object serves as the Source for different types of content.

So hopefully that clears up the idea that
Code:
scope=Source
might match all objects. Did you perhaps get mixed up with the fact that the starting set of objects that the scope condition gets applied to is all objects? The scope clause that would just stick with that would be
Code:
scope = All
and while conceivably that could be set as a default scope, I think it was deemed that there are probably not any effects whose proper scope really would be so broad, and so it would be probably useless and even misleading to make that a default scope.

As far as why "scope = Source" wasn't chosen as a default scope, while it is a common choice, I think it was deemed important to have the clarity of always making the scope explicit.

_________________
If I provided any code, scripts or other content here, it's released under GPL 2.0 and CC-BY-SA 3.0


Top
 Profile  
 
PostPosted: Sat Jul 07, 2018 10:13 pm 
Offline
Space Krill

Joined: Sat Jul 07, 2018 7:24 pm
Posts: 9
I did review both of those pages before creating this post, but they did not clarify what 'scope = Source' could match, at least for me (someone that is new to it)...
Maybe it's just a matter of getting used to the syntax, which apparently is non-intuitive to me.

You imply that it does not match all... then does it make the source of the EffectsGroup the only possible target match?


Top
 Profile  
 
PostPosted: Sat Jul 07, 2018 10:55 pm 
Offline
AI Lead, Programmer
User avatar

Joined: Sat Sep 22, 2012 6:25 pm
Posts: 4679
flaviojs wrote:
then does it make the source of the EffectsGroup the only possible target?
Right. The scope is specified by a Condition, and the Condition named "Source" only matches the Source object. I've tried to clarify things a bit more on the Scripting Details page by adding a forward reference to the Conditions section from the section talking about using Source, Target, etc as part of ValueRefs.

_________________
If I provided any code, scripts or other content here, it's released under GPL 2.0 and CC-BY-SA 3.0


Top
 Profile  
 
PostPosted: Sun Jul 08, 2018 2:40 pm 
Offline
Space Krill

Joined: Sat Jul 07, 2018 7:24 pm
Posts: 9
Thank you.

This is probably only helpful to beginners, but I just realized it becomes easier to figure out if I try to read it with human language...
"activation" can be read as "is active/enabled when the source is ..."
"scope" can be read as "the targets are ..."

I paid more attention to the EffectsGroup Specification before creating this post, so maybe put a note there?


Top
 Profile  
 
PostPosted: Sun Jul 08, 2018 4:44 pm 
Offline
AI Lead, Programmer
User avatar

Joined: Sat Sep 22, 2012 6:25 pm
Posts: 4679
flaviojs wrote:
so maybe put a note there?
I've made a few adjustments there now.

_________________
If I provided any code, scripts or other content here, it's released under GPL 2.0 and CC-BY-SA 3.0


Top
 Profile  
 
PostPosted: Sun Jul 08, 2018 8:36 pm 
Offline
Vacuum Dragon

Joined: Tue Sep 30, 2014 10:01 am
Posts: 504
Dilvish wrote:
flaviojs wrote:
so maybe put a note there?
I've made a few adjustments there now.

How about something like the following
Code:
  description = "DESCRIPTION" [optional -- may be left out]
  scope = CONDITION [defines targets to apply effects for]
  activation = CONDITION [optional condition on Source -- omission defaults to always trigger effects]
  stackinggroup = "STACKINGGROUP" [optional -- may be left out]
  accountinglabel = "ACCOUNTINGLABEL" [optional -- may be left out]
  priority = PRIORITY [optional -- omission defaults to 100]
  effects = {EFFECT|[
      EFFECT
      EFFECT
      EFFECT
  ]}

_________________
Any code or patches in anything posted here is released under the CC and GPL licences in use for the FO project.


Top
 Profile  
 
PostPosted: Sun Jul 08, 2018 11:25 pm 
Offline
AI Lead, Programmer
User avatar

Joined: Sat Sep 22, 2012 6:25 pm
Posts: 4679
Quote:
How about something like the following

Since the syntax already has a functional use for square brackets, I'm not a fan of trying to use them to indicate comments, I'd much rather see comments simply set off by \\

_________________
If I provided any code, scripts or other content here, it's released under GPL 2.0 and CC-BY-SA 3.0


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

All times are UTC


Who is online

Users browsing this forum: No registered users and 0 guests


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