MegaGlest Forum

Modding and game content creation => Mods => Topic started by: andy_5995 on 17 June 2016, 15:59:29

Title: how to determine if a unit is movable
Post by: andy_5995 on 17 June 2016, 15:59:29
I couldn't find a function that would return a value based on whether or not a unit is movable. Did I miss something? I'm using this page as a reference:
https://docs.megaglest.org/MG/Lua

In the meantime, I made this function. (It doesn't cover all factions)

Code: [Select]
nonMovableUnits = {
"blacksmith", "bone_tent", "castle", "house", "valhalla", "farm", "thor_totem", "mistletoe_tree", "mead_bar",
"air_pyramid", "desert_camp", "obelisk", "pyramid", "sphinx", "temple",
"beehive", "big_tent", "campfire", "horse_farm", "main_teepee", "reed", "round_tent", "tent", "totem"
}

function isMovableUnit(value)
local isMovable=1
for i = 1, #nonMovableUnits do
if value == nonMovableUnits[i] then
isMovable = 0
break
end
end

return isMovable
end
Title: Re: how to determine if a unit is movable
Post by: Birchard on 18 July 2017, 12:15:35
Thanks Andy, that's helpful.
Title: Re: how to determine if a unit is movable
Post by: andy_5995 on 19 July 2017, 17:21:55
Cool. Are you working on a scenario?
Title: Re: how to determine if a unit is movable
Post by: filux on 19 July 2017, 17:56:25
You missed getUnitsForFaction. Thx to this function your code may be shorter and universal (no hardcoded names).