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

Problem with Indexation
http://www.fbacreator.com/fbaforum/viewtopic.php?f=2&t=220
Page 1 of 1

Author:  Root [ Sun Sep 27, 2009 4:44 pm ]
Post subject:  Problem with Indexation

Greatings FBA TC users and developer :D
I have registred here much erlyer, but didn't have reason(like this one) to "say hello" until now.
For start I would like to say Thank YOU! for Fba, looks like you've spend a hell of a time to make such a great developing tool.
And now to the Bug.
I've made a script but ther was some problem, I find out that it's about Indexation.
It is extracted from program and placed to this demo sample. You can just put it to
Quote:
main.fba
, RUN and press right side of project window.

Code:
function onmainloop()
clear(0,0,127)
fillrect(0,0,screenwidth()/2,screenheight(),127,0,0)
print(50,120,"quit",0,127,127)
print(screenwidth()/2+50,120,"start",127,127,0)
if mousedown()==1 then
   if mousein(0,0,screenwidth()/2,screenheight()) then
      quit()
   else
      FillMatrix()
   end
end
end

function FillMatrix()
pathx={}
for lx=0,100 do
    pathx[lx]={}
    for ly=0,100 do
        pathx[lx][ly]={}
    end
end
Progression(20,80)
end

function Progression(x,y)
    CheckQuadrant(x-1, y ,x,y)
    CheckQuadrant(x+1,y-1,x,y)
end

function CheckQuadrant(xin,yin,xor,yor) --<--<-- something rong at this function
           pathx[xin][yin] = pathx[xor][yor] -- here
            FullIndex("before "..xin..":"..yin.." : in ",pathx[xin][yin])
            FullIndex("before "..xor..":"..yor.." : or ",pathx[xor][yor])
           pathx[xin][yin][# pathx[xin][yin] + 1]=xor -- or here, or both
            FullIndex("after "..xin..":"..yin.." : in ",pathx[xin][yin])
            FullIndex("after "..xor..":"..yor.." : or ",pathx[xor][yor])
end

function FullIndex(text,lib)
debug(text)for num=1,# lib do debug(lib[num])end
end

in debug window got this
Code:
>> Output Debug Console
DEBUG: before 19:80 : in
DEBUG: before 20:80 : or
DEBUG: after 19:80 : in
DEBUG: 20
DEBUG: after 20:80 : or
DEBUG: 20
DEBUG: before 21:79 : in
DEBUG: 20
DEBUG: before 20:80 : or
DEBUG: 20
DEBUG: after 21:79 : in
DEBUG: 20
DEBUG: 20
DEBUG: after 20:80 : or
DEBUG: 20
DEBUG: 20

As we see
Code:
DEBUG: after 20:80 : or 
DEBUG: 20

and in the end
Code:
DEBUG: after 20:80 : or 
DEBUG: 20
DEBUG: 20

despite that original quadrant untouched
pathx[xor][yor]=={20,20}
but it should remain empty
HOW can it be? :shock:

Allso I found that wrighting 0 character to file imposible ( writefile(handle,string.char(0)) ), does it suppose to be like that or it's just a bug?

Thank you for any response.

P.S. Tomorow I'll try to post a small new function for Fba. :idea:

Author:  evilmaio [ Mon Sep 28, 2009 7:29 am ]
Post subject:  Re: Problem with Indexation

Root wrote:
Allso I found that wrighting 0 character to file imposible ( writefile(handle,string.char(0)) ), does it suppose to be like that or it's just a bug?


Mmmh..no it looks like a bug..maybe I consider files only in ascii mode.
Actually the only way to workaround this could be build an external dll.

Author:  Root [ Tue Sep 29, 2009 7:38 pm ]
Post subject:  Re: Problem with Indexation

I guess you didn't understand what is the problem with indexation.
simple description:
script Value of x
x={} _____ {nil}
x[1]={1} __ {{1}}
x[2]=x[1] _ {{1},{1}}
x[2][1]=2 _ should be {{1},{2}} but it is {{2},{2}}
x[1] somehow binding to x[2] in 3rd row

Author:  evilmaio [ Wed Sep 30, 2009 2:55 pm ]
Post subject:  Re: Problem with Indexation

Root wrote:
I guess you didn't understand what is the problem with indexation.
simple description:
script Value of x
x={} _____ {nil}
x[1]={1} __ {{1}}
x[2]=x[1] _ {{1},{1}}
x[2][1]=2 _ should be {{1},{2}} but it is {{2},{2}}
x[1] somehow binding to x[2] in 3rd row


Did you already read the LUA tables documentation?
http://www.lua.org/pil/2.5.html
Actually FBA is entirelly LUA based, so any script related questions should be covered in LUA docs.

Author:  napco [ Sun Oct 11, 2009 1:19 am ]
Post subject:  Re: Problem with Indexation

When using the assignment operator with tables you don't pass a copy of the table, but its "address":
Code:
t1 = {1, 2, 3, 4}
t2 = t1

t2 isn't = {1, 2, 3, 4}, but it's a "pointer" to t1...

Author:  Root [ Sun Oct 25, 2009 7:35 pm ]
Post subject:  Re: Problem with Indexation

Thank you. Sorry, little dumb question. I Just forgot about addresses and some other stuff.

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