Page 1 of 1

Freeciv Lua reference manual online - turn_begin

Posted: Sat Oct 14, 2023 7:06 pm
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.

Re: Freeciv Lua reference manual online - turn_begin

Posted: Sat Oct 14, 2023 9:48 pm
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"

Re: Freeciv Lua reference manual online - turn_begin

Posted: Sat Oct 14, 2023 11:02 pm
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.

Re: Freeciv Lua reference manual online - turn_begin

Posted: Sun Oct 15, 2023 8:05 am
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.

Re: Freeciv Lua reference manual online - turn_begin

Posted: Sun Oct 15, 2023 2:38 pm
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.

Re: Freeciv Lua reference manual online - turn_begin

Posted: Sun Oct 15, 2023 3:29 pm
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)

Re: Freeciv Lua reference manual online - turn_begin

Posted: Sun Oct 15, 2023 3:31 pm
by Molo_Parko
Ahh, got it! Thank you again, that will save me from some future headaches.

Re: Freeciv Lua reference manual online - turn_begin

Posted: Wed Mar 06, 2024 1:05 pm
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?