FBA The Creator
http://www.fbacreator.com/fbaforum/

ERROR: MAIN SCRIPT NOT EXECUTED .. when moving stylus?
http://www.fbacreator.com/fbaforum/viewtopic.php?f=5&t=18
Page 1 of 1

Author:  trids [ Tue Apr 01, 2008 2:31 pm ]
Post subject:  ERROR: MAIN SCRIPT NOT EXECUTED .. when moving stylus?

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?
:cry:

Author:  evilmaio [ Tue Apr 01, 2008 3:53 pm ]
Post subject:  Re: ERROR: MAIN SCRIPT NOT EXECUTED .. when moving stylus?

Mmmh..i just found a strange behaviour on the windows FBA player (it shouldn't be present on the PPC version)...
It's related to mouse movements and actually it could explain why your script is interrupted while you move your mouse...
I'm going to check this and i'll release a new version in few hours ;)
Thanks.

Author:  evilmaio [ Tue Apr 01, 2008 5:20 pm ]
Post subject:  Re: ERROR: MAIN SCRIPT NOT EXECUTED .. when moving stylus?

I'm checking for that issues, btw changing your code like the following, worked for me ;)
This should solve also your problem; actually i noticed that on some Windows system, the main script is not called until you move the mouse on main window :o

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]={}
        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

Author:  trids [ Wed Apr 02, 2008 6:14 am ]
Post subject:  Re: ERROR: MAIN SCRIPT NOT EXECUTED .. when moving stylus?

Great - thanks!

I still have a lot to learn ;)

Page 1 of 1 All times are UTC
Powered by phpBB® Forum Software © phpBB Limited
https://www.phpbb.com/