Howdy, Stranger!

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

Codea 3.3.2 (270)

dave1707dave1707 Mod
edited April 20 in Beta Posts: 9,109

@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.

Comments

  • Posts: 2,118

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

  • Posts: 613

    @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 
    
  • Posts: 2,118
    @piinthesky - instead of using e have you tried it with a table ie e = {} then define each as e[index] ?
  • dave1707dave1707 Mod
    Posts: 9,109

    @piinthesky Make this change to your above code.

            e.model = craft.model(asset.builtin.SpaceKit.spaceCraft3_obj)
    
  • Posts: 972
    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.
  • Posts: 613

    @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.

  • Posts: 2,118

    @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'.
    ???

  • dave1707dave1707 Mod
    Posts: 9,109

    @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.

  • Posts: 613

    does FULLSCREEN_NO_BUTTONS work anymore for you? I get buttons!

  • edited April 20 Posts: 613

    @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.

  • dave1707dave1707 Mod
    Posts: 9,109

    @piinthesky viewer.mode=FULLSCREEN_NO_BUTTONS works for me.

  • dave1707dave1707 Mod
    Posts: 9,109

    @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.

  • Posts: 613

    @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.

  • dave1707dave1707 Mod
    Posts: 9,109

    @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.

  • SimeonSimeon Admin Mod
    Posts: 5,587

    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
  • dave1707dave1707 Mod
    Posts: 9,109

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

  • Posts: 613

    @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.

  • dave1707dave1707 Mod
    Posts: 9,109

    @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.

  • edited April 22 Posts: 2,118

    @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.

  • edited April 23 Posts: 2,118

    @Simeon - may be old error as the file is quite an old one. Reported the crash with the error dialogue. Attached the physicssandbox project - can’t remember who wrote this.

    Possible suggestion, if you haven’t already done it, - record the Codea Verson number and iOS reference in the header of the project to eliminate that confusion. Note only when first run so you can check it’s existence - or does the iOS crash report pass that data in the error details?

  • Posts: 972

    World Generator doesn’t run. Screenshot of error message attached.

  • edited April 23 Posts: 2,118

    @Simeon - loaded a large Codea file, old file from forum for reading in text files, Massively indented. Reformatted by selecting all and using shift/indent to re-align. Note image shows that blank lines (grey bars) not re-indented is that the cause of the indentation problem.

  • Posts: 2,118

    @Simeon - just typed a text on a blank line, hoping to get textMode - it appeared with the other options but when I typed the last t the menu list disappeared, so anything longer than text may be missed.

  • dave1707dave1707 Mod
    Posts: 9,109

    @Bri_G if you would have typed the m after text (textm), textMode would have shown again to be selected.

  • Posts: 2,118

    @dave1707 - thanks for that, tried it out and can confirm that works.

  • SimeonSimeon Admin Mod
    Posts: 5,587

    @Bri_G if you want to change this behaviour, in the editor go to:

    Do -> Preferences...

    Turn on "Results for exact matches" in the AUTOCOMPLETE section at the bottom.

    This behaviour was disabled by default after some feedback indicating that people had to keep cancelling the autocomplete bar to see the symbol buttons

  • Posts: 2,118
    @Simeon - thanks for the info, will try out with it disabled but may return to it later. I kinda like the system, so will probably learn to use it as designed.
  • SimeonSimeon Admin Mod
    Posts: 5,587

    @Bri_G when "Results for exact matches" is enabled, autocomplete will continue to show results (if there are any) even if the current text you have entered matches a completion

    So for example, since text matches the text() function, with "Results for exact matches" disabled, the autocomplete bar will hide. If it is enabled, then autocomplete will continue to show other matches beginning with "text" (like textMode)

    I added this option because I wasn't sure what the best default setting is. I think @dave1707 prefers it disabled (currently the default) as he was having to dismiss the autocomplete bar too often to access the symbol keys

  • SimeonSimeon Admin Mod
    Posts: 5,587

    @piinthesky on line 27, where you set the material on the model, do this

    Instead of:

    e.model:setMaterial(thisMat,j)
    

    Do this:

    e:get(craft.renderer):setMaterial(thisMat, j)
    
  • Posts: 613

    @Simeon, hallelujah, that works!! Thanks

Sign In or Register to comment.