Page 1 of 1

multiple requirement vectors

Posted: Sun Jun 14, 2020 4:25 am
by Dino the Dinosore
In a post from 2015,
http://forum.freeciv.org/f/viewtopic.ph ... iple#p3455
it says -
it's possible to define multiple different requirement vectors for units and buildings, one of which must evaluate to true to be able to build the unit/building.
Is this possible now with 2.6? What would that look like? I'd like to use one for an [extra_canal] in terrain.ruleset. The wiki page -
https://freeciv.fandom.com/wiki/Requirements
only says -
obsolete_by vectors from buildings.ruleset that have "or" logical operation
Does the wiki need updating?

Re: multiple requirement vectors

Posted: Sun Jun 14, 2020 9:39 am
by Ignatus
No, yet the enabling requirement vectors are still one per building or extra. For units, there are only fixed requirements. It's planned to introduce city-performed actions (like "build building" or "build city") in v.3.2 only, there the requirements will go to action enablers that can be multiple. For extras, it possibly will be done in 3.1. But in 2.6, not yet.

Re: multiple requirement vectors

Posted: Mon Jun 15, 2020 9:31 am
by nef
Have a look here to see if this approach does what you want.

If uncertain provide some details here and I will see what I can do.

Re: multiple requirement vectors

Posted: Fri Oct 02, 2020 3:24 am
by Dino the Dinosore
Thanx, nef, that was an approach I hadn't thought of, and was worth a try. What I want to do with having canal extras is to have canals > 1 tile long, I have implemented canals 1 tile long. The problem is that, in the lua script, the only signal I can connect to is turn_started(). The part with iterating over all the map tiles and doing my processing works fine, but the results are a turn behind because, as the wiki "turn" page https://freeciv.fandom.com/wiki/Turn explains, the first thing that happens is
"turn_started" signal (turn, year) is emitted.
then, later, any terrain modifications are done, and those are what I need to test.

So building the Erie Canal will have to wait.

Re: multiple requirement vectors

Posted: Fri Oct 02, 2020 10:42 am
by Ignatus
You may use "pulse" signal. I don't understand it well but likely even in autogames it will work for all but auto-exploring units.

Re: multiple requirement vectors

Posted: Mon Oct 05, 2020 1:06 pm
by nef
In an up coming project, I had the same issue with turn started so I combined it with pulse. Seems to work OK although there was a weird bug with some processing I did with a pulse that occurred before the first turn start. Note: I still use turn start to make sure the processing does actually occur, so there is an inter play between the two call backs.

Re: multiple requirement vectors

Posted: Fri Oct 30, 2020 3:38 am
by Dino the Dinosore
I've shied away from using pulse because I don't know anything about it. The Lua reference manual page doesn't help - can anyone explain how it works or when it happens?

Since my lua script callback routine iterates over the whole map, I worry about a possible performance slowdown if the pulse happens frequently.

Re: multiple requirement vectors

Posted: Fri Oct 30, 2020 4:18 am
by cazfi
Dino the Dinosore wrote:Since my lua script callback routine iterates over the whole map, I worry about a possible performance slowdown if the pulse happens frequently.
Tutorial scenario uses pulse to work around the fact that city dialog is opened only after city founding lua signal is emitted, and thus message dialog opened from the lua script would be left behind the city dialog. The script counts 5 pulses to make sure city dialog has time to open, before sending the message.
Similarly your script could act only on every n:th pulse.

Re: multiple requirement vectors

Posted: Mon Nov 02, 2020 1:08 pm
by nef
My experience is that the pulse occurs about one a second. Perhaps you could use your judgement as to how many to count but you may test the performance. In all my work so far the only performance issue I have had is in producing copious data it the chat log. (A few hundred lines takes a second or two.) You could try the map iterate on each pulse and let us know how it copes.