7 kyu Turn with a Compass
> a = {'t' = 1}
stdin:1: '}' expected near '='
> a = {t = 1}
> a = {1 = 12}
stdin:1: '}' expected near '='
> a = {[1] = 12}
> a[1]
12
local function direction(facing, turn)
local d = {N = 0,
NE = 45,
E = 90,
SE= 135,
S = 180,
SW= 225,
W = 270,
NW= 315}
local t = (d[facing] + turn) % 360
if 0 == t then
return 'N'
elseif 45 == t then
return 'NE'
elseif 90 == t then
return 'E'
elseif 135 == t then
return 'SE'
elseif 180 == t then
return 'S'
elseif 225 == t then
return 'SW'
elseif 270 == t then
return 'W'
elseif 315 == t then
return 'NW'
end
end
return direction