Latest Posts

Topic: Lua, immovable attributes

kaputtnik
Avatar
Topic Opener
Joined: 2013-02-18, 19:48
Posts: 2439
OS: Archlinux
Version: current master
Ranking
One Elder of Players
Location: Germany
Posted at: 2023-03-05, 15:34

I am trying to add the internal names of immovables to the editor help. I ran into difficulties for the trees: In the editor there is the old tree of each type shown. If i want to show the internal names of all related trees from sapling to mature i need to add some other functionality to the script. I have a working solution, but it makes heavy use of string manipulation (splitting, joining). That is split e.g. aspen_summer_old to aspen_summer and find all immovable which starts with this string. I think make use of attributes makes this a lot easier: If i add the attribute aspen_summer to all register.lua files of this tree, i can just use immovable:has_attribute("aspen_summer") to get all trees of this specific type (without doing heavy string things).

Now i want to add this information (internal names) to the rocks. Because rocks are all over the same (except the images) the idea is to have only 6 rocks, sorted by size, on the left side of editor help and put other information to the right side. If i add the attribute "help_rocks" to the register.lua files of rocks/blackland/[1to6]/register.lua i can just use immovable:has_attribute("help_rocks") to get only those rocks for the left side of the editor help. Then i can add additional attributes help_rocks[1-6] to some of the other rocks to get the entries for the right side of the editor help.

Is this a way to go, or are the attributes reserved for other things? I fear using those attributes for all kind of stuff may makes using them errorprone.

Edited: 2023-03-05, 15:36

Attachment:
editor_internal_help.jpg

Fight simulator for Widelands:
https://wide-fighter.netlify.app/

Top Quote
hessenfarmer
Avatar
Joined: 2014-12-11, 22:16
Posts: 2648
Ranking
One Elder of Players
Location: Bavaria
Posted at: 2023-03-05, 19:52

may I ask first why you want to have these internal names in the editor help?


Top Quote
kaputtnik
Avatar
Topic Opener
Joined: 2013-02-18, 19:48
Posts: 2439
OS: Archlinux
Version: current master
Ranking
One Elder of Players
Location: Germany
Posted at: 2023-03-06, 07:24

Feels like those internal names are somewhat a secret which must be hidden to the user face-grin.png I think it's tedious to always use a file explorer and go through all folders (if one knows where they are) and then open an init.lua in an editor to the find the internal names.

I would insert the internal names just below all other information.


Attachment:
internal_1.jpg

Fight simulator for Widelands:
https://wide-fighter.netlify.app/

Top Quote
hessenfarmer
Avatar
Joined: 2014-12-11, 22:16
Posts: 2648
Ranking
One Elder of Players
Location: Bavaria
Posted at: 2023-03-06, 20:12

Well, I can't see any other usage of the internal names other then editing some lua files. Which is a developer task anyway (no matter if for the main game or an addon). So I really don't see why bothering a user (up to a mapeditor) with that kind of information, as it is not needed anywhere in the game or in the editor.

So unless you can give me a use case for a normal user where it would be helpful to have such information, I am against such changes to the register files.


Top Quote
kaputtnik
Avatar
Topic Opener
Joined: 2013-02-18, 19:48
Posts: 2439
OS: Archlinux
Version: current master
Ranking
One Elder of Players
Location: Germany
Posted at: 2023-03-07, 08:39

Here is someone looking for a tool to add/change fish resources. And here a tool for exchange one terrain with another is asked for.

All in all it does not harm to have the internal names in the editor help. And i don't think it will bother a map editor. Moreover having those internal names in the editor help can awake interest to try out lua scripting. Maybe renaming "Internal names" to "Names used in lua scripting". So if one wan't's to try out lua scripting we should provide the needed information. Think e.g. on the scenario "Trident of fire" which exchanges terrains. Together with a possibility to add windows there can be editor addons with additional editor tools.

