Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

attempt to perform arithmetic on a nil value #5

Open
gasune opened this issue Jun 7, 2024 · 1 comment
Open

attempt to perform arithmetic on a nil value #5

gasune opened this issue Jun 7, 2024 · 1 comment

Comments

@gasune
Copy link

gasune commented Jun 7, 2024

Not exactly sure why i got the error after pressing right arrow key until i reached the 'episodes' part of jellyfin. from the console, the problematic part seems to be here:

local function update_list()
	overlay.data = ""
	local magic_num = 29 -- const
	list_start[layer] = list_start[layer] or 1  -- this one line fixed my "attempt to perform arithmetic on a nil value" error
	if selection[layer] - list_start[layer] > magic_num then  -- errored here
		list_start[layer] = selection[layer] - magic_num
	elseif selection[layer] - list_start[layer] < 0 then
		list_start[layer] = selection[layer]
	end
	for i=list_start[layer],list_start[layer]+magic_num do
		if i > #items then break end
		local index = ""
		if items[i].IndexNumber and items[i].IsFolder == false then
			index = items[i].IndexNumber..". "
		else
			-- nothing
		end
		if i == selection[layer] then
			overlay.data = overlay.data.."{\\fs16}{\\c&HFF&}"..index..items[i].Name.."\n"
		else
			overlay.data = overlay.data.."{\\fs16}"..index..items[i].Name.."\n"
		end
	end
	overlay:update()
end

EDIT:
Seems like the amount of folders and lack of arrays in list_layer caused it to give the error.

For example:
Folder1 -> Folder2 -> Folder3 wouldn't produce the error as there are indeed 3 arrays.

Folder1 -> Folder2 -> Folder3 -> Folder4 would give a nil error since there are only 3 arrays, yet 4 layers(?)

So, by adding arrays as needed seems to have fixed it:

if #list_start < layer then table.insert(list_start, 1) end
@EmperorPenguin18
Copy link
Owner

Yes thank you for reporting this, you identified the issue exactly. I'll push a fix.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants