"Unknown unit type" error for add-on units

The place to post your WML questions and answers.

Moderator: Forum Moderators

Forum rules
  • Please use [code] BBCode tags in your posts for embedding WML snippets.
  • To keep your code readable so that others can easily help you, make sure to indent it following our conventions.
Post Reply
Forge
Posts: 4
Joined: October 20th, 2019, 10:29 pm

"Unknown unit type" error for add-on units

Post by Forge »

If anyone remembers the Gambit's Empire Builder mod, I'm in the process of updating, modifying, and refining it because I personally enjoy playing it. (Even if most other people don't like it.) I'm having an issue with summoning add-on units for various parts of the games (buying them from villages, courtyards (elvish castle tiles), etc. Summoning core units works just fine, summoning units that came with the add-on do not. (It all worked fine in Wesnoth 1.8...or 1.6....it's been a while I dont remember for sure which one.) It throws a "unknown unit type" error in the game.
Other notes:
Unit file works.I put it in the core unit files and it'll spawn in debug mode just fine, but still not from the aforementioned village menu option.
Core units that you can buy on the menu option from the villages and such work fine.
It can find the units in the add-on, enough to complain about some non-functioning abilities when you try to load the multiplayer screen on startup. (these units where then removed and will be fixed later)
Its not a typo issue, the macro sends it looking for, in one particular case, a unit with "Cow" unit ID, and I verified the correct spelling. Paths all look good (as I said, it can follow the paths fine when it's complaining about broken units, but not when trying to spawn the good ones.

K code dump:
_main.cfg:
Spoiler:
macros folder:
_general.cfg macro
Spoiler:
the section of _general.cfg that I'm pretty sure is the important one for this problem: (generic_summon, special_summon, and special_summon2)
Spoiler:
_buildingoptions.cfg macro
Spoiler:
the specific part I've been focusing on of _buildingoptions.cfg:
Spoiler:
and the Cow.cfg file found in the units folder:
Spoiler:
Trying to buy a cow from a "ranch" (desert village) will throw a Lua error in the game:

Code: Select all

<Lua error> game_error: unknown unit type: Cow
Buying core units in similar situations (from other villages like the #Tavern in the _buildingoptions.cfg macro) works just fine. Buying any non-core unit (aka, those that came with the add-on and are in the /units folder in the /add-ons folder) does not work in any situation.

Hope all that made sense and someone can provide some direction. I can't really code from scratch I just modify pre-exisiting files and pick them apart so I only barely know what I'm doing. If any information is missing just ask and I'll provide it.
User avatar
Pentarctagon
Project Manager
Posts: 5564
Joined: March 22nd, 2009, 10:50 pm
Location: Earth (occasionally)

Re: "Unknown unit type" error for add-on units

Post by Pentarctagon »

I think your include of the units folder needs to be inside the [units] tag. It would be easiest if you uploaded the entire add-on as a zip archive though.
99 little bugs in the code, 99 little bugs
take one down, patch it around
-2,147,483,648 little bugs in the code
Forge
Posts: 4
Joined: October 20th, 2019, 10:29 pm

Re: "Unknown unit type" error for add-on units

Post by Forge »

So like

Code: Select all

[unit]
x=$x1
y=$y1
side=$side_number
type={TYPE}
/add-ons/Gambits_EMPIRE_Builder/units
[/unit]
?
User avatar
Pentarctagon
Project Manager
Posts: 5564
Joined: March 22nd, 2009, 10:50 pm
Location: Earth (occasionally)

Re: "Unknown unit type" error for add-on units

Post by Pentarctagon »

I mean like:

Code: Select all

# wmllint: no translatables

#ifdef MULTIPLAYER
[binary_path]
    path="data/add-ons/Gambits_EMPIRE_Builder"
[/binary_path]
{~add-ons/Gambits_EMPIRE_Builder/abilities}
{~add-ons/Gambits_EMPIRE_Builder/eras}
{~add-ons/Gambits_EMPIRE_Builder/images}
{~add-ons/Gambits_EMPIRE_Builder/macros}
{~add-ons/Gambits_EMPIRE_Builder/sounds}
[units]
{~add-ons/Gambits_EMPIRE_Builder/units}
[/units]
#endif
99 little bugs in the code, 99 little bugs
take one down, patch it around
-2,147,483,648 little bugs in the code
Forge
Posts: 4
Joined: October 20th, 2019, 10:29 pm

Re: "Unknown unit type" error for add-on units

Post by Forge »

Sweet, that worked. Next question.
Why?
User avatar
Pentarctagon
Project Manager
Posts: 5564
Joined: March 22nd, 2009, 10:50 pm
Location: Earth (occasionally)

Re: "Unknown unit type" error for add-on units

Post by Pentarctagon »

{~add-ons/Gambits_EMPIRE_Builder/units} includes all the [unit_type]s in that folder, and Wesnoth requires that all [unit_type]s be within the [units] tag.
99 little bugs in the code, 99 little bugs
take one down, patch it around
-2,147,483,648 little bugs in the code
Forge
Posts: 4
Joined: October 20th, 2019, 10:29 pm

Re: "Unknown unit type" error for add-on units

Post by Forge »

huh....good to know. Thanks for the help and explanation. I'll let you guys know next time I have an issue with it.
Post Reply