We have those internal names also in our encyclopedia and i never heard that this information is useless or bothering. On the contrary i think they are important for scenario authors.

Personally i have my own editor_functions.lua which grows in time, containing functions that i find useful, e.g. change_terrain() or set_fish(). Without knowing the internal names they are useless.

Did you noticed that in my pictures there are 2 new tabs in the editor help (immovables and rocks)? Despite the question of adding internal names, the immovables should be part of the help because some can be removed during game play, and others not. This is an importand information for a maps author, imho. Same for the rocks: "How many stones/granite can be mined from rocks4?".

Regarding the attributes in the register.lua's:
There should be a clear definition for what purpose they are for, imho.


Fight simulator for Widelands:
https://wide-fighter.netlify.app/

Top Quote
hessenfarmer
Avatar
Joined: 2014-12-11, 22:16
Posts: 2648
Ranking
One Elder of Players
Location: Bavaria
Posted at: 2023-03-07, 11:43

kaputtnik wrote:

Here is someone looking for a tool to add/change fish resources. And here a tool for exchange one terrain with another is asked for.

Correct, but in my opinion they are asking explicitly for a tool, to not have to bother with using lua scripts and thus the internal names. Therefore I think providing the names does not help them much.

All in all it does not harm to have the internal names in the editor help. And i don't think it will bother a map editor. Moreover having those internal names in the editor help can awake interest to try out lua scripting. Maybe renaming "Internal names" to "Names used in lua scripting". So if one wan't's to try out lua scripting we should provide the needed information. Think e.g. on the scenario "Trident of fire" which exchanges terrains. Together with a possibility to add windows there can be editor addons with additional editor tools.

if an addon provdes additional tools it should provide the relevant help as well.

We have those internal names also in our encyclopedia and i never heard that this information is useless or bothering. On the contrary i think they are important for scenario authors.

I agree, that the names of buildings are importnat for sceanrio authors, Therefore it is good to have them in our homepage Encyclopedia. However I think we should limit the in game help to information needed for gameplay and map making. Or formulated the other way round we should only provide help information that can be used inside the game / editor.

Personally i have my own editor_functions.lua which grows in time, containing functions that i find useful, e.g. change_terrain() or set_fish(). Without knowing the internal names they are useless.

I fully appreciate that. (In fact I would like if you could provide them somewhere e.g. in the utils folder like my dump_eco scripts or within an addon). However I don't think we should things we need to users who don't want to do scripting.

Did you noticed that in my pictures there are 2 new tabs in the editor help (immovables and rocks)? Despite the question of adding internal names, the immovables should be part of the help because some can be removed during game play, and others not. This is an importand information for a maps author, imho. Same for the rocks: "How many stones/granite can be mined from rocks4?".

fully agreed, would love to see a PR that.

Regarding the attributes in the register.lua's:
There should be a clear definition for what purpose they are for, imho.

well, basically the attributes should be used to clearly identify map objects in the game. namely in worker programs using the findobject or similar commands.


Top Quote
kaputtnik
Avatar
Topic Opener
Joined: 2013-02-18, 19:48
Posts: 2439
OS: Archlinux
Version: current master
Ranking
One Elder of Players
Location: Germany
Posted at: 2023-03-07, 18:02

hessenfarmer wrote:

kaputtnik wrote:

We have those internal names also in our encyclopedia and i never heard that this information is useless or bothering. On the contrary i think they are important for scenario authors.

I agree, that the names of buildings are importnat for sceanrio authors, Therefore it is good to have them in our homepage Encyclopedia. However I think we should limit the in game help to information needed for gameplay and map making. Or formulated the other way round we should only provide help information that can be used inside the game / editor.

I am only talking about the editor, not a game.

Did you noticed that in my pictures there are 2 new tabs in the editor help (immovables and rocks)? Despite the question of adding internal names, the immovables should be part of the help because some can be removed during game play, and others not. This is an importand information for a maps author, imho. Same for the rocks: "How many stones/granite can be mined from rocks4?".

