@Simeon - resolved the problem - it was a clash between two arrays. Modified code added below. Note deleted touch as not used at moment and added small extra routine. Did this in previous version which did not crash. Believe this may be due to two errors incurred at once.
--
viewer.mode = LANDSCAPE_LEFT
function setup()
--
xmax,ymax,xmin,ymin = 100,100,100,100
planets = {}
scene = asset.documents.Dropbox.TyroGalaxies.galaxy06
readData(1)
end
function draw()
--
-- background(40, 40, 50)
spriteMode(CENTER)
sprite(scene,WIDTH/2,HEIGHT/2,WIDTH,HEIGHT)
fill(241, 222, 47)
font("Baskerville-SemiBold")
fontSize(32)
textMode(CENTER)
text("BBC MICRO ELITE - Galaxy 1",WIDTH/2,HEIGHT-40)
fill(154, 215, 218)
ellipseMode(CENTER)
starter = 1
for gl = 1, 256 do
pln,plX,plY,rad = planets[starter],planets[starter+3], planets[starter+4], planets[starter+11]
prad = math.floor(tonumber(rad/1000))
ellipse(tonumber(plX)*4,tonumber(plY)*3+1,prad,prad)
starter = starter + 14
end
stroke(255)
strokeWidth(2)
noFill()
ellipse(tonumber(planets[102]),tonumber(planets[103]),80,80)
fill(255)
textMode(CORNER)
fontSize(18)
text(planets[101],tonumber(planets[102])+20,tonumber(planets[103]+20))
end
function parsePlanet(str)
--
for value,_ in string.gmatch(str,"(.-)(,)") do
table.insert(planets,value)
end
end
function printAll()
--
print(table.concat(planets,"\
"))
print("ranges : ",xmin,xmax," : ",ymin,ymax)
end
function maxmin()
--
cplX,cplY = tonumber(plX),tonumber(plY)
if xmin > cplX then xmin = cplX end
if xmax < cplX then xmax = cplX end
if ymin > cplY then ymin = cplY end
if ymax < cplY then ymax = cplY end
end
function readData(pl)
--
-- galaxy_num,system_num,name,x,y,economy_id,economy,govtype_id,govtype,techlev,productivity,radius,population,description
path = asset.documents[galaxy[1]]
csv = readText(path)
parsePlanet(csv)
num = {}
sys = {}
name = {}
pos = {}
econ = {}
gov = {}
tech = {}
prod = {}
rad = {}
pop = {}
desc = {}
starter = 1
for gl = 1, 256 do
pln,plX,plY,rad = planets[starter],planets[starter+3], planets[starter+4], planets[starter+11]
maxmin()
print(starter.."- "..pln.." - "..plX..":"..plY.." rad "..rad.." = "..tonumber(plX)*tonumber(plY))
if gl < 255 then
starter = starter + 14
end
num[gl] = planets[starter]
pos[gl] = vec2(tonumber(planets[101]),tonumber(planets[102]))
end
-- planetData = {num = 8,pos = vec2(tonumber(planets[101]),tonumber(planets[102]))}
print(tonumber(planets[102]),tonumber(planets[103]))
end
galaxy = {
"Galaxy1"
}
If, ignoring my bad programming, hope you can see the changes and dig out the cause of the crash and, of course, resolve it.