some questions about ruleset development, some specific to the master branch of freeciv

Contribute, display and discuss rulesets and modpacks for use in Freeciv here.
eldritch_cookie
Posts: 22
Joined: Sat Mar 05, 2022 6:41 pm

some questions about ruleset development, some specific to the master branch of freeciv

Post by eldritch_cookie »

i am developing a ruleset, as i have specific needs to my ruleset and i am planning to contribute code i am doing so on the master branch. i found and am expecting some problems that there may be solutions to and i have a few questions.

firstly my ruleset has a few tech trees but none of them are available to all nations but there are somethings i want to make available to all nations through research, in the case of things like governments for which i can't have multiple requirement vectors i have decided to create a unresearchable tech which is given to a nation through scripting when they get any of a list of techs. is there a better way? preferably one which doesn't use a limited ruleset resource, i thought of some alternatives but they all used something which has a limit lower than 250 of techs.

What is the parser.lua file for? Is it related to the luadata file? what are the planned use cases for a luadata file?

is there a limit to the number of effects, if yes how many? and if not, could we make techs also not have a limit?

the user effects are attached to what? according to the lua reference page on the wiki it is possible to acquire effect values for the world, for a player and for a city. Does that mean that tile or units requirements user effects are useless?if not, how do i use them?

regarding lua which builtins are available? i would like a list of all of them if possible.

how do i split lua code? if i want to have multiple files for lua scripting how would i go about doing that?

how can i control how often a extra appears if it isn't a resource?
Ignatus
Elite
Posts: 644
Joined: Mon Nov 06, 2017 12:05 pm
Location: St.Petersburg, Russia
Contact:

Re: some questions about ruleset development, some specific to the master branch of freeciv

Post by Ignatus »

eldritch_cookie wrote: Mon Jul 11, 2022 6:44 pm the user effects are attached to what? according to the lua reference page on the wiki it is possible to acquire effect values for the world, for a player and for a city. Does that mean that tile or units requirements user effects are useless?if not, how do i use them?
The user effects are checked by "effects" Lua module functions that just don't yet support local range testing. Recently you got the ability to make user effects valuable for AI, there they can be applied locally.
regarding lua which builtins are available? i would like a list of all of them if possible.
If you mean parts of standard Lua library, you get almost all basic modules except ones that access filesystem. Alas, the latter include "require". About Freeciv-specific stuff, you can read in Wikia, but for master it sometimes evolves.
how do i split lua code? if i want to have multiple files for lua scripting how would i go about doing that?
Put some "lua file myruleset/myfile.lua" lines into your ruleset starter file below the "rulesetdir myruleset" line.
nef
Elite
Posts: 324
Joined: Mon Jun 25, 2018 5:01 pm

Re: some questions about ruleset development, some specific to the master branch of freeciv

Post by nef »

firstly my ruleset has a few tech trees but none of them are available to all nations but there are somethings i want to make available to all nations through research, in the case of things like governments for which i can't have multiple requirement vectors i have decided to create a unresearchable tech which is given to a nation through scripting when they get any of a list of techs. is there a better way? preferably one which doesn't use a limited ruleset resource, i thought of some alternatives but they all used something which has a limit lower than 250 of techs.

