Howdy, Stranger!

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

CodeaUnit throwing strange error

Because CodeaUnit wouldn’t work as a dependency, I’ve started including it as a tab, and it has worked. However, in my most recent use, it sometimes gives the strange error reported in Bugs:

attempt to call a table value
stack traceback:

There is no traceback shown, and the program’s setup has already run correctly. The program is now dead in the water: I suppose that’s no surprise.

If I restart the program with the recycle button, it works correctly.

CodeaUnit sets up a parameter:

parameter.action("CodeaUnit Runner", function()
    print("button running")
    CodeaUnit.execute()
end)

When it fails, the “button running” message does not come out. So it is as if the failure is near the button logic.

I’m at a loss as to how to chase this. Recycling the program seems always to avoid the problem.

Advise me, please.

Comments

  • SimeonSimeon Admin Mod
    Posts: 5,054
    That is odd. The button running message should not print unless you tap the button though? And this error occurs before you tap the button?
  • No, sorry. When the program starts, my setup prints run. The “button running” message does not come up, as expected. If I press the rerun button, then the CodeaUnit button, all works as it should.

    In what’s below, by Fresh Run I mean I’ve been in the source and pressed that run button.

    Fresh Run
    Setup print runs
    Button appears (button running does not print)
    Press button
    - print does not appear
    - tests do not run
    - error message appears with no stack trace

    Fresh Run
    Setup print runs
    Button appears, button running does not print
    Press Recycle
    Setup print runs again
    Button appears, does not print
    Press button
    Everything works normally

  • SimeonSimeon Admin Mod
    Posts: 5,054

    Thanks you for the steps. Is this project possible for you to export as a zip file and allow me to test it?

  • Happy to. How shall I get it to you?

  • Duh. :)

    Path.zip 115K
  • SimeonSimeon Admin Mod
    Posts: 5,054

    @RonJeffries great! I can reproduce the bug here so I'll try to fix it.

    Apple is taking so long with 2.6.2 I think I'll be rejecting it in favour of submitting 2.6.3 so I can include bug fixes like this (and others)

  • SimeonSimeon Admin Mod
    Posts: 5,054

    This bug is fixed for 2.6.3, it happens when parameter.action is defined in the global scope (rather than in the setup() function or similar) and comes about because of the way Codea was checking projects for errors by initially evaluating the Lua code.

  • edited December 2018 Posts: 1,400

    @Simeon - I had a funny error, it could be my lack of understanding Codea under the hood, I was playing with a project which operated in two modes. In each mode it used parameters to make changes. The project fired up an error but, if I continued changing the parameters and using an action button part of the program still seemed to be running. I didn’t think that was feasible - the error seemed to be coming from a Craft section and the running part from reading and printing using json decoding a file.

    An oddity - whilst setting up a new project, on pressing the new button, the button seemed to rise off the screen with a fainter copy of the button behind it. It does look like you have overlaid the projects screen in a separate layer above the background - is that what I am seeing?

  • Super, Simeon, thanks!

  • SimeonSimeon Admin Mod
    Posts: 5,054

    @Bri_G The first one could be related to this bug, having a test project would be a good way for me to try debug it. On the latter issue it's because the beta version has drag-and-drop enabled on the project browser so I could see how it feels. That will be disabled for the App Store release until I put in functionality so you can drag and drop projects between sections and into/out of Codea.

  • edited December 2018 Posts: 1,400

    @Simeon - you are probably right, looks a little like the error @dave1707 mentioned. Knocked up a bit of code to demonstrate. Note deliberate error introduced in Serror which should be Sview.


    -- Error2 -- Use this function to perform your initial setup function setup() -- boxinit() scene = craft.scene() myEntity = scene:entity() parameter.integer("Sview",1,#views,1) parameter.action("Load", function() changeView(Serror) end) parameter.boolean("EnvMap", false, function(b) if b then scene.sky.material.envMap = env changeView(Sview) else scene.sky.material.envMap = nil end end) end -- This function gets called once every frame function draw() -- This sets a dark background color background(40, 40, 50) end function changeView(S) -- if EnvMap then tab1 = readText(views[S].ename) print(tab1) env = craft.cubeTexture(json.decode(tab1)) scene.sky.material.envMap = env else -- tab = readText(views[S].ename) img = nil img = json.decode(tab) imgRight = readImage(img[1]) imgLeft = readImage(img[2]) imgBack = readImage(img[3]) imgUp = readImage(img[4]) imgFront = readImage(img[5]) imgDown = readImage(img[6]) print(tab) end end function boxinit() -- views = {{ename = "Environments:Night"}, {ename = "Environments:Sunny"} } end

    Code based on @Johns Craft demo. If you run and use the slider and action buttons you will see the repeated error and printing of json files.

Sign In or Register to comment.