Homebrew [Release] Lua Player Plus 3DS (lpp-3ds) - LUA interpreter for 3DS

  • Thread starter Thread starter Rinnegatamante
  • Start date Start date
  • Views Views 187,231
  • Replies Replies 1,199
  • Likes Likes 35
I'm at my wit's end with a bug in my code that I've come across.

The error message is
Code:
Error: [string "?"]:120: attempt to index a nil value (field '?')
and shows up when I try to launch my program's file browser.

But I've checked all my scripts and even after commenting out the two scripts which have a table reference on line 120, I get the same error.
I then decided to add empty lines to the start of all my scripts to figure out which one it is, but it still says the error is at line 120.
 
I'm at my wit's end with a bug in my code that I've come across.

The error message is
Code:
Error: [string "?"]:120: attempt to index a nil value (field '?')
and shows up when I try to launch my program's file browser.

But I've checked all my scripts and even after commenting out the two scripts which have a table reference on line 120, I get the same error.
I then decided to add empty lines to the start of all my scripts to figure out which one it is, but it still says the error is at line 120.

If you don't post your script, we can't help you.
 
If you don't post your script, we can't help you.

That error does mean the issue is at line 120, right?

I don't know if this is sufficient code but, here's snippets of all my scripts that are 120 lines or longer:

lines 100 through 130 of index.lua
Code:
            Graphics.drawImage(0,0, img_arc_filebrowser_board, white)
            Graphics.drawImage(9,46+ (selector-1-selector_scroll)*13, img_arc_filebrowser_selector, white)
            --[[
            if filebrowser_arc_dir[selector-1] ~= nil then
                if filebrowser_arc_info[filebrowser_arc_dir[selector-1].name] ~= nil then
                    gpu_drawtext_ml(214,39, filebrowser_arc_info[filebrowser_arc_dir[selector-1].name], c15, 73)
                else
                    gpu_drawtext_ml(214,39, "NO INFO ON THIS FILE", c15, 73)
                end
            end
            ]]--
            if filebrowser_arc_dirsize > 10 then
                Graphics.drawImage(196,41, img_arc_filebrowser_scrollbar, white)
                local bb=0 --bar begin
                local be=0 --bar end
                bb = math.floor(selector_scroll/(filebrowser_arc_dirsize+1) * 141) --the size of the scrollbar's drawable space (197,47 to 199,187)
                be = math.ceil((selector_scroll+11)/(filebrowser_arc_dirsize+1) * 141)
                Graphics.fillRect(197, 200, 47+bb, 47+be, c90)
            end
          
            local c = 0
            local i=0
            if selector_scroll == 0 then
                if selector==1 then c = c90    else c = c15 end
                Graphics.drawImage(11,47, filebrowser_arc_dir[0].icon, c)
                gpu_drawtext(29,51, "..", c)
                i=i+1
            end
          
            while i<filebrowser_arc_dirsize+1 and i<11 do
                --i is the slot on the screen, selector is the number selected, selector_scroll is the offset of the screen

lines 100 through 130 of text_init.lua
Code:
        glyph_l['F'],glyph_r['F'] = 61,63
        glyph_l['G'],glyph_r['G'] = 65,67
        glyph_l['H'],glyph_r['H'] = 69,71
        glyph_l['I'],glyph_r['I'] = 73,75
        glyph_l['J'],glyph_r['J'] = 77,79
        glyph_l['K'],glyph_r['K'] = 81,83
        glyph_l['L'],glyph_r['L'] = 85,87
        glyph_l['M'],glyph_r['M'] = 89,95
        glyph_l['N'],glyph_r['N'] = 97,99
        glyph_l['O'],glyph_r['O'] = 101,103
        glyph_l['P'],glyph_r['P'] = 105,107
        glyph_l['Q'],glyph_r['Q'] = 109,111
        glyph_l['R'],glyph_r['R'] = 113,115
        glyph_l['S'],glyph_r['S'] = 117,119
        glyph_l['T'],glyph_r['T'] = 121,123
        glyph_l['U'],glyph_r['U'] = 125,127
        glyph_l['V'],glyph_r['V'] = 129,131
        glyph_l['W'],glyph_r['W'] = 133,139
        glyph_l['X'],glyph_r['X'] = 141,143
        glyph_l['Y'],glyph_r['Y'] = 145,147
        glyph_l['Z'],glyph_r['Z'] = 149,151
      
        glyph_l["'"],glyph_r["'"] = 153,155
        glyph_l['*'],glyph_r['*'] = 157,159
        glyph_l[':'],glyph_r[':'] = 161,163
        glyph_l['['],glyph_r['['] = 165,167
        glyph_l[']'],glyph_r[']'] = 169,171
        glyph_l['('],glyph_r['('] = 173,175
        glyph_l[')'],glyph_r[')'] = 177,179
        glyph_l['='],glyph_r['='] = 181,183
        glyph_l['!'],glyph_r['!'] = 185,187