Some ideas to consider:
a. you may be able to use root_req`s to 'interlace' the tech trees so that the gov techs are common to all trees
b. you may be able to use exclusion lists for requirements (i.e. not present for gov`s not wanted). See the civ2civ3 ruleset (especially effects) for examples that actually are about government.
c. your own approach but there is the problem if you need to know more than one prereq. and that is that tolua does not support any direct means of determining what techs are currently known by a player. One can remember them in a table as each one is researched but the distro version of _freeciv_state_dump does not remember tables across save/restore. Use this version or a 'scalar' as is done in the MP ruleset.
the user effects are attached to what? according to the lua reference page on the wiki it is possible to acquire effect values for the world, for a player and for a city. Does that mean that tile or units requirements user effects are useless?
Yes, and you also need to be careful with the actual scope of some effects: some that appear to be of city scope are actually player.
regarding lua which builtins are available? i would like a list of all of them if possible.
Not clear what you mean here; the wiki page you refer to has a list that is mostly complete. If you find it`s difficult to use I have an alternative that is organised differently and is designed to be used in an editor that has language support for 'secfile' format (e.g. .ini). If you want to try it ask and I will upload what I currently have. To get a accurate list of Lua and tolua functions (etc.) you can use this alternative to listenv
how do i split lua code? if i want to have multiple files for lua scripting how would i go about doing that?
Lua has facilities such as dofile (& friends) but they are not currently offered in fc (for reasons that appear to be entirely bogus.) If the split code is to be used just once (during startup) you can load a Lua script from a server command which can be placed in the .serv file used to start your ruleset. Note that this script is NOT run on a restore (but you may be able to use the alternative _freeciv_state_dump for tables (and signals)
how can i control how often a extra appears if it isn't a resource?
Are you talking about extras like huts and rivers that are created by mapgen? The former has a server option.

Sorry about some duplication here; ignatus got his reply in while I was preparing mine.
eldritch_cookie
Posts: 22
Joined: Sat Mar 05, 2022 6:41 pm

Re: some questions about ruleset development, some specific to the master branch of freeciv

Post by eldritch_cookie »

Ignatus wrote: Tue Jul 12, 2022 5:34 am Put some "lua file myruleset/myfile.lua" lines into your ruleset starter file below the "rulesetdir myruleset" line.
if i do that would i be able to refer to a function in another file? for instance if i have doX in default.lua that calls doY but doY is in myruleset/myfile.lua, what would happen?
eldritch_cookie
Posts: 22
Joined: Sat Mar 05, 2022 6:41 pm

Re: some questions about ruleset development, some specific to the master branch of freeciv

Post by eldritch_cookie »

nef wrote: Tue Jul 12, 2022 6:06 am
firstly my ruleset has a few tech trees but none of them are available to all nations but there are somethings i want to make available to all nations through research, in the case of things like governments for which i can't have multiple requirement vectors i have decided to create a unresearchable tech which is given to a nation through scripting when they get any of a list of techs. is there a better way? preferably one which doesn't use a limited ruleset resource, i thought of some alternatives but they all used something which has a limit lower than 250 of techs.

Some ideas to consider:
a. you may be able to use root_req`s to 'interlace' the tech trees so that the gov techs are common to all trees
b. you may be able to use exclusion lists for requirements (i.e. not present for gov`s not wanted). See the civ2civ3 ruleset (especially effects) for examples that actually are about government.
c. your own approach but there is the problem if you need to know more than one prereq. and that is that tolua does not support any direct means of determining what techs are currently known by a player. One can remember them in a table as each one is researched but the distro version of _freeciv_state_dump does not remember tables across save/restore. Use this version or a 'scalar' as is done in the MP ruleset.
the user effects are attached to what? according to the lua reference page on the wiki it is possible to acquire effect values for the world, for a player and for a city. Does that mean that tile or units requirements user effects are useless?
Yes, and you also need to be careful with the actual scope of some effects: some that appear to be of city scope are actually player.
regarding lua which builtins are available? i would like a list of all of them if possible.
Not clear what you mean here; the wiki page you refer to has a list that is mostly complete. If you find it`s difficult to use I have an alternative that is organised differently and is designed to be used in an editor that has language support for 'secfile' format (e.g. .ini). If you want to try it ask and I will upload what I currently have. To get a accurate list of Lua and tolua functions (etc.) you can use this alternative to listenv
how do i split lua code? if i want to have multiple files for lua scripting how would i go about doing that?
Lua has facilities such as dofile (& friends) but they are not currently offered in fc (for reasons that appear to be entirely bogus.) If the split code is to be used just once (during startup) you can load a Lua script from a server command which can be placed in the .serv file used to start your ruleset. Note that this script is NOT run on a restore (but you may be able to use the alternative _freeciv_state_dump for tables (and signals)
how can i control how often a extra appears if it isn't a resource?
Are you talking about extras like huts and rivers that are created by mapgen? The former has a server option.

Sorry about some duplication here; ignatus got his reply in while I was preparing mine.
about the extras i don't know if it has that functionality in 3.0 but in master(currently 3.2 pre-alpha) all things which belong to a tile which aren't a unit or a city are an extra this extra has a lot of important things like which graphic to use and how it appears, resources have a cause property equal to resource and a linked resource section, they are generated automatically on map creation, i can add hut to the cause property but that causes the extra to be generated too infrequently hence my question, i don't want to have it be a resource because by themself they shouldn't add anything to production and i want them to be generated in all terrains so if i add them as resources i would need to add 12 extras to each terrain, i currently have 2 extras per terrain. i tried to add them to the terrains without adding them as resources and that caused a immediate segmentation fault
Ignatus
Elite
Posts: 644
Joined: Mon Nov 06, 2017 12:05 pm
Location: St.Petersburg, Russia
Contact:

Re: some questions about ruleset development, some specific to the master branch of freeciv

Post by Ignatus »

eldritch_cookie wrote: Tue Jul 12, 2022 11:43 am
Ignatus wrote: Tue Jul 12, 2022 5:34 am Put some "lua file myruleset/myfile.lua" lines into your ruleset starter file below the "rulesetdir myruleset" line.
if i do that would i be able to refer to a function in another file? for instance if i have doX in default.lua that calls doY but doY is in myruleset/myfile.lua, what would happen?
All Lua scripts (except some you don't need here) use the same _G space; Lua instance on server is reset when you load a ruleset. So the last declared function fires. The signals have other rules as described in the manual.
cazfi
Elite
Posts: 3077
Joined: Tue Jan 29, 2013 6:54 pm

Re: some questions about ruleset development, some specific to the master branch of freeciv

Post by cazfi »

Sounds like you are trying to get map generator to place some extra that is not really a type of extra that the map generator is supposed to place (i.e. you're setting "cause" that is not accurate). Likely you should be placing those extras by your own lua script of the 'map_generated' signal.
cazfi
Elite
Posts: 3077
Joined: Tue Jan 29, 2013 6:54 pm

Re: some questions about ruleset development, some specific to the master branch of freeciv

Post by cazfi »

eldritch_cookie wrote: Tue Jul 12, 2022 11:56 am i tried to add them to the terrains without adding them as resources and that caused a immediate segmentation fault
What do you mean by "add them to the terrains without adding them as resources"? In any case, a segfault is a bug, so please report -> https://osdn.net/ticket/newticket.php?group_id=12505
cazfi
Elite
Posts: 3077
Joined: Tue Jan 29, 2013 6:54 pm

Re: some questions about ruleset development, some specific to the master branch of freeciv

Post by cazfi »

eldritch_cookie wrote: Tue Jul 12, 2022 11:56 ami can add hut to the cause property but that causes the extra to be generated too infrequently
Like nef already said, there's the huts server option.

Code: Select all

> explain huts
Option: huts  -  Amount of huts (bonus extras)
Description:
  Huts are tile extras that usually may be investigated by units.The
  server variable's scale is huts per thousand tiles.
Status: changeable
Value: 15, Minimum: 0, Default: 15, Maximum: 500
eldritch_cookie
Posts: 22
Joined: Sat Mar 05, 2022 6:41 pm

Re: some questions about ruleset development, some specific to the master branch of freeciv

Post by eldritch_cookie »

cazfi wrote: Thu Jul 14, 2022 2:33 am
eldritch_cookie wrote: Tue Jul 12, 2022 11:56 am i tried to add them to the terrains without adding them as resources and that caused a immediate segmentation fault
What do you mean by "add them to the terrains without adding them as resources"? In any case, a segfault is a bug, so please report -> https://osdn.net/ticket/newticket.php?group_id=12505
should i report any time that i get a segmentation fault instead of a error as a bug? that happens constantly,and i am using the latest master so i thought that was expected.
Post Reply