Author Topic: how to determine if a unit is movable  (Read 1523 times)

andy_5995

  • Moderator
  • Ornithopter
  • ********
  • Posts: 474
  • Debian Linux user
    • View Profile
    • Andy Alt's home page
how to determine if a unit is movable
« 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

Birchard

  • Guest
Re: how to determine if a unit is movable
« Reply #1 on: 18 July 2017, 12:15:35 »
Thanks Andy, that's helpful.

andy_5995

  • Moderator
  • Ornithopter
  • ********
  • Posts: 474
  • Debian Linux user
    • View Profile
    • Andy Alt's home page
Re: how to determine if a unit is movable
« Reply #2 on: 19 July 2017, 17:21:55 »
Cool. Are you working on a scenario?

filux

  • MegaGlest Team
  • Draco Rider
  • ********
  • Posts: 310
  • was OpenSuse x64, is Debian testing x64
    • View Profile
Re: how to determine if a unit is movable
« Reply #3 on: 19 July 2017, 17:56:25 »
You missed getUnitsForFaction. Thx to this function your code may be shorter and universal (no hardcoded names).

 

anything