lines 100 through 130 of commands_init.lua
Code:
            elseif selector==4 then cli_addline("RVEMAIL.ARC",c90)
            elseif selector==5 then cli_addline("BBS.ARC",c90)
            elseif selector==6 then cli_addline("GUI_CONFIG.ARC",c90)
            elseif selector==7 then cli_addline("KEYBOARD.ARC",c90)
            end
            confirm = false
        end
    end
  
    if keyboard_arc then
        if (Controls.check(pad,KEY_X)) and not (Controls.check(oldpad,KEY_X)) then --close keyboard by pressing X
            keyboard_arc = false
            --remember to also clear the line here (is this needed though?)
        else
            keyboard_input()
        end
    end
  
    if filebrowser_arc then
        if (Controls.check(pad,KEY_X)) and not (Controls.check(oldpad,KEY_X)) then
            filebrowser_arc = false
        else
            menunav()
            while selector > selector_scroll+11 do --scroll
                selector_scroll = selector_scroll +1
            end
            while selector <= selector_scroll do
                selector_scroll = selector_scroll -1
            end
        end
        if confirm then

lines 100 through 130 of load.lua
Code:
        redraw = 2
        --redraw = {}
        --redraw[TOP_SCREEN] = 2
        --redraw[BOTTOM_SCREEN] = 2
    end
  
    if pass==8 then
        dofile(appdir.."/bios/commands_init.lua")
        dofile(appdir.."/bios/menunav_init.lua")
        dofile(appdir.."/bios/keyboard_init.lua")
    end

    --////////////////////////////////////////////////////////
    --Programs and Gui
    --////////////////////////////////////////////////////////

    if pass==9 then
        topscreen_enabled = false

        function closeall()
            logingui_arc = false
            mainmenu_arc = false
            filebrowser_arc = false
            bbs_arc = false
            rvemail_arc = false
        end
        closeall()
      
        keyboard_arc = false
        uploader_arc = false
