function Move(s_object, displacement) local function wall_at(location) if walls[location[2]][location[1]] > 0 then return true; else return false; end end --Generate destination destination = {0,0}; for i,v in ipairs(displacement) do destination[i] = characters[s_object].location[i] + displacement[i]; end; --Is this destination viable? if not wall_at(destination) then characters[s_object].location = destination; end --Is this destination an enemy? end function Attack(s_object, s_victim) local function getDamage(s_object) return characters[s_object].attack_power; end characters[s_victim].hp = characters[s_victim].hp - getDamage(s_object); end function distance(s_object, s_relative) return math.sqrt((characters[s_object].location[1] - characters[s_relative].location[1])^2 + (characters[s_object].location[2] - characters[s_relative].location[2])^2); end function is_near(s_object, s_relative) return (distance(s_object, s_relative) < 2); end