FreeOrion

Forums for the FreeOrion project
It is currently Sun Dec 17, 2017 4:16 am

All times are UTC




Post new topic Reply to topic  [ 11 posts ] 
Author Message
PostPosted: Wed Jan 25, 2017 9:55 am 
Offline
Dyson Forest

Joined: Tue Sep 30, 2014 10:01 am
Posts: 226
Hi, i tried to print out the species on a planet via the sitrep.

I got me the species from a building using Source.Planet.Species but that killed the effect when using as data for the "species" tag. Using "rawtext" I do not get the Species name, but the id (e.g. 23).
For the species tag I need the species name like e.g. "SP_TRITH".

Shouldnt this return the species instead of the id? Is this a bug?

Can I look up the name from the id in scripting?

_________________
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: Wed Jan 25, 2017 10:53 am 
Offline
Creative Contributor
User avatar

Joined: Fri Jun 28, 2013 11:45 pm
Posts: 3295
I am terrible at remembering how to get sitreps right, I virtually always need help fixing them, but the colony building has
Code:
                        tag = "species" data = "SP_CRAY"
try tag= "species" data = Source.Planet.Species

Beyond that, there are people quite good at bughunting my messes, if you post the entire effectsgroup you're trying to setup someone can sometimes spot a problem, it can be caused by the scope or activation script being off.

_________________
Mat Bowles

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: Wed Jan 25, 2017 12:47 pm 
Offline
Programming, Design, Admin
User avatar

Joined: Wed Oct 08, 2003 1:33 am
Posts: 12045
Location: Munich
MatGB wrote:
...if you post the entire effectsgroup you're trying to setup someone can sometimes spot a problem...
This please. I can't tell from the somewhat vague description what could be happening.


Top
 Profile  
 
PostPosted: Wed Jan 25, 2017 12:58 pm 
Offline
Dyson Forest

Joined: Tue Sep 30, 2014 10:01 am
Posts: 226
Geoff the Medio wrote:
MatGB wrote:
...if you post the entire effectsgroup you're trying to setup someone can sometimes spot a problem...
This please. I can't tell from the somewhat vague description what could be happening.

Sorry :oops: , here you go. If i use species (as below) no message is written out. If I use rawtext instead I get the message "ERROR: Additional effect by species 24"
Code:
        EffectsGroup
            scope = And [
                Object id = Source.PlanetID
                Planet
                OwnedBy empire = Source.Owner
                Species
            ]
            activation = Source
            priority = [[EARLY_PRIORITY]]
            effects = [
                SetEmpireMeter empire = Source.Owner meter = "METER_IMPERIAL_PP_STORAGE_YIELD" value = Value + 0.2
                GenerateSitRepMessage
                    message = "Additional effect by species %rawtext%"
                    label = "EFFECT_BLACKHOLE_LABEL"
                    icon = "icons/building/blackhole.png"
                    parameters = [
                        tag = "rawtext" data = Source.Planet.Species // gibt nummer der species
                    ]
                    empire = Source.Owner
            ]

_________________
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: Wed Jan 25, 2017 2:29 pm 
Offline
Programming, Design, Admin
User avatar

Joined: Wed Oct 08, 2003 1:33 am
Posts: 12045
Location: Munich
There's an option setting to hide sitreps with errors. You should probably turn that off (so they are displayed). That should make the case with the tag = "species" show up. Make sure both the string and the tag are species, not just one...

"Additional effect by species %species%"
tag = "species" data = Source.Planet.Species

The message parameter is looking for a stringtable key, not the actual text to display, which is where the "ERROR" is coming from (the stringtable looking failing), since you've just written out the message instead of putting it in the stringtable as expected. To avoid that, I think you can put

NoStringtableLookup

after the label = line, although I'm not sure if that has any other consequence.

Looks like it's interpreting Source.Planet.Species as an expression that returns an integer, so it's calculating and returning the number 24, then converting that to a string since it's expecting a string reference in the parameter list.

