Instructions for Overriding World Conquest enemy army array Unclear
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.
- Lord-Knightmare
- Discord Moderator
- Posts: 2361
- Joined: May 24th, 2010, 5:26 pm
- Location: Somewhere in the depths of Irdya, gathering my army to eventually destroy the known world.
- Contact:
Instructions for Overriding World Conquest enemy army array Unclear
After 2-3 weeks of trying...I have finally arrived here with my problem.
In the mainline campaign directory, there is this file which states that I can define my own enemy army array and the one in the campaign is default case/fallback.
Anyways, I made my own: Here
The expected outcome should have been some success but all I got was this:
I opened the inspector and saw the array was there in the variables, so maybe it's the next step which is throwing the error?
Thus, I ask: What am I doing wrong? Or am I missing something? Or, are these modding instructions incomplete (if so, it should be filed as an issue)?
In the mainline campaign directory, there is this file which states that I can define my own enemy army array and the one in the campaign is default case/fallback.
Anyways, I made my own: Here
The expected outcome should have been some success but all I got was this:
Code: Select all
20220112 03:40:22 error scripting/lua: campaigns/World_Conquest/lua/campaign/enemy.lua:252: attempt to perform arithmetic on a nil value
stack traceback:
campaigns/World_Conquest/lua/campaign/enemy.lua:252: in local 'cmd'
lua/wml-utils.lua:144: in field 'handle_event_commands'
lua/wml-flow.lua:5: in function <lua/wml-flow.lua:4>
Thus, I ask: What am I doing wrong? Or am I missing something? Or, are these modding instructions incomplete (if so, it should be filed as an issue)?
Creator of "War of Legends"
Creator of the Isle of Mists survival scenario.
Maintainer of Forward They Cried
User:Knyghtmare | My Medium
Creator of the Isle of Mists survival scenario.
Maintainer of Forward They Cried
User:Knyghtmare | My Medium
Re: Instructions for Overriding World Conquest enemy army array Unclear
Well, go to line 252 and see what's going on.
Are you sure WC's lua can access WoL's units path?
I would also remove the line
Are you sure WC's lua can access WoL's units path?
I would also remove the line
id="wc2_init_enemy"
.- Lord-Knightmare
- Discord Moderator
- Posts: 2361
- Joined: May 24th, 2010, 5:26 pm
- Location: Somewhere in the depths of Irdya, gathering my army to eventually destroy the known world.
- Contact:
Re: Instructions for Overriding World Conquest enemy army array Unclear
Code: Select all
local enemy_type_id = wc2_utils.pick_random("wc2_enemy_army.factions_available") - 1
wc2_utils.pick_random("wc2_enemy_army.factions_available")
isn't being created so it's a nil...I wonder what's the cause...? would be nice if a lua expert commented here...or maybe move this to Lua Labs since it seems more Lua than WML, despite having both...?Creator of "War of Legends"
Creator of the Isle of Mists survival scenario.
Maintainer of Forward They Cried
User:Knyghtmare | My Medium
Creator of the Isle of Mists survival scenario.
Maintainer of Forward They Cried
User:Knyghtmare | My Medium
- Celtic_Minstrel
- Developer
- Posts: 2211
- Joined: August 3rd, 2012, 11:26 pm
- Location: Canada
- Contact:
Re: Instructions for Overriding World Conquest enemy army array Unclear
The
That means that the only way for it to return
wc2_utils.pick_random
function is defined on line 28 of utils.lua, and in this specific call, you can see that str
is non-nil (so the outermost if
is entered) and generator
is nil (so the inner if
is not entered).That means that the only way for it to return
nil
would be if array[index]
is nil
, and as far as I can tell, the only way for that to happen would be that array
has no elements… and from what I can tell, that can only happen if the variable wc2_enemy_army.factions_available
is either nil
or an empty string.- Lord-Knightmare
- Discord Moderator
- Posts: 2361
- Joined: May 24th, 2010, 5:26 pm
- Location: Somewhere in the depths of Irdya, gathering my army to eventually destroy the known world.
- Contact:
Re: Instructions for Overriding World Conquest enemy army array Unclear
I have later found out (big thank you to Soliton) that the modding instructions is half done. It's missing some code which counts the groups and createsCeltic_Minstrel wrote: ↑January 20th, 2022, 12:26 am Thewc2_utils.pick_random
function is defined on line 28 of utils.lua, and in this specific call, you can see thatstr
is non-nil (so the outermostif
is entered) andgenerator
is nil (so the innerif
is not entered).
That means that the only way for it to returnnil
would be ifarray[index]
isnil
, and as far as I can tell, the only way for that to happen would be thatarray
has no elements… and from what I can tell, that can only happen if the variablewc2_enemy_army.factions_available
is eithernil
or an empty string.
factions_available
and allies_available
keys for the array. The fallback has the code so it didn't face the problem.I got around this problem by hardcoding the two missing keys and got it to work.
Creator of "War of Legends"
Creator of the Isle of Mists survival scenario.
Maintainer of Forward They Cried
User:Knyghtmare | My Medium
Creator of the Isle of Mists survival scenario.
Maintainer of Forward They Cried
User:Knyghtmare | My Medium