widelands / wl_addons_server

Provides the add-ons server and all add-ons for the Widelands game.
https://www.widelands.org
Other
6 stars 4 forks source link

Problem with immovables registered with europeans, which already exists in stock. #136

Closed MarkMcWire closed 2 years ago

MarkMcWire commented 2 years ago
Ein Fehler ist aufgetreten. Die Fehlermeldung lautet:
Error while loading tribe 'amazons': Description Manager::register_description: Attempt to register
description
name: 'barleyfield harvested' script: 'tribes/immovables/barleyfield/harvested/init.lua', but the object has already been registered to
script: 'addons/europeans_tribe.wad/immovables/barleyfield/harvested/init.lua
Bitte das aufgetretene Problem melden, damit Widelands entsprechend verbessert werden kann. Weitere Informationen stehen in der Standardausgabe (stdout.txt unter Windows). Benutzte
Build-Version:1.0 (Release). Bitte füge diese Information deiner Meldung bei.

The message from above is from private message from forum from another user.

The background is that I added new growth time values for crops because the values from the game don't fit my economy. For expample barley growth way to slow, so there is a bottleneck in europeans brewery.

I added an extra , "__replace_if_exists" in register.lua, but doesn't seem to work properly.

I assumed that the objects are loaded exactly the other way around. So first the default objects from the game and then those from the addon.

Noordfrees commented 2 years ago

Widelands 1.0 has very limited support for replacing units. __replace_if_exists and friends have been added more recently, so this appears to work fine in current master (at least I can't reproduce the problem there with euro 2.9.5) but not in v1.0.

The only way around this is to disable this particular feature in your add-on for users who are on v1.0. See the-x-mod add-on for an example how to check which version the user has:

N = (get_build_id():find("1.0") ~= 1)

N is then false for v1.0 and true for everything newer.

The register.lua files would look something like this:

if N then
   return {
      barleyfield_harvested = { "field", "__replace_if_exists" }
   }
else
   return {}
end

Or you could just require v1.1 or newer for the Europeans add-on, depending on how much effort you want to put into backwards compatibility.

MarkMcWire commented 2 years ago

I no longer change the 2.x versions of the Europeans. Starting with version 3.x they will be backwards compatible. In 3 days I will be version 3.0.0. publish.

MarkMcWire commented 2 years ago

Starting with 3.0.0 the issue is solved.