Codea 3.3.2 (270)

@Simeon I copied some code from the forum an pasted it into a new project and the indentation is all screwed up. Almost every line is indented from the one above it.

@Simeon - same here, also tried copying whole tab and same effect.

@Simeon,
indexing starting from 1 seems ok.

Confirm tabbing and pasting fomat screwed up.

Contrary to what was indicated by @John in this thread https://codea.io/talk/discussion/10831/add-transparency-to-a-3d-obj-mtl-model#latest, i am unable to define different materials for multiple instances of the same model. It will work if each model is created individually. Am i doing something wrong?

-- PiInTheSky, test instances
    viewer.mode=FULLSCREEN

function setup()
    assert(OrbitViewer, "Please include Cameras as a dependency")        

-- Create a new craft scene    
    scene = craft.scene()   
    scene.farPlane=10000
    scene.nearPlane=0

--orbital viewer
    orv=scene.camera:add(OrbitViewer, vec3(0,0,0), 400, 0, 2000)
    
--model 
    myModel=craft.model(asset.builtin.SpaceKit.spaceCraft3_obj)
    nMat=myModel.submeshCount
    print("nMat=", nMat)

--create multiple instances    
    for i = 1,10 do
        local e = scene:entity()
        e.x =-50+ i*20
        e.model = myModel
        for j=1,nMat do
            local thisMat = randMaterial()
            e.model:setMaterial(thisMat,j)
        end
    end
end
            
-- Create a randomly coloured material
function randMaterial()
    mat = craft.material(asset.builtin.Materials.Standard)
    mat.diffuse = color(math.random(0,255), math.random(0,255), math.random(0,255))
    return mat
end

function update(dt)    
    memory = string.format("%.3f Mb",collectgarbage("count")/1024)
    scene:update(dt)
end

function draw()
    update(DeltaTime)  
    scene:draw()
end

function touched(touch)
    orv:touched(touch)
end 

@piinthesky - instead of using e have you tried it with a table ie e = {} then define each as e[index] ?

@piinthesky Make this change to your above code.

        e.model = craft.model(asset.builtin.SpaceKit.spaceCraft3_obj)

Indentation seems broken after all functions. If I tap return after a function I’m automatically indented one tab-stop, and it compounds, so after three functions I’m indented three tab-stops at the root level.

@dave1707 yes that does work (it is what i meant when each is created individually). As implied by the earlier thread i referred to, i hoped one could only have to load the model in once and then change the materials on all the instances of that single model.

@Bri_G no that does not help.

@dave1707 - modified @piinthesky 's code by addding the line you quoted and hiding the original line but didn’t work - error ‘attempt to index a nil value global e’.
???

@Bri_G I just copied it again and changed the line I show above. I didn’t add or delete anything else. When I run it I get an error because of the Camera dependency, but once I check that, it runs OK.

does FULLSCREEN_NO_BUTTONS work anymore for you? I get buttons!

@Simeon to get the select_all option in the editor the tab should be empty! or the first line in a tab needs to be empty. Not ideal.

@piinthesky viewer.mode=FULLSCREEN_NO_BUTTONS works for me.

@piinthesky If I tap any blank line in the editor, I get the Select, Select All, or Paste popup. The keyboard has to be showing for it to work.

@dave1707 weird, in a small test program NO_BUTTONS works, but in my big program it does not-not sure why!

Ahh i see, select all is available only for any empty lines. In previous versions i could tap on the top line and select all-very useful to copy.

Was it always the case that line numbers above 999 are truncated? Yes, i know i am a very bad programmer to have such big tabs.

@piinthesky @Simeon I looked on an older iPad that has Codea version 208 and the line numbers aren’t truncated. I think I remember an update where one of the comments was that the numbers weren’t going to be truncated. Apparently something changed in the later updates.

Thanks for all the feedback. Sorry I sent this build out a little earlier than I had planned (I’m setting up some build automation and figured, why not test out an automated build)

Just to collate the issues (let me know if I’ve missed any)

  • Indentation is messed up when pasting
  • Indentation level is failing to restore after a function ends
  • @piinthesky - @john suggested using entity:get(craft.renderer).material = myMaterial to have different materials on the same model instance when associated with different entities. I don’t see this code in your example (sorry if I missed it). Have you tried this?
  • FULLSCREEN_NO_BUTTONS is not working for @piinthesky
  • Unable to get select all option to display
  • Line numbers above 999 are being truncated

@Simeon The problem with img=image(CAMERA) used with img:get(1,1) not working.

@Simeon, entity:get(craft.renderer).material = myMaterial only allows to set all the materials to the same single material. Somehow @John managed to set multiple materials on multiple instances of same model.

@Simeon @John - just tidying up my mess of files and came across a Craft based demo using a sphere. When I ran it no issues, then I saw that the old system of addressing was still in use. Trying to use the new asset based addressing wouldn’t work. I seem to remember this was a planned update. If it’s due in V4 that’s OK just wanted clarification.

Edit: there is one issue with Project was “Project:Grid” and error Ed but Project.Grid or Project:Grid didn’t flash up an editor error but fired up a red text error.

Edit2: Please ignore the edit - just found you can tap on highlighted text and select resource from project resource window. Sorry ‘bout that.

Edit3: did find another issue though - I had a json text called night which was in documents. It described the skybox for the Environments resources which are called “Night Up” etc. But the Documents lister only seems to show image resources and there are not textual resources. The Environment resource has six night images in but no json text for displaying it. How do I get round this?

Edit 4: Aha, found some of the text assets in documents after the asset. prompt (as described in the error text) unfortunately I can’t find the day and night files that I had plus there are several text files present with the following text

“ Photos shared by iZip. iZip is a great Zip file management tool on mobile devices. I have used it and really liked it. You can install it for free here:

There was an internet address here which I removed.

Which I can’t remember ever seeing plus a couple of other random posts - weird.

@Simeon I don’t know if this was mentioned, but Codea was crashing when I tried to do a “CUT” after copying some lines of code. It happened every time when I was in a project, but now I can’t get it to happen.