Fix crash on user that has left the game

master
rubenwardy 2020-01-06 19:20:23 +00:00
parent a975d2afc5
commit 60d86c9f93
2 changed files with 10 additions and 1 deletions

View File

@ -134,7 +134,12 @@ function classroom.get_students_by_selector(selector)
elseif selector:sub(1, 6) == "group:" then
return classroom.get_group_students(selector:sub(7))
elseif selector:sub(1, 5) == "user:" then
return { selector:sub(6) }
local pname = selector:sub(6)
if classroom.get_player_by_name(pname) then
return { pname }
else
return {}
end
else
return {}
end

View File

@ -37,6 +37,10 @@ local function get_formspec(player, context)
return "label[0,0;" .. FS"Access denied" .. "]"
end
if context.selected_student and not minetest.get_player_by_name(context.selected_student) then
context.selected_student = nil
end
local function button(def)
local x = assert(def.x)
local y = assert(def.y)