Freeciv Lua reference manual online - turn_begin

Various topics about the game, the website, or anything else Freeciv related that doesn't fit elsewhere.
Post Reply
Molo_Parko
Hardened
Posts: 158
Joined: Fri Jul 02, 2021 4:00 pm

Freeciv Lua reference manual online - turn_begin

Post by Molo_Parko »

In regards to the Freeciv Lua reference manual at: http://freeciv.fandom.com/wiki/Lua_reference_manual

The event "turn_begin" is shown as having been introduced in Freeciv 3, which is why I didn't use that and instead used "turn_started" since I run Freeciv 2.6.4, however when I tried "turn_begin", I found that it does work in Freeciv 2.6.4 without error.
cazfi
Elite
Posts: 3111
Joined: Tue Jan 29, 2013 6:54 pm

Re: Freeciv Lua reference manual online - turn_begin

Post by cazfi »

I checked current S2_6 sources, and no, there's no turn_begin there.

Where you've got your freeciv? If you have not compiled it yourself (from freeciv.org sources), maybe the distributor has backported "turn_begin"
Molo_Parko
Hardened
Posts: 158
Joined: Fri Jul 02, 2021 4:00 pm

Re: Freeciv Lua reference manual online - turn_begin

Post by Molo_Parko »

This in regarding your post at this link: http://forum.freeciv.org/f/viewtopic.php?p=108824
cazfi wrote: Sat Oct 14, 2023 5:23 pm Loaded these 7 scenarios with "--warnings" to freeciv-3.0, and the only notable warning was about lua signal deprecated in 3.0 in two of them. But as long as you want to keep these compatible with 2.6 too, can't really fix that.

Code: Select all

2: Deprecated: lua signal "turn_started", deprecated since "3.0", used. Use "turn_begin" instead
^ I changed the only occurrence of "turn_started" to "turn_begin" and it worked. After reading your last message, I changed it again to "lost_weekend", and that also worked. So it isn't that turn_begin is recognized by Freeciv 2.6.4, but rather that 2.6.4 doesn't error or complain regardless of what I use there. The script still runs successfully with either turn_begin or turn_started.
end
signal.connect('lost_weekend', 'turn_callback')
$
vars=$
^ That worked. So did turn_begin, and so did turn_started.
cazfi
Elite
Posts: 3111
Joined: Tue Jan 29, 2013 6:54 pm

Re: Freeciv Lua reference manual online - turn_begin

Post by cazfi »

Ok. So when you said "worked", it didn't mean that the functionality is there.

Yeah, it's not an error to connect to a signal that is not currently not defined. Not sure if we could make it an error - at least (AFAIK) there's no mechanism for user to define their own signals, so it shouldn't be like that we have to be prepared for signals appearing later.
Molo_Parko
Hardened
Posts: 158
Joined: Fri Jul 02, 2021 4:00 pm

Re: Freeciv Lua reference manual online - turn_begin

Post by Molo_Parko »

Yes, thank you. As for the error "turn_started", deprecated since "3.0" the easy fix is to use turn_begin since it isn't an error in 2.6.4 and is thus still compatible, and will avoid the 3.0 error message.
cazfi
Elite
Posts: 3111
Joined: Tue Jan 29, 2013 6:54 pm

Re: Freeciv Lua reference manual online - turn_begin

Post by cazfi »

Molo_Parko wrote: Sun Oct 15, 2023 2:38 pm Yes, thank you. As for the error "turn_started", deprecated since "3.0" the easy fix is to use turn_begin since it isn't an error in 2.6.4 and is thus still compatible, and will avoid the 3.0 error message.
Well, you are never receiving that signal in 2.6. That's leaving some scenario functionality out from 2.6.

If you want the scenario to work both on 2.6 and 3.0 (and all the way to current development version), you should actually keep on using turn_started. It's deprecated, but not yet obsoleted, and gives only a warning (not an error), and even that warning appears only with deprecation --warnings enabled (in practice; not to end-users, but only to people who really want to check such warnings)
Molo_Parko
Hardened
Posts: 158
Joined: Fri Jul 02, 2021 4:00 pm

Re: Freeciv Lua reference manual online - turn_begin

Post by Molo_Parko »

Ahh, got it! Thank you again, that will save me from some future headaches.
Batesaneva
Posts: 1
Joined: Tue Mar 05, 2024 6:10 am
Contact:

Re: Freeciv Lua reference manual online - turn_begin

Post by Batesaneva »

Was the usage of "turn_begin" in Freeciv 2.6.4 merely accepted without causing an error, or did it actually provide the intended functionality?
:)
Post Reply