From b84872c2b250626eb70e42d872f8ffb006915a4f Mon Sep 17 00:00:00 2001 From: Afforess Date: Sun, 3 Apr 2016 19:39:49 -0400 Subject: [PATCH] Fix nil when accessing biter scents data --- Makefile | 2 +- libs/region/biter_scents.lua | 10 ++++++---- 2 files changed, 7 insertions(+), 5 deletions(-) diff --git a/Makefile b/Makefile index 17d8471..814d101 100644 --- a/Makefile +++ b/Makefile @@ -1,5 +1,5 @@ PACKAGE_NAME := Misanthrope -VERSION_STRING := 0.3.5 +VERSION_STRING := 0.3.6 OUTPUT_NAME := $(PACKAGE_NAME)_$(VERSION_STRING) OUTPUT_DIR := build/$(OUTPUT_NAME) diff --git a/libs/region/biter_scents.lua b/libs/region/biter_scents.lua index 2ee9cba..80955da 100644 --- a/libs/region/biter_scents.lua +++ b/libs/region/biter_scents.lua @@ -121,10 +121,12 @@ function biter_scents.tick(cache) end function biter_scents.get_value(cache, x, y) - local x_idx = bit32.band(x, 0x7F) - local y_idx = bit32.band(y, 0x7F) - if cache.values[x_idx] and cache.values[x_idx][y_idx] then - return cache.values[x_idx][y_idx] + if cache and cache.values then + local x_idx = bit32.band(x, 0x7F) + local y_idx = bit32.band(y, 0x7F) + if cache.values[x_idx] and cache.values[x_idx][y_idx] then + return cache.values[x_idx][y_idx] + end end return 0 end