Building requirement(s): is it possible to have a OR b?
Building requirement(s): is it possible to have a OR b?
In buildings.ruleset there is a building requirement field that contains a standard requirement vector. The requirement vector can have more requirements that are in an AND relationship: they all have to be fulfilled for the vector to be positive. Is it possible to have more requirements, and that EITHER needs to be fulfilled in order to construct the building?
When it comes to Effects, it's relatively simple: simple create more effects. But buildings in building.ruleset have only one requirement field.
Any ideas?
When it comes to Effects, it's relatively simple: simple create more effects. But buildings in building.ruleset have only one requirement field.
Any ideas?
--
* Freeciv LongTurn, a community of one-turn-per-day players and developers
* LongTurn Blog - information nexus with stuff and stuff and stuff
* Longturn Discord server; real-time chatting, discussing, quarrelling, trolling, gaslighting...
* Freeciv LongTurn, a community of one-turn-per-day players and developers
* LongTurn Blog - information nexus with stuff and stuff and stuff
* Longturn Discord server; real-time chatting, discussing, quarrelling, trolling, gaslighting...
Re: Building requirement(s): is it possible to have a OR b?
In the future, building requirements will be replaced by city-performed action enablers that may be multiple. Currently, they are not, alas. Try using negative requirements (not A and not B <=> not (A or B)). Try playing with obsoletion requirements (they ar or-ed).
Re: Building requirement(s): is it possible to have a OR b?
But I guess there are no double negative requirements, right? _nreq_ is removed form 3.0, correct?
What I wanted was for a city to be able to build a Factory if there is the tech present (Industrialzation) OR if it is connected to a foreign city with a traderoute and thas city also has a Factory.
I haven't checked, but putting two vectors in the same field probably wouldn't work, right? Something like
reqs =
{ 1st set
}
{2nd set
}
What I wanted was for a city to be able to build a Factory if there is the tech present (Industrialzation) OR if it is connected to a foreign city with a traderoute and thas city also has a Factory.
I haven't checked, but putting two vectors in the same field probably wouldn't work, right? Something like
reqs =
{ 1st set
}
{2nd set
}
--
* Freeciv LongTurn, a community of one-turn-per-day players and developers
* LongTurn Blog - information nexus with stuff and stuff and stuff
* Longturn Discord server; real-time chatting, discussing, quarrelling, trolling, gaslighting...
* Freeciv LongTurn, a community of one-turn-per-day players and developers
* LongTurn Blog - information nexus with stuff and stuff and stuff
* Longturn Discord server; real-time chatting, discussing, quarrelling, trolling, gaslighting...
-
- Hardened
- Posts: 171
- Joined: Sun Dec 31, 2017 3:41 am
Re: Building requirement(s): is it possible to have a OR b?
I have a similar problem in terrain.ruleset with adding a canal extra. I would like it to be enabled with either an oceanic OR river tile adjacent, but that does not seem possible currently. I've tried some workarounds that are not entirely satisfactory.
-
- Hardened
- Posts: 171
- Joined: Sun Dec 31, 2017 3:41 am
Re: Building requirement(s): is it possible to have a OR b?
I tried that and it didn't work. Having _nreq_ and (not A and not B <=> not (A or B)) might be worth trying.I haven't checked, but putting two vectors in the same field probably wouldn't work, right? Something like
reqs =
{ 1st set
}
{2nd set
}
Re: Building requirement(s): is it possible to have a OR b?
Have you tried that by introducing two separate extras "Canal from Ocean" and "Canal from River" set to conflict with each other so that one does not build both to the same tile?Dino the Dinosore wrote:I have a similar problem in terrain.ruleset with adding a canal extra. I would like it to be enabled with either an oceanic OR river tile adjacent, but that does not seem possible currently. I've tried some workarounds that are not entirely satisfactory.
Re: Building requirement(s): is it possible to have a OR b?
There is no support for ORed requirements. To mitigate the problem, there are a couple of concepts that work in some common cases:
- There can be multiple effects doing the same thing but with different requirements
- There can be multiple action enablers enabling the same thing but with different requirements
- Many ruleset types have "user flags" that one can require instead of "object A or object B", but that helps only when you want to work within same ruleset type (you can't mix terrain and extra requirements for example).
I have vague ideas (freeciv-3.2 at earliest) about extending the last point so that e.g. terrain and extra could provide conceptually same flag, that one could then require.
- There can be multiple effects doing the same thing but with different requirements
- There can be multiple action enablers enabling the same thing but with different requirements
- Many ruleset types have "user flags" that one can require instead of "object A or object B", but that helps only when you want to work within same ruleset type (you can't mix terrain and extra requirements for example).
I have vague ideas (freeciv-3.2 at earliest) about extending the last point so that e.g. terrain and extra could provide conceptually same flag, that one could then require.
Re: Building requirement(s): is it possible to have a OR b?
It never worked since nreqs were OR-ed. So are obsoleted_by; they may be negated individually.Dino the Dinosore wrote:I tried that and it didn't work. Having _nreq_ and (not A and not B <=> not (A or B)) might be worth trying.
Currently possible kludge is adding/removing an extra with "AutoOnCityTile" flag and Lua callbacks, and require this extra (or maybe a flag of several extras). But there is a lot of callbacks to write, and I even can't be sure we have API for all the cases we need here (basically, the callbacks are action_started_unit_city, city_destroyed, building_lost, city_transferred, and turn_begin to remove possibility for factories that were enabled by trade route...).Corbeau wrote:What I wanted was for a city to be able to build a Factory if there is the tech present (Industrialzation) OR if it is connected to a foreign city with a traderoute and thas city also has a Factory.
Re: Building requirement(s): is it possible to have a OR b?
We have some custom effects, maybe as a generic solution we can make a requirement like "EffectValueMin", "User_Effect_1:1", "Local"?cazfi wrote:I have vague ideas (freeciv-3.2 at earliest) about extending the last point so that e.g. terrain and extra could provide conceptually same flag, that one could then require.
-
- Hardened
- Posts: 171
- Joined: Sun Dec 31, 2017 3:41 am
Re: Building requirement(s): is it possible to have a OR b?
I did try something like that. It sort of works but has 2 problems.#1 the user sees 2 different names for what is the same tile special (with the same graphics). #2 The 2 different extra names don't get their graphics connected the way they should. I set them to "integrates = " with each other, and in the file sandbox/terrain.ruleset it says -Dino the Dinosore wrote:
I have a similar problem in terrain.ruleset with adding a canal extra. I would like it to be enabled with either an oceanic OR river tile adjacent, but that does not seem possible currently. I've tried some workarounds that are not entirely satisfactory.
Have you tried that by introducing two separate extras "Canal from Ocean" and "Canal from River" set to conflict with each other so that one does not build both to the same tile?
which implies the connected graphics should work. Maybe this is a bug?; integrates = list of road types that are suitable next steps
; for travel from this road type; such steps are
; possible for units native to both roads and don`t
; get cost from underlying terrain; graphics are
; drawn accordingly
Another thought I had is for a lua script to iterate over every tile in the world, placing a flag on lowland tiles next to an ocean or river. But there's no edit.create_tile_flag(). And a tile could get transformed.
If an extra's flags could include a terrain flag - that would do it. But they seem to be separate name spaces.