Lua error after adding factions to wc2

Discussion of Lua and LuaWML support, development, and ideas.

Moderator: Forum Moderators

Post Reply
hay207
Double Style Tourney #1 Champ
Posts: 121
Joined: November 26th, 2009, 5:46 am
Location: Egypt

Lua error after adding factions to wc2

Post by hay207 »

Hi all, my goal/project 's to add more factions to wc2
It worked but the option "Tell me how recruit works" gives an error When browsing units of the new faction
I noticed in the error, that lua uses the old/default path for addon, i tried changing that in main.lua and beside every LUAREQUIRE instance but failed.

Error image's here: https://ibb.co/GJ56Tm8

Edit: i renamed LUAREQUIRE macro but still old path's used
Ports: Velensk's tower defense, dov's deep shrine, Scrolling survival, Scrolling survival Co-op, Temples of the nagas.
Addons: Tower defense maps , some ANL scenarios like: ANL 3p "A New Land" survival type, and ANL Co-operative map for 2p
Luther
Posts: 128
Joined: July 28th, 2007, 5:19 pm
Location: USA

Re: Lua error after adding factions to wc2

Post by Luther »

Could you show us the statement at line 233? I see two possibilities: (1) Someone is using _ as a dummy variable, in which case you can replace it with nil, or (2) _ is the translation function that hasn't been defined for some reason.
hay207
Double Style Tourney #1 Champ
Posts: 121
Joined: November 26th, 2009, 5:46 am
Location: Egypt

Re: Lua error after adding factions to wc2

Post by hay207 »

Code: Select all

function wesnoth.wml_actions.wc2_recruit_info(cfg)
		
	local side_num = wesnoth.get_viewing_side()
	local faction = wc2_era.get_faction(side_num)
	if not faction then
		wesnoth.wml_actions.message {
			scroll = false,
			canrecruit = true,
			side = side_num,
			message = _ "You are not using a WC2 faction.",
		}
		return
	end
the line 223 is at message
But i tried deleting the underscore, commenting out whole line, nothing works
Ports: Velensk's tower defense, dov's deep shrine, Scrolling survival, Scrolling survival Co-op, Temples of the nagas.
Addons: Tower defense maps , some ANL scenarios like: ANL 3p "A New Land" survival type, and ANL Co-operative map for 2p
hay207
Double Style Tourney #1 Champ
Posts: 121
Joined: November 26th, 2009, 5:46 am
Location: Egypt

Re: Lua error after adding factions to wc2

Post by hay207 »

I see translations folder empty in wc2
Ports: Velensk's tower defense, dov's deep shrine, Scrolling survival, Scrolling survival Co-op, Temples of the nagas.
Addons: Tower defense maps , some ANL scenarios like: ANL 3p "A New Land" survival type, and ANL Co-operative map for 2p
User avatar
Lord-Knightmare
Discord Moderator
Posts: 2340
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: Lua error after adding factions to wc2

Post by Lord-Knightmare »

hay207 wrote: May 19th, 2021, 3:05 pm Hi all, my goal/project 's to add more factions to wc2
It worked but the option "Tell me how recruit works" gives an error When browsing units of the new faction
I noticed in the error, that lua uses the old/default path for addon, i tried changing that in main.lua and beside every LUAREQUIRE instance but failed.

Error image's here: https://ibb.co/GJ56Tm8

Edit: i renamed LUAREQUIRE macro but still old path's used
May i see the faction file codes? You are supposed to designate pairs of units under a new custom tag specific to WC otherwise errors like these will be common.
Creator of "War of Legends"
Creator of the Isle of Mists survival scenario.
Maintainer of Forward They Cried
User:Knyghtmare | My Medium
Luther
Posts: 128
Joined: July 28th, 2007, 5:19 pm
Location: USA

Re: Lua error after adding factions to wc2

Post by Luther »

Lord-Knightmare seems to know better than me what he's talking about, but there's an explanation of how to define _ at: https://wiki.wesnoth.org/GettextForWesn ... ngs_in_Lua
hay207
Double Style Tourney #1 Champ
Posts: 121
Joined: November 26th, 2009, 5:46 am
Location: Egypt

Re: Lua error after adding factions to wc2

Post by hay207 »

Here
Attachments
loyalist_drake.cfg
(1.66 KiB) Downloaded 117 times
Ports: Velensk's tower defense, dov's deep shrine, Scrolling survival, Scrolling survival Co-op, Temples of the nagas.
Addons: Tower defense maps , some ANL scenarios like: ANL 3p "A New Land" survival type, and ANL Co-operative map for 2p
User avatar
Lord-Knightmare
Discord Moderator
Posts: 2340
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: Lua error after adding factions to wc2

Post by Lord-Knightmare »

hay207 wrote: May 19th, 2021, 4:52 pmHere
Just as I suspected.

This is the correct way:

Code: Select all

