Unit ids not being found by lua

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
zaimoni
Posts: 281
Joined: January 27th, 2005, 7:00 am
Location: Linn Valley, KS U.S.A.
Contact:

Unit ids not being found by lua

Post by zaimoni »

Example:

Code: Select all

Checking lua scripts... ok
20180220 17:40:34 error scripting/lua: game_error: unknown unit type: WBD Civilian
stack traceback:
[C]: in local 'cmd'
lua/wml-utils.lua:145: in field 'handle_event_commands'
lua/wml-flow.lua:52: in local 'cmd'
lua/wml-utils.lua:145: in field 'handle_event_commands'
lua/wml-flow.lua:6: in function <lua/wml-flow.lua:5>
Failing macro at game start appears to be CREATE_HENCH_INSERT_TO_TAVERN in https://bitbucket.org/zaimoni/wesband/s ... stores.cfg. We have this at line 2196:

Code: Select all

{VARIABLE_OP new_hench rand "WBD Woodsman,WBD Ruffian,WBD Peasant,WBD Brute,WBD Civilian,WBD Initiate,WBD Nobleman,WBD Elf,WBD She Elf"}
The not-found units are from this list.

I can prevent the not-found by putting the relevant id values in the unit type configurations in quotes, but was advised that shouldn't be necessary by both the main wiki, and on Discord.

EDIT: This is a change in behavior in 1.13.11 from 1.13.8, which found the units and floundered on later lua errors.
User avatar
Sapient
Inactive Developer
Posts: 4453
Joined: November 26th, 2005, 7:41 am
Contact:

Re: Unit ids not being found by lua

Post by Sapient »

The error message indicates that there is nothing wrong with the code which is trying to place the "WBD Civilian" unit. The problem is rather that the unit_type "WBD Civilian" does not exist. You can take a look at the comma-separated list returned by [store_unit_type_ids], and I wager you will not find "WBD Civilian" in that list.

If I understand what you said correctly, that editing the [unit_type] then surrounding the id with quotes would make this error go away, then that is definitely a bug... potentially a bug in the WML parser. However, my own little test showed that I am able to place Elvish Fighters, despite the fact that their id has a space and is unquoted:

Code: Select all

    [event]
      name=moveto
      first_time_only=no
      [unit]
        type="Elvish Fighter"
# note, unit_type has unquoted id=Elvish Fighter
        x=$x1
        y="$($y1+1)"
        side=$side_number
      [/unit]
    [/event]
http://www.wesnoth.org/wiki/User:Sapient... "Looks like your skills saved us again. Uh, well at least, they saved Soarin's apple pie."
zaimoni
Posts: 281
Joined: January 27th, 2005, 7:00 am
Location: Linn Valley, KS U.S.A.
Contact:

Re: Unit ids not being found by lua

Post by zaimoni »

Right ... when I hit this yesterday the source code was hitting other lua errors fairly reliably making it hard to test this.

Looks like the problem is that

Code: Select all

[+units]
    {./units}
[/units]
isn't recursive; the subdirectories of the units directory aren't caught. Listing them explicitly fixes the not-found problem.
Post Reply