This (interpreting as an integer) makes sense given the order it tries to interpret expressions here:
https://github.com/freeorion/freeorion/ ... 1.cpp#L116

Probably (in C++) either the int expression needs to be renamed to SpeciesID or the species name should be gotten with SpeciesName to avoid the ambiguity.

You can also try forcing it to interpret Source.Planet.Species as a string by writing something like

data = "" + Source.Planet.Species

Not sure if that'll work, but it might.


Top
 Profile  
 
PostPosted: Wed Jan 25, 2017 5:35 pm 
Offline
Dyson Forest

Joined: Tue Sep 30, 2014 10:01 am
Posts: 226
Geoff the Medio wrote:
You can also try forcing it to interpret Source.Planet.Species as a string by writing something like

data = "" + Source.Planet.Species

Not sure if that'll work, but it might.

Not in this case at least:
Code:
default\scripting/buildings\INTERSPECIES_ACADEMY.focs.txt:39:51: Parse error.  E
xpected real number expression here:
                GenerateSitRepMessage
                    message = "Additional effect by species %rawtext%"
                    label = "EFFECT_BLACKHOLE_LABEL"
                    icon = "icons/building/blackhole.png"
                    parameters = [
                        tag = "rawtext" data = ("" + Source.Planet.Species)
                                                   ^
                    ]

_________________
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: Wed Jan 25, 2017 5:45 pm 
Offline
Dyson Forest

Joined: Tue Sep 30, 2014 10:01 am
Posts: 226
Geoff the Medio wrote:
There's an option setting to hide sitreps with errors. You should probably turn that off (so they are displayed). That should make the case with the tag = "species" show up. Make sure both the string and the tag are species, not just one...

Ah thats what "Situation reports with errors" is for :)
Code:
ERROR: Additional effect by species ERROR

Guess that would help a little bit with debugging.

_________________
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: Wed Jan 25, 2017 6:06 pm 
Offline
Creative Contributor
User avatar

Joined: Fri Jun 28, 2013 11:45 pm
Posts: 3295
The ERROR: at the front shows it's an error in the stringtable lookup, you need to put something into the stringtable or tell it to not look things up, the former is easier for most purposes (and we won't accept any PRs that don't use the stringtables).

Open en.txt, find the stringtable keys section and add something like EFFECT_MY_PLANET_SPECIES_THING and put that in place of the text in your script, puttting your text beneath it in the stringtable, that will resolve at least part of the error regardless.

_________________
Mat Bowles

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: Wed Jan 25, 2017 6:38 pm 
Offline
Programming, Design, Admin
User avatar

Joined: Wed Oct 08, 2003 1:33 am
Posts: 12045
Location: Munich
I can't find any place that .Species is used that actually expects an ID number instead of the name. I also can't find in the history when it was added for any context. But I'll just change it to .SpeciesID for the ID number so that .Species should always return the name string.

Edit: Try again after: https://github.com/freeorion/freeorion/ ... ce53a9cd5e


Top
 Profile  
 
PostPosted: Wed Jan 25, 2017 7:34 pm 
Offline
Programmer

Joined: Sun Feb 14, 2016 12:08 am
Posts: 359
Either
Code:
tag = "species" data = Source.Planet.Species

or
Code:
tag = "text" data = Source.Planet.Species

Seems to work great.

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


Top
 Profile  
 
PostPosted: Thu Jan 26, 2017 7:48 pm 
Offline
Dyson Forest

Joined: Tue Sep 30, 2014 10:01 am
Posts: 226
Geoff the Medio wrote:
I can't find any place that .Species is used that actually expects an ID number instead of the name. I also can't find in the history when it was added for any context. But I'll just change it to .SpeciesID for the ID number so that .Species should always return the name string.

Edit: Try again after: https://github.com/freeorion/freeorion/ ... ce53a9cd5e

Verified, works :)

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


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 11 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:  
cron
Powered by phpBB® Forum Software © phpBB Group