multiple requirement vectors

Contribute, display and discuss rulesets and modpacks for use in Freeciv here.
User avatar
Dino the Dinosore
Veteran
Posts: 87
Joined: Sun Dec 31, 2017 3:41 am

multiple requirement vectors

Postby Dino the Dinosore » Sun Jun 14, 2020 4:25 am

In a post from 2015,
http://forum.freeciv.org/f/viewtopic.php?f=13&t=551&p=3274&hilit=reqs+multiple#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?

Ignatus
Elite
Posts: 482
Joined: Mon Nov 06, 2017 12:05 pm
Location: St.Petersburg, Russia
Contact:

Re: multiple requirement vectors

Postby Ignatus » Sun Jun 14, 2020 9:39 am

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.

nef
Hardened
Posts: 244
Joined: Mon Jun 25, 2018 5:01 pm

Re: multiple requirement vectors

Postby nef » Mon Jun 15, 2020 9:31 am

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.

User avatar
Dino the Dinosore
Veteran
Posts: 87
Joined: Sun Dec 31, 2017 3:41 am

Re: multiple requirement vectors

Postby Dino the Dinosore » Fri Oct 02, 2020 3:24 am

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.

Ignatus
Elite
Posts: 482
Joined: Mon Nov 06, 2017 12:05 pm
Location: St.Petersburg, Russia
Contact:

Re: multiple requirement vectors

Postby Ignatus » Fri Oct 02, 2020 10:42 am

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.

nef
Hardened
Posts: 244
Joined: Mon Jun 25, 2018 5:01 pm

Re: multiple requirement vectors

Postby nef » Mon Oct 05, 2020 1:06 pm

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.

User avatar
Dino the Dinosore
Veteran
Posts: 87
Joined: Sun Dec 31, 2017 3:41 am

Re: multiple requirement vectors

Postby Dino the Dinosore » Fri Oct 30, 2020 3:38 am

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.

cazfi
Elite
Posts: 1971
Joined: Tue Jan 29, 2013 6:54 pm

Re: multiple requirement vectors

Postby cazfi » Fri Oct 30, 2020 4:18 am

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.

nef
Hardened
Posts: 244
Joined: Mon Jun 25, 2018 5:01 pm

Re: multiple requirement vectors

Postby nef » Mon Nov 02, 2020 1:08 pm

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.