[/spoiler

If you need more info I can just upload the whole program
 
Last edited by HexZyle,
It's useless you post only a part of your code.

Error could be related to a missing end for example.
You should post all your scripts and also telling where you put them (to check if there aren't file placing errors).
Maybe it will be better if you start a repository on GitHub.
 
You might be better off running it yourself. I'll look into whether or not I'm missing if and while statement closures in the meantime though.
 
At the Menu, navigate to "File Browser" using the D-Pad and press "A"

These controls are handled in menunav()
Pressing A flags a variable named "confirm" to true, any processes that use that will detect that and enact their specific function.

The most recent functions I had been implementing was a multiline text drawing function gpu_drawtext_ml() and a "file info" feature initialized at the end of filebrowser_init.lua and drawn on line 110 of index.lua
 
Last edited by HexZyle,
Okay then. Maybe I need a clean install. Are you using Citra or 3DS to run the program?
 
Is it possible to use an array as named arguments in a lua function? i.e.

Code:
function(array[1],array[2],array[3],array[4])
    local i=1
    while array[i] ~= nil do
        i=i+1
    end
    print("there are ".. tostring(i-1) .. " arguments")
end

Because when I do it, lua doesn't seem to like the bracket arrangement on the first line, nor does it like the array.i syntax.
 
Last edited by HexZyle,
Is it possible to use an array as named arguments in a lua function? i.e.

Code:
function(array[1],array[2],array[3],array[4])
    local i=1
    while array[i] ~= nil do
        i=i+1
    end
    print("there are ".. tostring(i-1) .. " arguments")
end

Because when I do it, lua doesn't seem to like the bracket arrangement on the first line, nor does it like the array.i syntax.

If you want to do something like array.name you should use something like this:

Code:
array = {["name"] = "bye bye"}

With this, array.name will be set to "bye bye"

Example in action: https://github.com/Rinnegatamante/RPG-Maker-3DS/blob/master/scripts/rendering.lua#L152-L179 & https://github.com/Rinnegatamante/RPG-Maker-3DS/blob/master/settings/hero1.lua

--------------------- MERGED ---------------------------

If you want to do something like array.name you should use something like this:

Code:
array = {["name"] = "bye bye"}

With this, array.name will be set to "bye bye"

Example in action: https://github.com/Rinnegatamante/RPG-Maker-3DS/blob/master/scripts/rendering.lua#L152-L179 & https://github.com/Rinnegatamante/RPG-Maker-3DS/blob/master/settings/hero1.lua

If you're talking about passing an array to a function, it could be done but your function is passing an element of an array, not an array itself.
 
If you're talking about passing an array to a function, it could be done but your function is passing an element of an array, not an array itself.

No, that's not what I wanted to do. I wanted a temporary array that exists just inside the function, so I can handle all the arguments with a single block instead of having to write a new "if argument1 = blah then do stuff", then "if argument2 = blah then do stuff" for every single different argument title. In GML, the arguments for scripts are referred to as "argument0" through "argument8", or they can also be referred to as "argument[0]" through "argument[8]", so the array functionality in the arguments is already inbuilt.

I figured that the function will only initialize a single local variable, so therefore it won't initialize both the table and a cell on that table in the same line. It also will not add the variable to the array even if the array has previously been initialized, so I used this instead, which is still fairly compact and gets me the effect I wanted.

Code:
function(a1,a2,a3,a4)
    local array = {a1,a2,a3,a4}
    local i=1
    while array[i] ~=nil do
        i=i+1
    end
    print("there are ".. tostring(i-1).." arguments")
end

Random question: What is faster, if at all - drawing a image file that's 10x10, or partial drawing a 10x10 section of a larger image file?
 
Last edited by HexZyle,
Random question: What is faster, if at all - drawing a image file that's 10x10, or partial drawing a 10x10 section of a larger image file?

It depends on your code. If the image is loaded once and then used different times, it should be the same (but you'll have less loading time).
 
It depends on your code. If the image is loaded once and then used different times, it should be the same (but you'll have less loading time).

I definitely noticed the massive decrease in loading time when I switched from individual images to a spritesheet when developing my own gpu text drawing function, (though the long loading time was actually what drove me to developing a loading screen) but seeing as that was early on in development and my 3DS was still knocking out 30 FPS with no drops, I didn't notice any difference in framerate when I switched over.

I'm asking now because I'm starting to get framedrops down to 20FPS (even down to 12FPS in some severely cluttered parts) due to how much stuff is being drawn and I'm looking to optimize my code in any way possible. Normally a lower framerate wouldn't bother me because response time isn't critical, but the random black flicker that occurs every now and then when the framerate is below 20 is really fucking annoying.
 
Last edited by HexZyle,
I definitely noticed the massive decrease in loading time when I switched from individual images to a spritesheet when developing my own gpu text drawing function, (though the long loading time was actually what drove me to developing a loading screen) but seeing as that was early on in development and my 3DS was still knocking out 30 FPS with no drops, I didn't notice any difference in framerate when I switched over.

I'm asking now because I'm starting to get framedrops down to 20FPS (even down to 12FPS in some severely cluttered parts) due to how much stuff is being drawn and I'm looking to optimize my code in any way possible. Normally a lower framerate wouldn't bother me because response time isn't critical, but the random black flicker that occurs every now and then when the framerate is below 20 is really fucking annoying.

If the text is static you can blit it once and refresh screen only when needed.
 

Site & Scene News

Popular threads in this forum