Multiplayer AI errors

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
vghetto
Posts: 755
Joined: November 2nd, 2019, 5:12 pm

Multiplayer AI errors

Post by vghetto »

Hi,

In my Wesband port, I keep getting this error on screen and in the console. I don't know what is causing it. It appears whenever it's the AIs turn.
I also get the same message when I try to :inspect the ai side.

I'm not sure why it's calling the dummy_engine. The AI side moves and attacks normally, btw.

This is on 1.14.

Code: Select all

20211208 03:48:49 error scripting/lua: lua/core.lua:281: bad argument #2 to 'set_variable_local' (WML table or scalar expected, got function)
stack traceback:
        [C]: in upvalue 'set_variable_local'
        lua/core.lua:281: in metamethod '__newindex'
        lua/core.lua:303: in upvalue 'set_variable_proxy'
        lua/core.lua:323: in metamethod '__newindex'
        ai/lua/cache.lua:9: in field 'init'
        ai/lua/stdlib.lua:9: in field 'init'
        ai/lua/dummy_engine_lua.lua:8: in main chunk
        [C]: in field 'dofile'
        lua/package.lua:53: in field 'require'
        [string "wesnoth.require("ai/lua/dummy_engine_lua.lua"..."]:1: in main chunk
20211208 03:48:49 error scripting/lua: ai/lua/ca_high_xp_attack.lua:35: attempt to index a nil value (field 'aspects')
stack traceback:
        ai/lua/ca_high_xp_attack.lua:35: in function <ai/lua/ca_high_xp_attack.lua:31>
        (...tail calls...)
20211208 03:48:49 error scripting/lua: ai/lua/ca_high_xp_attack.lua:35: attempt to index a nil value (field 'aspects')
stack traceback:
        ai/lua/ca_high_xp_attack.lua:35: in function <ai/lua/ca_high_xp_attack.lua:31>
        (...tail calls...)
vghetto
Posts: 755
Joined: November 2nd, 2019, 5:12 pm

Re: Multiplayer AI errors

Post by vghetto »

First I thought this has something to do with multiplayer. I haven't done anything in multiplayer before, so I don't know.
I changed wesband into a single player campaign as a test and it had the same problem on the AI turn.
All I could narrow it down to are probably these as the root cause.

Code: Select all

H = wesnoth.require "lua/helper.lua"
W = H.set_wml_action_metatable {}
H.set_wml_var_metatable(_G)
That can't be a good sign :augh:

Edit:
I just ran a dummy campaign and sure thing it's the big _G :(
Anyone knows of a quick fix for this situation?
User avatar
Celtic_Minstrel
Developer
Posts: 2207
Joined: August 3rd, 2012, 11:26 pm
Location: Canada
Contact:

Re: Multiplayer AI errors

Post by Celtic_Minstrel »

H.set_wml_var_metatable(_G) is just bad practice in general, but… I think you should be able to get around the issue by literally just moving that line to the bottom of the file (above any return obviously). The problem is (most likely) that for every function defined in the file, it's trying to assign it to a WML variable of the same name, which obviously won't work.

If that's in a WML file, it's a bit trickier though… you would need to figure out what parts of the code rely on it and modify them.
Author of The Black Cross of Aleron campaign and Default++ era.
Former maintainer of Steelhive.
vghetto
Posts: 755
Joined: November 2nd, 2019, 5:12 pm

Re: Multiplayer AI errors

Post by vghetto »

Celtic_Minstrel wrote: January 9th, 2022, 10:33 pm H.set_wml_var_metatable(_G) is just bad practice in general, but… I think you should be able to get around the issue by literally just moving that line to the bottom of the file (above any return obviously).
That's good to know. Thank you.
The way I ended up doing it is by removing the H.set_wml_var_metatable(_G) line and encasing the needed lua vars with wml.variables[].
Post Reply