StatisticCount & Python

Creation, discussion, and balancing of game content such as techs, buildings, ship parts.

Moderators: Oberlus, Committer

Post Reply
Message
Author
User avatar
drkosy
Space Dragon
Posts: 367
Joined: Sat Jul 11, 2020 9:41 am

StatisticCount & Python

#1 Post by drkosy »

I like to change some Techs for my mod. I tried to implement

Code: Select all

PLANETS_OWNED_BY_EMPIRE = StatisticCount(float, condition = Planet() & OwnedBy(empire=Source.Owner) & TargetPopulation(low=0.1) ),
But the log says:

Code: Select all

TypeError: unsupported operand type(s) for &: 'Boost.Python.function' and 'Condition'
Is StatisticCount already implemented in the Python File Management? If so, I would be glad to learn the right syntax :)
Want some fresh experience? Try Kosymod

o01eg
Programmer
Posts: 2004
Joined: Sat Dec 10, 2011 5:46 am

Re: StatisticCount & Python

#2 Post by o01eg »

drkosy wrote: Tue Nov 29, 2022 6:21 pm I like to change some Techs for my mod. I tried to implement

Code: Select all

PLANETS_OWNED_BY_EMPIRE = StatisticCount(float, condition = Planet() & OwnedBy(empire=Source.Owner) & TargetPopulation(low=0.1) ),
But the log says:

Code: Select all

TypeError: unsupported operand type(s) for &: 'Boost.Python.function' and 'Condition'
Is StatisticCount already implemented in the Python File Management? If so, I would be glad to learn the right syntax :)
Syntax is correct. Is TypeError happened at that line? I would expect this error if you write

Code: Select all

Planet & OwnedBy(...)
Gentoo Linux x64, gcc-11.2, boost-1.78.0
Ubuntu Server 22.04 x64, gcc-12, boost-1.74.0
Welcome to the slow multiplayer game at freeorion-lt.dedyn.io.Version 2024-03-15.b3de094.
Donations're welcome:BTC:bc1q007qldm6eppqcukewtfkfcj0naut9njj7audnm

User avatar
drkosy
Space Dragon
Posts: 367
Joined: Sat Jul 11, 2020 9:41 am

Re: StatisticCount & Python

#3 Post by drkosy »

Thanks for the quick reply!
I managed to get the line mentioned above parse well. But now I get an error on the referenced line:

Code: Select all

SetTargetIndustry( value = Value + MaxOf(float, 2.0, 0.1 * Target.Population - 0.1 * PLANETS_OWNED_BY_EMPIRE) * StatisticIf(float, condition=EmpireHasAdoptedPolicy(empire=Source.Owner, name = "PLC_METROPOLES"))),
Gives:

Code: Select all

[error] client : PythonCommon.cpp:101 : TypeError: can't multiply sequence by non-int of type 'float'
If I replace "PLANETS_OWNED_BY_EMPIRE" by a number (e.g. 5) the parser error is gone. I guess my way of reference is wrong or the StatisticCount doesn't return a number :?:
Want some fresh experience? Try Kosymod

o01eg
Programmer
Posts: 2004
Joined: Sat Dec 10, 2011 5:46 am

Re: StatisticCount & Python

#4 Post by o01eg »

drkosy wrote: Wed Nov 30, 2022 7:17 pm If I replace "PLANETS_OWNED_BY_EMPIRE" by a number (e.g. 5) the parser error is gone. I guess my way of reference is wrong or the StatisticCount doesn't return a number :?:
I suppose comma at the end of PLANETS_OWNED_BY_EMPIRE make it sequence instead of integer value reference.
Gentoo Linux x64, gcc-11.2, boost-1.78.0
Ubuntu Server 22.04 x64, gcc-12, boost-1.74.0
Welcome to the slow multiplayer game at freeorion-lt.dedyn.io.Version 2024-03-15.b3de094.
Donations're welcome:BTC:bc1q007qldm6eppqcukewtfkfcj0naut9njj7audnm

User avatar
drkosy
Space Dragon
Posts: 367
Joined: Sat Jul 11, 2020 9:41 am

Re: StatisticCount & Python

#5 Post by drkosy »

Many thanks :) That actually did the trick!
Want some fresh experience? Try Kosymod

Post Reply