I'm trying out a modified version of the StarField app, but I'm getting an error when running in the IDE -- as soon as I move the stylus over the screen:
when running in the IDE:
Quote:
ERROR: MAIN SCRIPT NOT EXECUTED: [string "MAIN.FBA"]:11: attempt to index field '?' (a nil value)
Here's the code:
Code:
nS=60
local nAccel = 1.07
local aPt={}
local nOffX = 160 -- offset, changes with stylus
local nOffY = 120 -- offset, changes with stylus
for nK=0, nS-1 do
-- assign real coordinates. the offset will be applied when displaying relative to the stylus ;o)
aPt[nK].X = math.random(0,240) - nOffX -- the point of visibility **Line11**
aPt[nK].Y = math.random(0,320) - nOffY -- the point of visibility
aPt[nK].CurrX = aPt[nK].X
aPt[nK].CurrY = aPt[nK].Y
end
function onmainloop()
-- new screen
clear(0,0,0)
for nK=0, nS-1 do
D=math.abs(aPt[nK].CurrX)
point(aPt[nK].CurrX + nOffX, aPt[nK].CurrY + nOffY, 255-(160-D),255-(160-D),255-(160-D))
-- prep for next iteration
aPt[nK].CurrX = aPt[nK].CurrX * nAccel
aPt[nK].CurrY = aPt[nK].CurrY * nAccel
if math.abs(aPt[nK].CurrX) > 240 or math.abs(aPt[nK].CurrY) > 320 then
-- reset to furthest point
aPt[nK].CurrX = aPt[nK].X
aPt[nK].CurrY = aPt[nK].Y
end
end
end
function onstylusup(x, y)
quit()
end
function onstylusdown(x, y)
nOffX = x
nOffY = y
end
function onstylusmove(x, y)
nOffX = x
nOffY = y
--debug("("..x..";"..y..")")
end
If the error is referring to "Line 11", then I'm baffled as to how control gets there when I simply move the cursor over the screen.
Where am I going wrong?
