FBA The Creator

The True Multiplatform PC / PocketPC Opensource Development Tool - Read Only Mode - Kept only for historical purposes - Thank you all ;)
It is currently Thu Jun 04, 2026 2:41 am

All times are UTC




Post new topic  Reply to topic  [ 4 posts ] 
Author Message
PostPosted: Tue Apr 01, 2008 2:31 pm 
Offline

Joined: Mon Mar 31, 2008 6:52 am
Posts: 18
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:


Top
   
PostPosted: Tue Apr 01, 2008 3:53 pm 
Offline
FBA Administrator
FBA Administrator
User avatar

Joined: Fri Mar 21, 2008 11:19 pm
Posts: 238
Location: Rome - Italy
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.


Top
   
PostPosted: Tue Apr 01, 2008 5:20 pm 
Offline
FBA Administrator
FBA Administrator
User avatar

Joined: Fri Mar 21, 2008 11:19 pm
Posts: 238
Location: Rome - Italy
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


Top
   
PostPosted: Wed Apr 02, 2008 6:14 am 
Offline

Joined: Mon Mar 31, 2008 6:52 am
Posts: 18
Great - thanks!

I still have a lot to learn ;)


Top
   
Display posts from previous:  Sort by  
Post new topic  Reply to topic  [ 4 posts ] 

All times are UTC


Who is online

Users browsing this forum: No registered users and 1 guest


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Jump to:  
cron
Powered by phpBB® Forum Software © phpBB Limited