Lua error when using [unit] tag
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.
-
- Posts: 38
- Joined: June 17th, 2011, 1:26 am
Lua error when using [unit] tag
I've been writing a scenario where a particular event fires, causing a lot of things to happen, including the spawning of a bunch of reinforcements for side 2. About halfway through, I have the following code:
The idea being that a unit with an id I can use in messages later on spawns. As far as I can tell, everything prior to that bit functions correctly, but the unit in the above code won't spawn, the rest of the event doesn't work, and I get an error message in the upper right of the screen saying:
Strangely, the [unit] tag works perfectly everywhere else in the scenario.
What am I doing wrong?
Code: Select all
#Coded in Wesnoth 1.9.7
[unit]
id=Pikeman Leader
name=_ "Pikeman Leader"
type=Pikeman
side=2
x=30
y=19
[/unit]
Code: Select all
<Lua Error>...(x86)/Battle for Wesnoth 1.9.7/data/lua/wml-tags.lua:140: bad argument #1 to 'add_known_unit' (unknown unit type)
stack traceback:
[c]: in function 'add_known_unit'
...(x86)/Battle for wesnoth/data/lua/wml_tags.lua:140: in function 'cmd'
...(x86)/Battle for Wesnoth/data/lua/wml-tags.lua:290: in function <...(x86)/Battle for Wesnoth 1.9.7/data/lua/wml-tags.lua:254>
What am I doing wrong?
Currently working on various ideas using 1.9.8.9
-
- Developer
- Posts: 546
- Joined: January 12th, 2011, 2:18 am
- Location: Pennsylvania, USA
Re: Lua error when using [unit] tag
It'd help to have more info, but I'll venture a guess.
based on the error message, I looked at the lua in question and it suggests that you have a [allow_extra_recruit] tag somewhere else in your code. My guess is that you are feeding it "Pikeman Leader" which is the id, not the type of the unit, which is what [allow_extra_recruit] requires
OTOH, this guess might be a bit off.
based on the error message, I looked at the lua in question and it suggests that you have a [allow_extra_recruit] tag somewhere else in your code. My guess is that you are feeding it "Pikeman Leader" which is the id, not the type of the unit, which is what [allow_extra_recruit] requires
OTOH, this guess might be a bit off.
Co-Author of Winds of Fate
My Add-ons: Random Campaign, Custom Campaign, Ultimate Random Maps, Era of Legends, Gui Debug Tools
Erfworld: The comic that lead me to find Wesnoth.
My Add-ons: Random Campaign, Custom Campaign, Ultimate Random Maps, Era of Legends, Gui Debug Tools
Erfworld: The comic that lead me to find Wesnoth.
-
- Posts: 38
- Joined: June 17th, 2011, 1:26 am
Re: Lua error when using [unit] tag
I do have an [allow_extra_recruit] tag, but misspelled one of the unit id's. Thanks for the help; the reason I didn't post the whole event is because a lot happens in it, all of which now work. Thanks again.
Currently working on various ideas using 1.9.8.9
-
- Inactive Developer
- Posts: 2461
- Joined: August 15th, 2008, 8:46 pm
- Location: Germany
Re: Lua error when using [unit] tag
strategy for such errors:
Look at the stack traceback the error message displays. A stack traceback is a sequence of called functions, that is, actions which are made, which leads to a certain spot in this sequence of actions where the error occurs. It says /data/lua/wml_tags.lua:140 in the first line. Open that file of your BfW installation in a text editor. Line 140 belongs to a long block (no need to understand anything of it, although it helps if you do):
"some_tag_name" is the name of the tag where you probably have made a mistake. (So look it up in the wiki etc.)
Look at the stack traceback the error message displays. A stack traceback is a sequence of called functions, that is, actions which are made, which leads to a certain spot in this sequence of actions where the error occurs. It says /data/lua/wml_tags.lua:140 in the first line. Open that file of your BfW installation in a text editor. Line 140 belongs to a long block (no need to understand anything of it, although it helps if you do):
Code: Select all
function wml_actions.some_tag_name(cfg)
...
end
projects (BfW 1.12):
A Simple Campaign: campaign draft for wml starters • Plan Your Advancements: mp mod
The Earth's Gut: sp campaign • Settlers of Wesnoth: mp scenario • Wesnoth Lua Pack: lua tags and utils
updated to 1.8 and handed over: A Gryphon's Tale: sp campaign
A Simple Campaign: campaign draft for wml starters • Plan Your Advancements: mp mod
The Earth's Gut: sp campaign • Settlers of Wesnoth: mp scenario • Wesnoth Lua Pack: lua tags and utils
updated to 1.8 and handed over: A Gryphon's Tale: sp campaign