Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Codea 3.1 (203)

13

Comments

  • SimeonSimeon Admin Mod
    Posts: 5,193

    @dave1707 I've hit that project opening bug a few times too but have not yet tracked it down. I think it happens if you open a new project soon after closing the old one and the project list sorting hasn't updated

    Some uses of the old asset strings won't cause warnings, but in that particular case I'll add a warning on assignment. Thanks for finding it.

    @Bri_G that happens because the old project was just modified, and the default sort order for project list is most recently modified. Normally the project should close into its new position, but sometimes the sort order lags behind the closing of the project, I'll look into this

  • dave1707dave1707 Mod
    Posts: 8,182

    @Simeon As I’m going from one project to the next, I’m not waiting very long between the closing of one and opening another.

  • SimeonSimeon Admin Mod
    Posts: 5,193

    @dave1707 fixed the page numbers on threads

  • dave1707dave1707 Mod
    edited February 24 Posts: 8,182

    @Simeon Is there anything I need to do. The page numbers at the bottom of the page still don’t work. I zoomed in to make sure I was hitting them, but nothing.

  • Posts: 1,595
    @dave1707 - page links at bottom of page work for me. Which browser are you on and is it mobile or full site?
  • dave1707dave1707 Mod
    edited February 24 Posts: 8,182

    @Bri_G I’m using Safari on my iPad Air 3 and iOS 13.3.1 . The page numbers at the top of the page work OK, but when I go back to page 1, there aren’t any page numbers at the top. Since the ones at the bottom don't work, I have to exit the forum and go back in to get to the current page.

    The bottom numbers don’t work with safari on my iPad Pro 1 iOS 13.3.1 either.

    They work on my iPad Air 1 with iOS 12.4.5 . So maybe iOS 13 is messing things up.

  • edited February 24 Posts: 1,595

    @Simeon @dave1707 - mixed results to report - tested mainly on android phone and found Opera worked fine but formatting different. On Mac Opera and Firefox didn't work but there was something unusual in that the links were placed above the empty 'Leave a Comment' dialogue box for the next post - at the top right hand corner. Looks like the text/links may have been placed in the wrong Div - would expect them in the Footer.

  • Posts: 1,595

    @Simeon @dave1707 - same on Safari and also on Safari have to log in for the page links to appear - top and bottom. Shouldn't they be there for anyone who wishes to scan all pages? regardless of logging in?

    Having said that I am permanently logged into my browsers! Top links work on Safari.

  • edited February 24 Posts: 1,595

    @Simeon @dave1707 - MS Edge both top and bottom work on Mac.

    p.s. the links, top and bottom are present if you are logged in or not. Looks like a browser problem and possibly web page issues across browsers. Edge uses the Android Chrome engine for the web pages.

  • dave1707dave1707 Mod
    edited February 24 Posts: 8,182

    Just to make myself clear, the page numbers at the bottom and top of the forum list 1 2 3 4 5 ... 100 works fine. It’s when I’m inside a large discussion like this one where I see < 1 2 3 > at the bottom and top of the page. The top set of numbers works, but the bottom set doesn’t.

    @Simeon While we’re on the subject of the page numbers, the numbers for the forum list only goes to 100. There are about 2 years of discussions that can’t be listed because they’re on pages greater than 100. You can get to them if you know what to search for, but not easily. Just a lot of old memories/progress that can’t be seen easily.

  • SimeonSimeon Admin Mod
    Posts: 5,193

    @dave1707 the bottom set of numbers in the thread should work now, but it could be that your browser has still cached the old CSS styling

    Could you try open the discussion in private browsing mode to see if it's working there? (To get to private browsing mode, tap the icon that shows all the tabs then tap "Private" then tap the + button, you will need to sign in again)

    If it's working in private mode it means that your local browser cache hasn't been updated. I'm not sure how to force Safari on iOS to reload a page fully / clear its cache. I'll look into it

  • SimeonSimeon Admin Mod
    Posts: 5,193

    @dave1707 I was able to clear the cache on my iPad by doing the following:

    • Close all tabs from codea.io in Safari
    • Fully close Safari (i.e., swipe up in the multitasking to kill it)
    • Open Settings -> Safari -> Advanced -> Website Data
    • Search for "codea" and when "codea.io" shows up, swipe left to delete it
    • Open Safari and load a discussion on codea.io (need to sign in again)
    • Page numbers should be fixed
  • dave1707dave1707 Mod
    Posts: 8,182

    @Simeon Thanks, that fixed it. Never thought of having to clear Safari for the line numbers. I normally clear all of the cached sites on a regular basis just to get rid of the junk there.

  • edited March 2 Posts: 464

    @Simeon i tried to copy an .obj 3d model from dropbox assets to my project assets using 'add to' in the asset picker. It seems the .obj file is copied over, but not the corresponding .mtl file. Is there a way to get the .mtl in the right place?

  • SimeonSimeon Admin Mod
    Posts: 5,193

    @piinthesky not at the moment if it's going to a project folder. I'd like to modify the asset pickers to show all files, including .mtl

  • dave1707dave1707 Mod
    edited March 3 Posts: 8,182

    @Simeon There’s a problem someplace with version 202. This code used to run very fast, now it hardly runs at all. If I run this on Codea version 189 on my slower iPad, it created the grid instantly and the ball moves across the grid OK, like it’s supposed to. If I run this on Codea version 202 on my faster iPad, it takes 2 min. to create the grid. I put a print statement in the function calc() so you can see it slowing down as it runs calc(). It’s not the print that’s slowing it, but the function create() that’s being called. If you comment out the function call create() in calc() then it runs fast but without the grid. So I’m not sure what changed with creating a cube in function create().

    PS. It’s this line that’s causing the slow down. Apparently the new asset is the problem.

        c.material = craft.material(asset.builtin.Materials.Standard)
    

    If you replace the above line with the old code, it runs fine.

        c.material = craft.material("Materials:Standard")
    
    function setup()
        tab={}
        assert(craft, "Please include Craft as a dependency")
        assert(OrbitViewer, "Please include Cameras (not Camera) as a dependency")
        scene = craft.scene()
        skyMaterial=scene.sky.material
        skyMaterial.sky=color(0, 255, 232, 255)
        skyMaterial.horizon=color(0, 251, 255, 255)
        scene.sun.rotation=quat.eulerAngles(20,45,-30)
        v=scene.camera:add(OrbitViewer, vec3(0,0,0), 400, 0, 1000)
        v.ry=45
        v.rx=20
        calc()
        pos=1
        aa=0
    end
    
    function create(x,y,z)
        local c=scene:entity()
        c.position=vec3(x,y,z)
        c.model = craft.model.cube(vec3(4,10,4))
        c.material = craft.material(asset.builtin.Materials.Standard)
        --c.material = craft.material("Materials:Standard")
        c.material.diffuse=color(0, 255, 59, 53)
    end
    
    function createSphere(x,y,z)
        if c~=nil then
            c:destroy()
        end
        c=scene:entity()
        c.position=vec3(x,y+5,z)
        c.model = craft.model.icosphere(1,1)
        c.material = craft.material(asset.builtin.Materials.Standard)
        --c.material = craft.material("Materials:Standard")
        c.material.diffuse=color(255, 0, 0, 53)
    end
    
    function draw()
        update(DeltaTime)
        scene:draw()
        aa=aa+1
        if aa>15 then
            pos=pos+61
            aa=0
        end
        createSphere(tab[pos].x,tab[pos].y,tab[pos].z)
    end
    
    function update(dt)
        scene:update(dt)
    end
    
    function calc()
        step=.05
        n=craft.noise.perlin()
        for x=-1.5,1.5, step do
            print(x)
            for z=-1.5,1.5,step do
                value = n:getValue(x,yVal,z)
                create(x*80,value*15,z*80)
                table.insert(tab,vec3(x*80,value*15,z*80))
            end
        end
    end
    
  • Posts: 1,595

    @dave1707 - confirmed, same on my pad. I take it cube size at 10 is to hide the gaps. I increased sphere y position to 10 to get full sphere as against hemisphere. Also in the perlin Calc I take it yVal defaults to zero - no error generated with that?

    Tried to dig around and change things but nothing else seemed to affect the calculation rate.

  • dave1707dave1707 Mod
    Posts: 8,182

    @Bri_G yVal probably defaults to 0, didn’t notice that. I probably did something with it at one point and forgot to remove it. I tried a few things too, but it came down to that one line causing the slowdown.

  • dave1707dave1707 Mod
    edited March 4 Posts: 8,182

    @Simeon Here’s a stripped down version of the asset problem. Shows the time it takes to do 1000 loops not using asset and using asset.

    function setup()
        s=require("socket")
        scene = craft.scene()
    
        c=scene:entity()
    
        print("not using asset")
        st=s:gettime()
        for z=1,1000 do
            c.material = craft.material("Materials:Standard")
        end
        en=s:gettime()
        print(en-st)
    
        print("using asset")
        st=s:gettime()
        for z=1,1000 do
            c.material = craft.material(asset.builtin.Materials.Standard)
        end
        en=s:gettime()
        print(en-st)
    end
    

    Here’s a way around the problem. Just get the asset once and use it after that. It’s also a lot faster.

    function setup()
        s=require("socket")
        scene = craft.scene()
    
        c=scene:entity()
    
        print("not using asset")
        st=s:gettime()
        for z=1,1000 do
            c.material = craft.material("Materials:Standard")
        end
        en=s:gettime()
        print(en-st)
    
        a = craft.material(asset.builtin.Materials.Standard)
    
        print("using asset")
        st=s:gettime()
        for z=1,1000 do
            c.material = a
        end
        en=s:gettime()
        print(en-st)
    end
    
  • Posts: 1,595

    @dave1707 - something funny with your post formatting.

    Very interesting - added a few of print statements. Run the following code and then de-rem the ‘and then .... ‘ print. Should it do that ?


    function setup() s=require("socket") scene = craft.scene() c=scene:entity() print("not using asset") st=s:gettime() for z=1,1000 do c.material = craft.material("Materials:Standard") end print(craft.material("Materials:Standard")) en=s:gettime() print(en-st) a = craft.material(asset.builtin.Materials.Standard) print("using asset") st=s:gettime() for z=1,1000 do c.material = a end en=s:gettime() print(a) -- print("and then .....") print(craft.material(asset.builtin.Materials.Standard)) print(en-st) end
  • dave1707dave1707 Mod
    Posts: 8,182

    @Bri_G Sorry, I forgot the ending ~~~, I fixed it. If you’re talking about the first run shows two of the path names and when you uncomment the “and then” it prints three, that’s the new print function in Codea. If you look at the paths when you run it with the “and then” commented, you’ll notice a 2 to the bottom right of the last path name. That means 2 of the same thing printed one after the other. The second time with it uncommentEd, you print something different in between the 2 path names so they’re not the same twice in a row.

  • SimeonSimeon Admin Mod
    Posts: 5,193

    Thank you for finding that performance regression, I've been trying to ensure the new asset stuff is equally as fast as the old, but I hadn't looked into extensive material use.

    For now, can you see if it runs faster if you cache the asset key to a local variable first?

    function setup()
        s=require("socket")
        scene = craft.scene()
    
        c=scene:entity()
    
        print("not using asset")
        st=s:gettime()
        for z=1,1000 do
            c.material = craft.material("Materials:Standard")
        end
        en=s:gettime()
        print(en-st)
    
        print("using asset")
        st=s:gettime()
        local standardMat = asset.builtin.Materials.Standard
        for z=1,1000 do
            c.material = craft.material(standardMat)
        end
        en=s:gettime()
        print(en-st)
    end
    
  • dave1707dave1707 Mod
    Posts: 8,182

    @Simeon Thats what I did in my example just above my previous post and it ran a whole lot faster.

  • SimeonSimeon Admin Mod
    Posts: 5,193

    Oops sorry I didn't read all the way through the thread

    Caching them is always going to be faster, though I really tried to optimise the speed in calls like sprite so that using the full key in-place would be as fast as the string variant

    I didn't consider craft.material as I wasn't expecting it to be called so often. I'll try optimise that scenario too, even if I can't get it as fast as caching the key I should be able to make it faster

  • SimeonSimeon Admin Mod
    Posts: 5,193

    Thanks for identifying this, it was a simple fix for the next build

    I was getting

    0.02s with string
    10.0s with full asset key path (!!)

    Now I get

    0.02s with string
    0.06s with full asset key path
    0.02s with cached asset key

    (where the cached key is local m = asset.builtin.Materials.Standard)

  • dave1707dave1707 Mod
    Posts: 8,182

    @Simeon Glad it was an easy fix. The speeds look great.

  • Posts: 1,595

    @dave1707 - just a quick note on your backup project, I found errors were produced with the new asset path listing etc. Previously I just used “Dropbox” but now the project is not working suggesting we use “asset.documents,Dropbox.all” instead. On running that path a Codea error is thrown up. Have you seen /resolved this?

    Also, could just be my eyes, but the .all at the end of the path looks to be formatted differently.

  • dave1707dave1707 Mod
    Posts: 8,182

    @Bri_G Heres the changes I made for my backup program. If I misses something, let me know, mine works OK after the changes.

    --saveText("Dropbox:"..backupName,str)
    saveText(asset.documents.Dropbox..backupName,str)
    
    --local lst=assetList("Dropbox")
    local temp=asset.documents.Dropbox.all
    
    sprite(asset.builtin.Cargo_Bot.Dialogue_Button,WIDTH/2,HEIGHT-a*75+dy,200,50)
    
    --bkupFile=readText("Dropbox:"..name)
    bkupFile=readText(asset.documents.Dropbox..name)
    
    sprite(asset.builtin.Cargo_Bot.Dialogue_Button,WIDTH/2,HEIGHT-a*75+dy,200,50)
    
    sprite(asset.builtin.Cargo_Bot.Dialogue_Button,575,HEIGHT-a*75+dy,150,50)
    
    sprite(asset.builtin.Cargo_Bot.Dialogue_Button,400,HEIGHT-a*75+dy,200,50)
    
    sprite(asset.builtin.Cargo_Bot.Dialogue_Button,575,HEIGHT-a*75+dy,150,50)
    
    sprite(asset.builtin.Cargo_Bot.Dialogue_Button,self.x,self.y,self.w,self.h)
    
  • Posts: 1,595

    @dave1707 - thanks for the update, recorded a backup file OK but when I ran the list backups it fired out an error in the following routine:


    local lst=asset.documents.Dropbox.all for a,b in pairs(lst) do if string.find(b,"bk") then table.insert(bkupTab,b) end end

    note - I changed lst to temp, as in your post, but still same error so I changed the other lst instances to temp - still an error ‘bad argument to find’. Which, I assume is due to the asset location definition. Which again raises the difference in format with .all at the end - was that intended or has it been omitted from the path?

  • dave1707dave1707 Mod
    Posts: 8,182

    @Bri_G Maybe there’s more changes then I realized. Here the whole code.

    displayMode(FULLSCREEN)
    
    function setup()
        delay=5
        pns="PROJ".."NAME".."START" -- project name start
        pne="PROJ".."NAME".."END"   -- project name end
        tns="TAB".."NAME".."START"  -- tab name start
        tne="TAB".."NAME".."END"    -- tab name end
        te="TAB".."END"             -- tab end
        pe="PROJ".."END"            -- project end
        bk1,bk2,bk3,bk4="","","",""
        msg1=""
        m1=button(WIDTH/2,HEIGHT-100,200,50,"Create a backup",createBkup)
        m2=button(WIDTH/2,HEIGHT-200,200,50,"Select a backup",getBkups)
        m3=button(WIDTH/2,HEIGHT-300,200,50,"Exit",exit)
        b1=button(190,HEIGHT-200,180,50,"Turn all projects on.",allOn)
        b2=button(190,HEIGHT-260,180,50,"Turn all projects off.",allOff)
        b3=button(190,HEIGHT-360,180,50,"Allow overwrite. OFF",allowOverwrite)
        b5=button(190,HEIGHT-520,180,50,"Restore selected items",restore)
        b6=button(190,100,180,50,"Return to menu",retn)
        func=menu
    end
    
    function draw()
        background(40, 40, 50)
        func()
    end
    
    function touched(t)
        if t.state==ENDED then
            if func==menu then
                m1:touched(t)
                m2:touched(t)
                m3:touched(t)
            elseif func==showBkups then
                for a,b in pairs(bkupTab) do
                    if math.abs(t.x-WIDTH/2)<100 and math.abs(t.y-(HEIGHT-a*75+dy))<25 then
                        selectedBackupFile=b
                        func=getProjects
                    end
                end
                b6:touched(t)
            elseif func==showProjects then
                for a,b in pairs(projTab) do
                    if math.abs(t.x-WIDTH/2)<100 and math.abs(t.y-(HEIGHT-a*75+dy))<25 then
                        b.sel=not b.sel
                    end
                end
                b1:touched(t)
                b2:touched(t)
                b3:touched(t)
                b5:touched(t)
                b6:touched(t)
            elseif func==showRestoreTable then
                b6:touched(t)
            end
        end
        if t.state==MOVING then
            if func==showProjects or func==showRestoreTable then
                if t.x<100 or t.x>WIDTH-100 then
                    sp=1
                    if t.y<HEIGHT/2 then
                        sp=20
                    end
                    dy=dy+t.deltaY*sp
                    if dy<0 then
                        dy=0
                    end
                end
            end
        end
    end
    
    function menu()
        fill(255)
        m1:draw()
        m2:draw()
        m3:draw()
        text(bk1,WIDTH/2,300)
        text(bk2,WIDTH/2,260)
        text(bk3,WIDTH/2,220)
        text(bk4,WIDTH/2,180)
    end
    
    function exit()
        close()
    end
    
    function retn()
        msg1=""
        func=menu
    end
    
    function createBkup()
        if delay>0 then
            func=createBkup
            text("Creating backup",WIDTH/2,HEIGHT/2)
            delay=delay-1
            return
        end
        local proj=listProjects("Documents")
        local t=os.date("*t")
        backupName=string.format("bkA%02d%02d%02d-%02d%02d",
                t.year%100,t.month,t.day,t.hour,t.min)
        local temp={}
        local dt=os.date()
        local cnt=0
        table.insert(temp,"BKUP==START.."..dt)
        for a,b in pairs(proj) do
            lst=listProjectTabs(b)
            cnt=cnt+1
            table.insert(temp,pns.."=="..b.."=="..pne)
            for c,d in pairs(lst) do
                table.insert(temp,tns.."=="..d.."=="..tne)
                table.insert(temp,readProjectTab(b..":"..d))
                table.insert(temp,"=="..te)
            end
            table.insert(temp,"=="..pe)
        end
        table.insert(temp,"BKUP==END")
        local str=table.concat(temp,"\n")
        bk1=backupName
        bk2=dt
        bk3="Projects saved = "..cnt
        bk4="File size = "..#str.." bytes"
        --saveText("Dropbox:"..backupName,str)
        saveText(asset.documents.Dropbox..backupName,str)
        delay=5
        func=menu
    end
    
    function getBkups()
        bk1,bk2,bk3,bk4="","","",""
        bkupTab={}
        showBackupTable=true
        dy=0
        --local lst=assetList("Dropbox")
        local temp=asset.documents.Dropbox.all
        local lst={}
        for a,b in pairs(temp) do
            s=string.find(a,".txt")
            if s~=nil then
                table.insert(lst,a)
            end
        end    
        table.sort(lst)
        for a,b in pairs(lst) do
            if string.find(b,"bk") then
                table.insert(bkupTab,b)
            end
        end
        func=showBkups
    end
    
    function showBkups()
        for a,b in pairs(bkupTab) do
            sprite(asset.builtin.Cargo_Bot.Dialogue_Button,WIDTH/2,HEIGHT-a*75+dy,200,50)
            text(b,WIDTH/2,HEIGHT-a*75+dy)
        end
        b6:draw()
    end
    
    function getProjects()
        text("Please wait, getting a list of all projects",WIDTH/2,HEIGHT/2)
        projTab={}
        local name=selectedBackupFile
        --bkupFile=readText("Dropbox:"..name)
        bkupFile=readText(asset.documents.Dropbox..name)
        if bkupFile==nil then
            alert("No backup file selected.","ERROR")
            return
        end
        local sss=pns.."==(.-)=="..pne
        for projName,proj in string.gmatch(bkupFile,sss) do
            table.insert(projTab,{proj=projName,sel=false,res=""})
        end
        dy=0
        func=showProjects    
    end
    
    function showProjects()
        text("Tap a project to select or unselect it.",WIDTH/2,HEIGHT-20+dy)
        for a,b in pairs(projTab) do
            tint(255)
            if b.sel then
                tint(0, 255, 0, 255)
            end
            sprite(asset.builtin.Cargo_Bot.Dialogue_Button,WIDTH/2,HEIGHT-a*75+dy,200,50)
            fill(255)
            text(b.proj,WIDTH/2,HEIGHT-a*75+dy)
            if b.res~="" then
                sprite(asset.builtin.Cargo_Bot.Dialogue_Button,575,HEIGHT-a*75+dy,150,50)
                text(b.res,575,HEIGHT-a*75+dy)
            end
        end
        tint(255)
        b1:draw()
        b2:draw()
        b3:draw()
        b5:draw()
        b6:draw()
        scrollArea()
        text(msg1,200,200)
    end
    
    function scrollArea()
        fill(97, 229, 165, 100)
        rect(0,HEIGHT/2+20,100,HEIGHT)
        rect(0,0,100,HEIGHT/2-20)
        rect(WIDTH-100,HEIGHT/2+20,100,HEIGHT)
        rect(WIDTH-100,0,100,HEIGHT/2-20)
        fill(255)
        text("SLOW\nSCROLL\nAREA",50,HEIGHT*.75)
        text("FAST\nSCROLL\nAREA",50,HEIGHT*.25)
        text("SLOW\nSCROLL\nAREA",WIDTH-50,HEIGHT*.75)
        text("FAST\nSCROLL\nAREA",WIDTH-50,HEIGHT*.25)
    end
    
    function allOn()
        for a,b in pairs(projTab) do
            b.sel=true
        end
    end
    
    function allOff()
        for a,b in pairs(projTab) do
            b.sel=falss
        end
    end
    
    function allowOverwrite(self)
        Allow_overwrite=not Allow_overwrite
        if Allow_overwrite then
            self.name="Allow overwrite.  ON"
            self.col=color(255,0,0)
        else
            self.name="Allow overwrite.  OFF"
            self.col=color(255)
        end
    end
    
    function restore()
        resTab={}
        msg1=""
        if projTab==nil or selectedBackupFile=="" then
            alert("No projects selected.","ERROR")
            return
        end
        dy=0
        cnt=0
        for a,b in pairs(projTab) do
            if b.sel then
                cnt=cnt+1
                pname=b.proj
                restoreProject()
            end
        end
        if cnt>0 then
            alert("Check for error messages.","RESTORE COMPLETE")
        else
            alert("Nothing selected for restore.","ERROR")
            return
        end
        allOff()
        if Allow_overwrite then
            allowOverwrite(b3)
        end
        dy=0
        func=showRestoreTable
    end
    
    function restoreProject()
        name=pname
        local sss=pns.."==(.-)=="..pne.."\n(.-)=="..pe
        if hasProject(name) then
            if Allow_overwrite then
                deleteProject(name)
            else
                table.insert(resTab,{proj=name,res="Overwrite   OFF"})
                return
            end
        end
        if not hasProject(name) then
            createProject(name)
            for projName,proj in string.gmatch(bkupFile,sss) do
                if name==projName then
                    getTab(proj)
                end
            end
            table.insert(resTab,{proj=name,res="Restored"})
        end
    end
    
    function getTab(proj)
        local sss=tns.."==(%g+)=="..tne.."\n(.-)\n=="..te
        for tabName,tab in string.gmatch(proj,sss) do
            saveProjectTab(name..":"..tabName,tab)
        end
    end
    
    function showRestoreTable()
        for a,b in pairs(resTab) do
            sprite(asset.builtin.Cargo_Bot.Dialogue_Button,400,HEIGHT-a*75+dy,200,50)
            fill(255)
            text(b.proj,400,HEIGHT-a*75+dy)
            sprite(asset.builtin.Cargo_Bot.Dialogue_Button,575,HEIGHT-a*75+dy,150,50)
            text(b.res,575,HEIGHT-a*75+dy)
        end
        b6:draw()
        scrollArea()
    end
    
    button=class()
    
    function button:init(x,y,w,h,n,f)
        self.x=x
        self.y=y
        self.w=w
        self.h=h
        self.name=n
        self.func=f
        self.col=color(255)
    end
    
    function button:draw()
        sprite(asset.builtin.Cargo_Bot.Dialogue_Button,self.x,self.y,self.w,self.h)
        fill(self.col)
        text(self.name,self.x,self.y)
    end
    
    function button:touched(t)
        if math.abs(t.x-self.x)<self.w/2 and math.abs(t.y-self.y)<self.h/2 then
            self.func(self)
        end
    end
    
  • Posts: 1,595

    @dave1707 - thanks for the fully updated code, there was a further change - both lst and temp were needed to run properly. This is a valuable tool - thanks again.

  • dave1707dave1707 Mod
    Posts: 8,182

    @Bri_G I used this when I got a new iPad. It took about 5 sec. to load 600+ projects onto the new iPad.

  • Posts: 1,595
    @dave1707 - yes very fast and handy. Have it on both my pads. Looking to slim down the number now - have too many unfinishd projects. Thanks.
  • Posts: 78

    @Dave1707 With your Programm I allways get the following error Message.
    Main:..attempt to Index a Nil value (‚global ‚asset). I have a iPad Pro Version 13.3.1
    Codea 3.01(192). How can I fix this.Thank you also for your many contributions.

  • Posts: 1,595
    @matox - could you post a few lines of code around where the error is so members can see what is causing it. Also the full text if the error would help.
  • SimeonSimeon Admin Mod
    Posts: 5,193

    @matox dave's program is for the current beta version of Codea, v3.1 — not 3.0.1. He's using a new API that will be available in the next version and is not currently in the App Store version of Codea.

  • Posts: 1,595
    @matox - @dave1707 posted the code before recent changes were made in the beta. The full code is posted within the forum if you'd like to search for it.
  • dave1707dave1707 Mod
    Posts: 8,182

    @matox Heres a link to a version that should work on the previous version of Codea.

    https://codea.io/talk/discussion/9210/moving-to-a-new-ipad-best-way-to-take-my-code
    
  • Posts: 480

    I'm not on the most recent beta (I have to keep switching Apple Id's on the iPad that can cope with it - using the link from TestFlight doesn't work) so this might not still be relevant, plus I haven't read every comment so it might already be noted somewhere.

    Anyway, it appears that text now has a maximum size different to what it was before. Is that intentional? Long text simply doesn't display. Is the maximum length to do with characters or pixels?

  • dave1707dave1707 Mod
    edited March 10 Posts: 8,182

    @LoopSpace I think in the past any text string that exceeded the screen width disappeared. I tried it now and it looks like the text disappears when the size exceeds 1024 pixels. So when the screen width is larger than 1024 pixels, the text disappears before filling the screen width.

    Apparently the Apple ID you’re using isn’t recognized as a beta tester. There’s no problem with the TestFlight link.

  • dave1707dave1707 Mod
    Posts: 8,182

    @Simeon I don’t know if this is supposed to happen or not, but if I create too many craft models, it not only crashes Codea, but crashes my iPad. I guess it’s filling up memory. Don’t know if there’s a way to stop it other than not creating so many models. Not sure how many are created before the crash.

  • SimeonSimeon Admin Mod
    Posts: 5,193

    @dave1707 would I be able to recreate this by creating lots of Craft models in a loop or something? It's possible they're using too much memory

    Are you drawing lots of Craft models or is just creating and discarding them crashing?

  • dave1707dave1707 Mod
    Posts: 8,182

    @Simeon Here’s the code that crashes Codea and the iPad. This creates a textured terrain you can fly around. Tilt the iPad left or right to turn left or right. Tilt forward or back to go down or up. This runs OK now with val=10 in the function create(). If you increase the value of val to a larger number, 20 or 30, it will crash everything. Probably a memory issue. I would expect Codea to crash, but I was surprised that the iPad crashed.

    displayMode(FULLSCREEN)
    
    function setup()
        assert(OrbitViewer, "Please include Cameras (not Camera) as a dependency")        
        hgx,tilt,hgz=0,0,-999
        speed,ey,ang=.5,0,0
        cameraX,cameraZ=-100,40
        scene = craft.scene()
        scene.camera.eulerAngles=vec3(ex,ey,ez)
        texture=readImage(asset.builtin.Surfaces.Desert_Cliff_Color)
        cm=craft.material(asset.builtin.Materials.Basic)  
        h=craft.noise.perlin()
        create()
    end
    
    function create()
        local val=10    -- change this to 20 or higher to crash ipad
        local step=.2
        local size=200
        local groundHeight=100  
        for x=-val,val,step do
            for z=-val,val,step do           
                local y=h:getValue(x,0,z)
                local p1=vec3(x*size,y*groundHeight,z*size)
                y=h:getValue(x+step,0,z)
                local p2=vec3((x+step)*size,y*groundHeight,z*size)
                y=h:getValue(x+step,0,z+step)
                local p3=vec3((x+step)*size,y*groundHeight,(z+step)*size)
                y=h:getValue(x,0,z+step)
                local p4=vec3(x*size,y*groundHeight,(z+step)*size)
                createTile(p1,p2,p3,p4)
            end
        end
    end
    
    function draw()
        update(DeltaTime)
        scene:draw() 
        updateCameraPos()
        checkTilt()
    end
    
    function updateCameraPos()
        ey=ey-ang
        x=speed*math.sin(math.rad(ey))
        z=speed*math.cos(math.rad(ey)) 
        cameraX=cameraX+x
        cameraZ=cameraZ+z
    end
    
    function checkTilt()
        gx=Gravity.x
        ang=ang+(gx-hgx)*4
        hgx=gx
        if gx>-.001 and gx<.001 then
            ang=0
        end    
        if hgz == -999 then
            hgz=Gravity.y
        end
        gz=Gravity.y
        tilt=tilt-(gz-hgz)*5
    end
    
    function update(dt)
        scene:update(dt)
        scene.camera.position = vec3(cameraX,30+tilt,cameraZ)
        scene.camera.eulerAngles=vec3(0,ey,0)
    end
    
    function createTile(p1,p2,p3,p4)
        local c=color(255)    
        local pt=scene:entity()
        pt.model = craft.model()
        pt.model.positions={p1,p3,p4,p1,p2,p3}
        pt.model.indices={1,2,3,4,5,6,6,5,4,3,2,1}
        pt.model.colors={c,c,c,c,c,c}
        pt.model.uvs={vec2(0,0),vec2(1,1),vec2(0,1),vec2(0,0),vec2(1,0),vec2(1,1)}
        pt.material = cm
        pt.material.map=texture 
    end
    
  • dave1707dave1707 Mod
    edited March 11 Posts: 8,182

    @Simeon Codea version 203 crashes.

    The change you made for material works fine. Changing pt.material from pt.material=cm to pt.material = craft.material(asset.builtin.Materials.Basic) doesn’t slow the program down like it did.

    Changing the last line from pt.material.map=texture to pt.material.map=readImage(asset.builtin.Surfaces.Desert_Cliff_Color) crashes Codea after awhile.

  • edited March 11 Posts: 464
    @Simeon on iphone12, the colorpicker icon appears next to a color() even when the line has been commented out. For this case, touching the icon causes codea to hang and stop responding.
  • dave1707dave1707 Mod
    Posts: 8,182

    @Simeon On my iPad, if I comment out color(), the color picker disappears, so it not a problem on the iPad.

  • Posts: 1,595

    @Simeon - using 203 and ran into problem with system locking up, probably same feature as @dave1707 reported. I was building a large texture and it was going slow so I tried to access the editor by closing the running project. When it came out of the run mode the editor didn’t respond to scrolling by stroking the scheme and the keyboard didn’t appear straight away. Eventually the keyboard appeared and the editor returned to normal screening.

    Seems like the system is locked into the run mode and can not respond to the exit button. I’ll try to put a simple demo up to show this.

  • dave1707dave1707 Mod
    Posts: 8,182

    @Simeon I was also running into something similar to what @Bri_G was describing. When I was working on the above terrain program, there were times when I would exit the running code, but the editor wouldn’t respond for maybe 5 seconds or more. I couldn’t scroll or type or do anything. I figured my program was taking up a lot of memory and Codea was just clearing what was built up. That was on the previous version 202.

  • SimeonSimeon Admin Mod
    Posts: 5,193
    @piinthesky thanks for the bug report on commented colour functions

    @dave1707 @Bri_G so 203 locks up on the editor screen? is it not responsive to touches?
  • SimeonSimeon Admin Mod
    Posts: 5,193
    Ah i notice the bug on the PlanetGenerator file in the Planet 3D project
Sign In or Register to comment.