Page 1 of 1

Why not make all units "actors" capable of "actions" via Lua script? <-- They are by v3.2 some at v3.0 & 1

Posted: Fri Nov 29, 2024 4:15 pm
by Molo_Parko
Why not make all units "actors" capable of "actions" via Lua scripting?

In Lua scripting, a Diplomat is an actor capable of some actions* but not others such as "Fortify", or "Go to". A Settlers unit is not an "actor" despite being capable of "Build City", "Add to City" (below size 8), mining Tiles, irrigating Tiles, "Build road", etcetera, and despite that those actions can be performed by the Settler when directed to do so by a Player rather than a Lua script.

* Diplomat actions: "Establish Embassy", "Investigate City", "Poison City", "Steal Gold", "Sabotage City", "Targeted Sabotage City", "Steal Tech", "Targeted Steal Tech", "Incite City", "Establish Trade Route", "Enter Marketplace", "Help Wonder", "Bribe Unit", "Sabotage Unit".

Even a Diplomat is not capable of some "actions" via Lua scripting such as "Fortify" despite that the unit can be directed to undertake the action "Fortify" by a Player.

Re: Why not make all units "actors" capable of "actions" via Lua script?

Posted: Fri Nov 29, 2024 9:34 pm
by cazfi
freeciv-2.6 was the first version with action enablers, and it started with diplomats. Later versions have been greatly extending the action enablers concept. See https://www.freeciv.org/wiki/NEWS-3.0.0, https://www.freeciv.org/wiki/NEWS-3.1.0, and https://www.freeciv.org/wiki/NEWS-3.2.0

Re: Why not make all units "actors" capable of "actions" via Lua script?

Posted: Fri Nov 29, 2024 9:46 pm
by Molo_Parko
While creating scenarios I was surprised to find that Lua scripting could not direct a unit to do what units can do from the GUI -- Settlers can't "Add to city" from Lua, although that is somewhat resolved in Freeciv 3.3 by the addition of edit.change_city_size(). Lua can't set a goto for a unit such as a Warriors, and can't have a unit Fortify, or Sentry, or Patrol despite that all those actions are possible from the GUI. It greatly limits the use of "scripted events" or "scripted scenes" in scenarios.

Re: Why not make all units "actors" capable of "actions" via Lua script?

Posted: Sat Nov 30, 2024 12:44 am
by cazfi
I think all actions that user can do through UI are already action enabler controlled actions in freeciv-3.1.

Re: Why not make all units "actors" capable of "actions" via Lua script?

Posted: Sat Nov 30, 2024 12:56 am
by cazfi
Molo_Parko wrote: Fri Nov 29, 2024 9:46 pmSettlers can't "Add to city" from Lua, although that is somewhat resolved in Freeciv 3.3 by the addition of edit.change_city_size().
"Add to City" was made an action enabler controlled action already in freeciv-3.0. No need to wait for 3.3 to "partially resolve" it.

Re: Why not make all units "actors" capable of "actions" via Lua script?

Posted: Sat Nov 30, 2024 1:19 am
by cazfi
Just tested the Fortify via lua. This works as expected:

Code: Select all

unit:perform_action(find.action("Fortify"))

Re: Why not make all units "actors" capable of "actions" via Lua script?

Posted: Sat Nov 30, 2024 1:56 am
by Molo_Parko
Hey that's great! I had read the various lists of "action" values at http://freeciv.fandom.com/wiki/Lua_reference_manual and actions such as "Fortify" aren't mentioned there at all, though it does refer to README.actions -- but my copies of that file are of course from Freeciv 2.6.x not 3 so I had no idea the features were already implemented in a newer version.