multiple requirement vectors

Contribute, display and discuss rulesets and modpacks for use in Freeciv here.
Post Reply
Dino the Dinosore
Hardened
Posts: 171
Joined: Sun Dec 31, 2017 3:41 am

multiple requirement vectors

Post 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?
Ignatus
Elite
Posts: 644
Joined: Mon Nov 06, 2017 12:05 pm
Location: St.Petersburg, Russia
Contact:

Re: multiple requirement vectors

Post 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.
nef
Elite
Posts: 324
Joined: Mon Jun 25, 2018 5:01 pm

Re: multiple requirement vectors

Post 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.
Dino the Dinosore
Hardened
Posts: 171
Joined: Sun Dec 31, 2017 3:41 am

Re: multiple requirement vectors

Post 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.
Ignatus
Elite
Posts: 644
Joined: Mon Nov 06, 2017 12:05 pm
Location: St.Petersburg, Russia
Contact:

Re: multiple requirement vectors

Post 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.
nef
Elite
Posts: 324
Joined: Mon Jun 25, 2018 5:01 pm

Re: multiple requirement vectors

Post 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.
Dino the Dinosore
Hardened
Posts: 171
Joined: Sun Dec 31, 2017 3:41 am

Re: multiple requirement vectors

Post 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.
cazfi
Elite
Posts: 3069
Joined: Tue Jan 29, 2013 6:54 pm

Re: multiple requirement vectors

Post 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.
nef
Elite
Posts: 324
Joined: Mon Jun 25, 2018 5:01 pm

Re: multiple requirement vectors

Post 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.
Post Reply