#define MULTIPLAYER_SIDE_THE_CULT
    [multiplayer_side]
        id=The Cult
        name={STR_CULT}
        recruit=Spearman,Spearman,Skeleton,Skeleton,Bowman,Bowman,Skeleton Archer,Skeleton Archer,Mage,Mage,Dark Adept,Dark Adept,Horseman,Horseman,Ghoul,Ghoul,Fencer,Fencer,Dune Herbalist,Walking Corpse,Heavy Infantryman,Ghost,Cavalryman,Cavalryman,Vampire Bat,Vampire Bat,Merman Fighter,Merman Fighter
        image={IMG_CULT}
        type=random
        leader= Lieutenant,Swordsman,Pikeman,Javelineer,Shock Trooper,Longbowman,White Mage,Red Mage,Dark Sorcerer,Revenant,Deathblade,Bone Shooter,Necrophage
        random_leader= {RANDOM_LEADERS_CULT}
        [world_conquest_data]
            commanders=Loyalists,Undead,Dune Herbalist
            heroes=Rebels_All,Knalgans_All
            deserters=Drakes,Northerners,Young Ogre
            deserters_names={STR_YOUNG_OGRE}+", "+{STR_DRAKES}+{STR_AND}+{STR_NORTHERENS}
            {WC_II_PAIR "Spearman" "Spearman"}
            {WC_II_PAIR "Skeleton" "Skeleton"}
            {WC_II_PAIR "Bowman" "Bowman"}
            {WC_II_PAIR "Skeleton Archer" "Skeleton Archer"}
            {WC_II_PAIR "Mage" "Mage"}
            {WC_II_PAIR "Dark Adept" "Dark Adept"}
            {WC_II_PAIR "Horseman" "Horseman"}
            {WC_II_PAIR "Ghoul" "Ghoul"}
            {WC_II_PAIR "Fencer" "Fencer"}
            {WC_II_PAIR "Dune Herbalist" "Walking Corpse"}
            {WC_II_PAIR "Heavy Infantryman" "Ghost"}
            {WC_II_PAIR "Cavalryman" "Cavalryman"}
            {WC_II_PAIR "Vampire Bat" "Vampire Bat"}
            {WC_II_PAIR "Merman Fighter" "Merman Fighter"}
        [/world_conquest_data]
    [/multiplayer_side]
#enddef
Creator of "War of Legends"
Creator of the Isle of Mists survival scenario.
Maintainer of Forward They Cried
User:Knyghtmare | My Medium
hay207
Double Style Tourney #1 Champ
Posts: 121
Joined: November 26th, 2009, 5:46 am
Location: Egypt

Re: Lua error after adding factions to wc2

Post by hay207 »

Ok, so you suggest using

Code: Select all

 [world_conquest_data]
instead of

Code: Select all

FACTION_VARIABLE
which is used by default factions , However your method doesn't allow pairing (displays all units in faction).
Also, i still get same error
Ports: Velensk's tower defense, dov's deep shrine, Scrolling survival, Scrolling survival Co-op, Temples of the nagas.
Addons: Tower defense maps , some ANL scenarios like: ANL 3p "A New Land" survival type, and ANL Co-operative map for 2p
hay207
Double Style Tourney #1 Champ
Posts: 121
Joined: November 26th, 2009, 5:46 am
Location: Egypt

Re: Lua error after adding factions to wc2

Post by hay207 »

Also i should mention that everything works if i delete wc2 and used my modded one
Ports: Velensk's tower defense, dov's deep shrine, Scrolling survival, Scrolling survival Co-op, Temples of the nagas.
Addons: Tower defense maps , some ANL scenarios like: ANL 3p "A New Land" survival type, and ANL Co-operative map for 2p
User avatar
Lord-Knightmare
Discord Moderator
Posts: 2340
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: Lua error after adding factions to wc2

Post by Lord-Knightmare »

hay207 wrote: May 19th, 2021, 5:34 pm Also i should mention that everything works if i delete wc2 and used my modded one
Are you trying to load the mainline WC in 1.15.x as an add-on in 1.14?
Creator of "War of Legends"
Creator of the Isle of Mists survival scenario.
Maintainer of Forward They Cried
User:Knyghtmare | My Medium
hay207
Double Style Tourney #1 Champ
Posts: 121
Joined: November 26th, 2009, 5:46 am
Location: Egypt

Re: Lua error after adding factions to wc2

Post by hay207 »

I'm just editing the addon on 1.14 server, so the

Code: Select all

 [world_conquest_data]
is not written yet
Ports: Velensk's tower defense, dov's deep shrine, Scrolling survival, Scrolling survival Co-op, Temples of the nagas.
Addons: Tower defense maps , some ANL scenarios like: ANL 3p "A New Land" survival type, and ANL Co-operative map for 2p
hay207
Double Style Tourney #1 Champ
Posts: 121
Joined: November 26th, 2009, 5:46 am
Location: Egypt

Re: Lua error after adding factions to wc2

Post by hay207 »

Ok, i'll just write the info in [message], thanks all :)
Ports: Velensk's tower defense, dov's deep shrine, Scrolling survival, Scrolling survival Co-op, Temples of the nagas.
Addons: Tower defense maps , some ANL scenarios like: ANL 3p "A New Land" survival type, and ANL Co-operative map for 2p
Post Reply