[micro_ai] error: bad argument #1 to 'insert' (table expected, got nil)
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.
[micro_ai] error: bad argument #1 to 'insert' (table expected, got nil)
Hello,
I'm trying to make some scattered animals behave like animals with the [micro_ai] ai_type=forest_animals setting. Here's the code:
The unit types are valid, and the scattered units are on the map. Yet, each time it's side 3's turn, after a few moves, this error happens:
What am I doing wrong?
EDIT:
These are the lines the error is pointing to in ca_forest_animals_move.cfg:
Apparently it doesn't see the items? There are numerous
items on the map, I don't see why the micro_ai doesn't find them.
I'm trying to make some scattered animals behave like animals with the [micro_ai] ai_type=forest_animals setting. Here's the code:
Code: Select all
[event]
name=prestart
[micro_ai]
ca_id=jonadiszno
side=3
action=add
ai_type=forest_animals
rabbit_type="Rabbit TRS"
deer_type="Stag TRS"
tusker_type="Horse TRS,Boar TRS"
tusklet_type="Chicken TRS,Pig TRS"
rabbit_hole_img="scenery/dirt.png"
[filter_location]
[not]
x=1-30
y=1-11
[/not]
[/filter_location]
[/micro_ai]
[/event]
EDIT:
These are the lines the error is pointing to in ca_forest_animals_move.cfg:
Code: Select all
-- If cfg.rabbit_hole_img is set, only items with that image or halo count as holes
local holes
if cfg.rabbit_hole_img then
for _,item in ipairs(all_items) do
if (item.image == cfg.rabbit_hole_img) or (item.halo == cfg.rabbit_hole_img) then
table.insert(holes, item)
end
end
else
holes = all_items
end
Code: Select all
[item]
x,y=...
image=scenery/dirt.png
[/item]
Main UMC campaigns: The Ravagers - now for 1.16, with new bugs!
Old UMC works: The Underness Series, consisting of 5 parts: The Desolation of Karlag, The Blind Sentinel, The Stone of the North, The Invasion Of The Western Cavalry, Fingerbone of Destiny
Old UMC works: The Underness Series, consisting of 5 parts: The Desolation of Karlag, The Blind Sentinel, The Stone of the North, The Invasion Of The Western Cavalry, Fingerbone of Destiny
- Celtic_Minstrel
- Developer
- Posts: 2216
- Joined: August 3rd, 2012, 11:26 pm
- Location: Canada
- Contact:
Re: [micro_ai] error: bad argument #1 to 'insert' (table expected, got nil)
I think the fix would be to write
local holes = {}
on the second line of your posted code snippet (naturally that would be a bug in the AI if so, but you can make the change yourself for a quick test).Re: [micro_ai] error: bad argument #1 to 'insert' (table expected, got nil)
Yes, that's it, and it is already fixed, but only from Wesnoth 1.14.6 on, while it looks like you're using 1.14.5.
SP campaigns: Galuldur's First Journey (1.12 & 1.14) & Grnk the Mighty (1.10 & 1.12)
AI experiments: Micro AIs (wiki, forum thread, known/fixed bugs), Fred, AI-demos add-on
AI experiments: Micro AIs (wiki, forum thread, known/fixed bugs), Fred, AI-demos add-on
Re: [micro_ai] error: bad argument #1 to 'insert' (table expected, got nil)
Oh, I see. Yes, sadly 1.14.5 is still the newest with my linux distribution, and I'm not great at compiling from source.
Guess I'll use an
Guess I'll use an
#ifver
for the custom rabbit hole then Main UMC campaigns: The Ravagers - now for 1.16, with new bugs!
Old UMC works: The Underness Series, consisting of 5 parts: The Desolation of Karlag, The Blind Sentinel, The Stone of the North, The Invasion Of The Western Cavalry, Fingerbone of Destiny
Old UMC works: The Underness Series, consisting of 5 parts: The Desolation of Karlag, The Blind Sentinel, The Stone of the North, The Invasion Of The Western Cavalry, Fingerbone of Destiny
Re: [micro_ai] error: bad argument #1 to 'insert' (table expected, got nil)
It is Lua change, no compiling needed. You can open the file and change it yourself.
That is if you need it for yourself, for other players if you want to support lower versions you need workarounds.
That is if you need it for yourself, for other players if you want to support lower versions you need workarounds.
Re: [micro_ai] error: bad argument #1 to 'insert' (table expected, got nil)
Also, since the entire Micro AI is written in Lua, you could add a local, fixed version of the MAI to your campaign and use that. Then it becomes independent of the version a player uses. Might not be worth the effort though.
SP campaigns: Galuldur's First Journey (1.12 & 1.14) & Grnk the Mighty (1.10 & 1.12)
AI experiments: Micro AIs (wiki, forum thread, known/fixed bugs), Fred, AI-demos add-on
AI experiments: Micro AIs (wiki, forum thread, known/fixed bugs), Fred, AI-demos add-on
Re: [micro_ai] error: bad argument #1 to 'insert' (table expected, got nil)
You can install 1.14.7 via flatpak if you are using Ubuntu. http://ubuntuhandbook.org/index.php/201 ... o-install/
Re: [micro_ai] error: bad argument #1 to 'insert' (table expected, got nil)
I already handfixed it here, but that's the point, for if anyone is still using 1.14.5 or older for some reason, it'd be broken for them, that's why I decided to use an ifver condition. It's also less effort than trying to include the entire MAI in the campaign. But that's another option, could be done some time later. Thanks
It's Debian 8 sadly.EarthCake wrote: ↑August 28th, 2019, 7:54 pm You can install 1.14.7 via flatpak if you are using Ubuntu. http://ubuntuhandbook.org/index.php/201 ... o-install/
Main UMC campaigns: The Ravagers - now for 1.16, with new bugs!
Old UMC works: The Underness Series, consisting of 5 parts: The Desolation of Karlag, The Blind Sentinel, The Stone of the North, The Invasion Of The Western Cavalry, Fingerbone of Destiny
Old UMC works: The Underness Series, consisting of 5 parts: The Desolation of Karlag, The Blind Sentinel, The Stone of the North, The Invasion Of The Western Cavalry, Fingerbone of Destiny
- Pentarctagon
- Project Manager
- Posts: 5564
- Joined: March 22nd, 2009, 10:50 pm
- Location: Earth (occasionally)
Re: [micro_ai] error: bad argument #1 to 'insert' (table expected, got nil)
Flatpak is supposed to be distro-agnostic, so it can be installed on Debian as well, depending on if Debian 8 supports it.
99 little bugs in the code, 99 little bugs
take one down, patch it around
-2,147,483,648 little bugs in the code
take one down, patch it around
-2,147,483,648 little bugs in the code