unit.flying does not appear.

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

Moderator: Forum Moderators

Post Reply
B099
Posts: 26
Joined: September 5th, 2024, 1:00 pm

unit.flying does not appear.

Post by B099 »

unit.flying does not appear.

Units that fly, according to [movetype] flying = yes [/movetype], should have a unit.flying variable.
For me, in this circumstance, it does not appear. The code below triggers with gryphons, bats, gliders.
And "unit.flying" never appears.

Code: Select all

local function add_object(unit)
    if not unit.flying then
        wesnoth.interface.add_chat_message("not flying "..wesnoth.as_text(unit.flying))
    end
end

on_event("recruit, recall", function (ctx)
	local unit = wesnoth.get_unit(ctx.x1, ctx.y1)
	if unit then
		add_object(unit)
	end
end)

B099
Posts: 26
Joined: September 5th, 2024, 1:00 pm

Re: unit.flying does not appear.

Post by B099 »

I figured it. OUT.

YOU MUST ACCESS unit.__cfg.flying INSTEAD OF unit.flying
CHECK WITH unit.__cfg.flying == true. BECAUSE unit.flying WON'T BE REAL
User avatar
Celtic_Minstrel
Developer
Posts: 2371
Joined: August 3rd, 2012, 11:26 pm
Location: Canada
Contact:

Re: unit.flying does not appear.

Post by Celtic_Minstrel »

Are you using version 1.18.x? If I recall correctly, unit.flying was added in 1.19.x.
Author of The Black Cross of Aleron campaign and Default++ era.
Former maintainer of Steelhive.
white_haired_uncle
Posts: 1456
Joined: August 26th, 2018, 11:46 pm
Location: A country place, far outside the Wire

Re: unit.flying does not appear.

Post by white_haired_uncle »

Celtic_Minstrel wrote: November 6th, 2024, 6:56 pm Are you using version 1.18.x? If I recall correctly, unit.flying was added in 1.19.x.
I think you're right. I though for sure OP would need to use unit.__cfg, but I tested it (on 1.19) and it worked for me.
Speak softly, and carry Doombringer.
Post Reply