Posted 12 November 2012 - 12:07 AM
I'm trying to make some kind of Pokemon Battle Simulator.
Now I'm making the move selection table but I get this error:
pbsselect:30: attempt to index ? (a nil value)
Now I tried to look it up, but I cant find any error's.
here is the code:
Now I'm making the move selection table but I get this error:
pbsselect:30: attempt to index ? (a nil value)
Now I tried to look it up, but I cant find any error's.
here is the code:
Spoiler
function yN()
selection=1
while true do
term.clear()
term.setCursorPos(1,1)
local x, y=term.getCursorPos()
term.clearLine()
if selection==1
then write(">Attack< Exit ")
else write (" Attack >Exit<") end
term.setCursorPos(x, y)
a, b=os.pullEvent()
while a~="key"
do a, b=os.pullEvent() end
if b==203 and selection==2 then selection=1 end
if b==205 and selection==1 then selection=2 end
if b==28 then print ("") break end
end
if selection==1 then return true end
if selection==2 then return false end
return false
end
function atk()
attack=1
while true do
term.clear()
term.setCursorPos(1,2)
for i=1, 5, 1 do
if i==attack then print(i, " ["..m[i].."]") else print(i, " ", m[i]) end
end
print("Select your move:")
a, b= os.pullEventRaw()
if a == "key" then
if b==200 and attack>1 then attack=attack-1 end
if b==208 and attack<=1 then attack=attack+1 end
if b==28 then break end
end
end
term.clear()
term.setCursorPos(1,1)
return attack
end
while yN() == true do
if selection == 1 then
local moves={
"Tackle",
"Tail Whip",
"Growl",
"-",
"Back"
}
local attack=atk(moves)
print(attack)
else if selection == 2 then
break end
end
end