Forum

> > CS2D > Scripts > Lua error pointing to commented section
Forums overviewCS2D overview Scripts overviewLog in to reply

English Lua error pointing to commented section

1 reply
To the start Previous 1 Next To the start

old Lua error pointing to commented section

VADemon
User Off Offline

Quote
TL;DR: I basically give up debugging this code. I wanted to use user EngiN33R 's file cs2d [EngiN33R] UniMenu for this and I've put it into a global table because I made quite some changes to it and didn't want so many variables to in the global space... and after some point it started giving me the weirdest error I've ever seen. Not only is the error totally wrong (inside the multi-line comment) but I also fail to find any "menus" attempting to get its value from the global table.
Error message:
1
2
3
4
5
[19:59:47] VADemon: !f2
[19:59:48] LUA ERROR: sys/lua/autorun/multiserveraction.lua:98: attempt to index global 'menus' (a nil value)
[19:59:48]  -> sys/lua/autorun/multiserveraction.lua:98: in function <sys/lua/autorun/multiserveraction.lua:91>
[19:59:48]  -> in Lua hook 'menu', params: 1, 'Weapon Shop Page 1', 4
[19:59:48] ELLO!

How to reproduce:
• !f2 in chat
• Click on any menu entry

Code: http://pastebin.com/V7EVYsQQ

Code >


UPD: It's called SugarStick now.
edited 1×, last 06.09.15 03:35:28 am

old Re: Lua error pointing to commented section

DC
Admin Off Offline

Quote
The debug message also says that the code part is triggered by the menu hook which means that it must be triggered by this code part:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
addhook("menu","nigger.unimenuhook")
function nigger.unimenuhook(id, menu, sel)
        local p = tonumber(menu:sub(-1))
        if sel < 8 and sel > 0 then
                local s = sel+(7*(p-1))
                if type(nigger.pmenu[id]) == "table" then
                        nigger.pmenu[id].items[s][3](id)
                else
                        nigger.menus[nigger.pmenu[id]].items[s][3](id)
                end
        else
                if sel == 8 then
                        nigger.unimenu(id, true, "current", p+1)
                elseif sel == 9 then
                        nigger.unimenu(id, true, "current", p-1)
                end
        end
end

So you should ignore the line number (which is obviously wrong for some reason I don't know) and use that code block as a starting point. I can assure you that the hook and parameter debug info is always true and reliable.

There is no real debugging (like breakpoints) unfortunately so the best approach would probably be to put in a hell of a lot debug messages and to see after/before which message it breaks. This might seem dumb but it's the most efficient way to pinpoint a runtime bug when there are no useful error messages.

btw: why is the main table called "nigger"? This is bad
To the start Previous 1 Next To the start
Log in to reply Scripts overviewCS2D overviewForums overview