fully agreed, would love to see a PR that.

Such information can be better shown as a tooltip for an immovable inside the editors place immovable tool, imho, just like the tooltips for trees. Having an extra tab just to show "Size is big" or "Quarrying turns this into rocks3" is a bit overkill. See also: https://github.com/widelands/widelands/issues/2099

Ok then, my approach was anyway a dirty hack. But at least i have learned some things.

What about having the internal names inside the Info-tool window? face-grin.png


Fight simulator for Widelands:
https://wide-fighter.netlify.app/

Top Quote
hessenfarmer
Avatar
Joined: 2014-12-11, 22:16
Posts: 2648
Ranking
One Elder of Players
Location: Bavaria
Posted at: 2023-03-07, 20:14

kaputtnik wrote:

Such information can be better shown as a tooltip for an immovable inside the editors place immovable tool, imho, just like the tooltips for trees. Having an extra tab just to show "Size is big" or "Quarrying turns this into rocks3" is a bit overkill. See also: https://github.com/widelands/widelands/issues/2099

Agreed. showing the info in the tooltip window is even better then having the tabs.

What about having the internal names inside the Info-tool window? face-grin.png

Nice try ;-). Honestly I think this does not change any of my arguments.


Top Quote
kaputtnik
Avatar
Topic Opener
Joined: 2013-02-18, 19:48
Posts: 2439
OS: Archlinux
Version: current master
Ranking
One Elder of Players
Location: Germany
Posted at: 2023-03-08, 17:23

hessenfarmer wrote:

kaputtnik wrote:

What about having the internal names inside the Info-tool window? face-grin.png

Nice try ;-). Honestly I think this does not change any of my arguments.

Sorry, but your argument's aren't very strong in my opinion. The example of the scenario trident of fire was only one. Imagine one want's to script a rock which never shrinks, or a tree which renews itself after some seconds after felling, or whatever. Or if one wants to use the function modify_unit. Another example: in my scenario (really don' know if i can complete it sometime face-sad.png ) there is a person who is able to pray for land if he will be provided with donkeys to keep his magic. A scenario can be much more than placing buildings, forbid buildings, checking if a user has reached a field of a map, or set workers and so on. There can be much more scripted. If we want to get some new developers, also a new scenario authors, we should provide the relevant information somewhere.

But i admit that it is currently only me who wants the internal names somewhere shown, because for me it's tedious to always walk through the folder structure of the data directory with a texteditor or file manager. For beginners it is even harder to find the correct file and additional the learning curve for lua scripting with the widelands lua api is steep. If we can make it a little bit easier we should do that. Moreover i think on the long run we should move the information of internal names of buildings, wares and workers from the websites encyclopedia into the editor. So they are available where they are needed. And this could also be a step forward to a scenario editor inside the map editor.


Fight simulator for Widelands:
https://wide-fighter.netlify.app/

Top Quote
hessenfarmer
Avatar
Joined: 2014-12-11, 22:16
Posts: 2648
Ranking
One Elder of Players
Location: Bavaria
Posted at: 2023-03-08, 17:45

Well I am not against providing that information e.g. on the homepage in our scripting section. I am only against providing this in the editor, as it can*t be used there directly. If a sceanrio designer wants to achieve what you have described, he needs to read a lot in the homepage anyway.
For me the editor as well as the in game help are related to the editor and the game and so we should only provide information that is useful in using the editor.

Once we might have a scenario editor this might change, but currently it is just a map editor. Providing unrelated information in a tool / game help simply does not feel right for me and could confuse "normal" users of the editor.

So for me the right place would be the scripting section of the homepage to provie such information. Maybe this could be realized like for the buildings ans we just need a link inside the scripting section.

Edit: As it seems we can't agree on that we might need to ask other developers or @Nordfriese on opinions.

Edited: 2023-03-08, 17:49

Top Quote