Posted 26 January 2013 - 08:09 AM
Spoiler
function updateNPC()
if npcmode == "dumb" then
turn = math.random(1,4)
if (turn == 1) and ((map[npcpos-9] == "-") or (map[npcpos-9] == "d" and door)) then
npcpos = npcpos-9
npcy = npcy-1
elseif (turn == 2) and ((map[npcpos+9] == "-") or (map[npcpos+9] == "d" and door)) then
npcpos = npcpos+9
npcy = npcy+1
elseif (turn == 3) and ((map[npcpos-1] == "-") or (map[npcpos-1] == "d" and door)) then
npcpos = npcpos-1
npcx = npcx-1
elseif (turn == 4) and ((map[npcpos+1] == "-") or (map[npcpos+1] == "d" and door)) then
npcpos = npcpos+1
npcx = npcx+1
end
elseif npcmode == "stalk" then
if npcy > chary then
if map[npcpos-9] == "-" or (map[npcpos-9] == "d" and door) then
npcpos = npcpos-9
npcy = npcy-1
elseif map[npcpos+1] == "-" or (map[npcpos+1] == "d" and door) then
npcpos = npcpos+1
npcx = npcx+1
elseif map[npcpos-1] == "-" or (map[npcpos-1] == "d" and door) then
npcpos = npcpos-1
npcx = npcx-1
end
elseif npcy < chary then
if map[npcpos+9] == "-" or (map[npcpos+9] == "d" and door) then
npcpos = npcpos+9
npcy = npcy+1
elseif map[npcpos+1] == "-" or (map[npcpo+1] == "d" and door) then
npcpos = npcpos+1
npcx = npcx+1
elseif map[npcpos-1] == "-" or (map[npcpos-1] == "d" and door) then
npcpos = npcpos-1
npcx = npcx-1
end
elseif npcx > charx then
if map[npcpos-1] == "-" or (map[npcpos-1] == "d" and door) then
npcpos = npcpos-1
npcx = npcx-1
elseif map[npcpos-9] == "-" or (map[npcpos-9] == "d" and door) then
npcpos = npcpos-9
npcy = npcy-1
elseif map[npcpos+9] == "-" or (map[npcpos+9] == "d" and door) then
npcpos = npcpos+9
npcy = npcy+1
end
elseif npcx < charx then
if map[npcpos+1] == "-" or (map[npcpos+1] == "d" and door) then
npcpos = npcpos+1
npcx = npcx+1
elseif map[npcpos-9] == "-" or (map[npcpos-9] == "d" and door) then
npcpos = npcpos-9
npcy = npcy-1
elseif map[npcpos+9] == "-" or (map[npcpos+9] == "d" and door) then
npcpos = npcpos-9
npcy = npcy+1
end
end
end
end
Full code:
http://pastebin.com/pmSyttDX
ANY HELP POSSIBLE??