Fix crashes in Land
parent
10b43ef79d
commit
401131944c
|
@ -141,6 +141,11 @@ function company.get_company_header(pname, width, y, snippet)
|
|||
local func = company.registered_snippets[snippet or "ceo"]
|
||||
assert(func, "Unable to find snippet " .. (snippet or "ceo"))
|
||||
|
||||
local snippet_text = ""
|
||||
if comp and func then
|
||||
snippet_text = minetest.formspec_escape(func(comp))
|
||||
end
|
||||
|
||||
return table.concat({
|
||||
"container[0,", tostring(y + 0.45), "]",
|
||||
"box[-0.3,-0.1;", tostring(width + 0.4), ",1.1;#222]",
|
||||
|
@ -148,7 +153,7 @@ function company.get_company_header(pname, width, y, snippet)
|
|||
minetest.formspec_escape(comp and comp.title or "No active company"),
|
||||
"]",
|
||||
"label[0.1,0.4;",
|
||||
minetest.formspec_escape(func(comp)),
|
||||
snippet_text,
|
||||
"]",
|
||||
"button[",
|
||||
tostring(width - 2),
|
||||
|
|
|
@ -232,9 +232,9 @@ sfinv.register_page("land:land", {
|
|||
local list = flatten_list(tree)
|
||||
context.list = list
|
||||
|
||||
if not context.selected then
|
||||
if not context.selected and #list > 0 then
|
||||
context.selected = 1
|
||||
elseif context.selected > #list then
|
||||
elseif context.selected and context.selected > #list then
|
||||
context.selected = #list
|
||||
end
|
||||
|
||||
|
@ -270,9 +270,9 @@ sfinv.register_page("land:land", {
|
|||
end
|
||||
fs[#fs + 1] = "]"
|
||||
|
||||
fs[#fs + 1] = "container[0,-0.2]"
|
||||
if context.selected then
|
||||
-- local area = list[context.selected]
|
||||
fs[#fs + 1] = "container[0,-0.2]"
|
||||
fs[#fs + 1] = "button[6,0;2,1;teleport;Teleport]"
|
||||
fs[#fs + 1] = "box[6,1;1.8,0.8;#222]"
|
||||
fs[#fs + 1] = "box[6,2;1.8,0.8;#222]"
|
||||
|
@ -281,8 +281,17 @@ sfinv.register_page("land:land", {
|
|||
fs[#fs + 1] = "box[6,5;1.8,0.8;#222]"
|
||||
fs[#fs + 1] = "box[6,6;1.8,0.8;#222]"
|
||||
fs[#fs + 1] = "box[6,7;1.8,0.8;#222]"
|
||||
fs[#fs + 1] = "container_end[]"
|
||||
else
|
||||
fs[#fs + 1] = "box[6,0;1.8,0.8;#222]"
|
||||
fs[#fs + 1] = "box[6,1;1.8,0.8;#222]"
|
||||
fs[#fs + 1] = "box[6,2;1.8,0.8;#222]"
|
||||
fs[#fs + 1] = "box[6,3;1.8,0.8;#222]"
|
||||
fs[#fs + 1] = "box[6,4;1.8,0.8;#222]"
|
||||
fs[#fs + 1] = "box[6,5;1.8,0.8;#222]"
|
||||
fs[#fs + 1] = "box[6,6;1.8,0.8;#222]"
|
||||
fs[#fs + 1] = "box[6,7;1.8,0.8;#222]"
|
||||
end
|
||||
fs[#fs + 1] = "container_end[]"
|
||||
|
||||
return sfinv.make_formspec(player, context,
|
||||
table.concat(fs, ""), false)
|
||||
|
@ -305,6 +314,7 @@ sfinv.register_page("land:land", {
|
|||
minetest.log("warning", "teleport, but no selected or list")
|
||||
return
|
||||
end
|
||||
|
||||
local area = context.list[context.selected]
|
||||
assert(area)
|
||||
|
||||
|
|
Loading…
Reference in New Issue