Alexey0402 Posted April 23, 2016 Share Posted April 23, 2016 Собственно есть двумерный массив WeatherInWorld = {},{} А одном месте выполняю этот код WeatherInWorld[2][1] = CreateAdjacentWeather(WeatherInWorld[1][4], month) WeatherInWorld[2][2] = CreateAdjacentWeather(WeatherInWorld[2][1], month) WeatherInWorld[2][3] = CreateAdjacentWeather(WeatherInWorld[2][2], month) WeatherInWorld[2][4] = CreateAdjacentWeather(WeatherInWorld[2][3], month) Вот Function CreateAdjacentWeather function CreateAdjacentWeather(x, y) if(y == 1) then if(x == 1) then return 1 else return 0 end else return 0 end end Суть функции думаю поняли (в реальности она такая же,только чуть больше условных конструкций) В итоге ошибка attempt to index field ' ' (a nil value) на WeatherInWorld[2][1] = CreateAdjacentWeather(WeatherInWorld[1][4], month) WeatherInWorld[2][2] = CreateAdjacentWeather(WeatherInWorld[2][1], month) WeatherInWorld[2][3] = CreateAdjacentWeather(WeatherInWorld[2][2], month) WeatherInWorld[2][4] = CreateAdjacentWeather(WeatherInWorld[2][3], month) Что исправить надо и как?И,вообще в чём косяк? Link to comment
SeWeR Posted April 23, 2016 Share Posted April 23, 2016 WeatherInWorld[2][1] = CreateAdjacentWeather(WeatherInWorld[2][4], month) WeatherInWorld[2][2] = CreateAdjacentWeather(WeatherInWorld[2][1], month) WeatherInWorld[2][3] = CreateAdjacentWeather(WeatherInWorld[2][2], month) WeatherInWorld[2][4] = CreateAdjacentWeather(WeatherInWorld[2][3], month) пальцем в небо. Link to comment
Alexey0402 Posted April 24, 2016 Author Share Posted April 24, 2016 WeatherInWorld[2][1] = CreateAdjacentWeather(WeatherInWorld[2][4], month) WeatherInWorld[2][2] = CreateAdjacentWeather(WeatherInWorld[2][1], month) WeatherInWorld[2][3] = CreateAdjacentWeather(WeatherInWorld[2][2], month) WeatherInWorld[2][4] = CreateAdjacentWeather(WeatherInWorld[2][3], month) пальцем в небо. Ошибка явно не в этом.Тут всё правильно.Именно WeatherInWorld[1][4] надо,ибо это погода вечера прошлого дня. Link to comment
Alexey0402 Posted April 24, 2016 Author Share Posted April 24, 2016 Всё,решил.Проблема была в моей криворукости.Я неправильно объявил двумерный массив. Вместо WeatherInWorld = {},{} надо было WeatherInWorld = {} и for i=1, 3 do WeatherInWorld[i] = {} end Link to comment
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now