Fix formspec overbleeding

master
Wuzzy 2020-09-08 19:38:04 +02:00
parent 27660860a1
commit af08f7a1ad
1 changed files with 17 additions and 13 deletions

View File

@ -107,23 +107,27 @@ teleports.set_formspec = function(pos)
local node = minetest.get_node(pos) local node = minetest.get_node(pos)
local buttons = ""; local buttons = "";
for i, EachTeleport in ipairs( teleports:find_nearby(pos, 5) ) do local x = 1
if EachTeleport["name"] then local y = 1
buttons = buttons.."button_exit[3,"..(i)..";4,0.5;tp"..i..";"..F(S("GO>@1",EachTeleport.name)).."]"; for i, EachTeleport in ipairs( teleports:find_nearby(pos, 6) ) do
else if i == 4 then
buttons = buttons.."button_exit[3,"..(i)..";4,0.5;tp"..i..";"..F(S("GO>@1,@2,@3",EachTeleport.pos.x,EachTeleport.pos.y,EachTeleport.pos.z)).."]"; x = x + 3.5
y = 1
end end
if EachTeleport["name"] then
buttons = buttons.."button_exit["..x..","..y..";3.5,0.5;tp"..i..";"..F(S("GO>@1",EachTeleport.name)).."]";
else
buttons = buttons.."button_exit["..x..","..y..";3.5,0.5;tp"..i..";"..F(S("GO>@1,@2,@3",EachTeleport.pos.x,EachTeleport.pos.y,EachTeleport.pos.z)).."]";
end
y = y + 1
end end
meta:set_string("formspec", "size[8,10;]" meta:set_string("formspec", "size[8,9;]"
.."label[0,0;" .. F(S("Go to available teleports! Use mossy cobblestone as fuel!")) .. "]" .."label[0,0;" .. F(S("Go to available teleports! Use mossy cobblestone as fuel!")) .. "]"
.."list[current_name;price;0,1;1,1;]" .."list[current_name;price;0,1;1,1;]"
..buttons ..buttons
.."button_exit[1,4;2,0.5;cancel;"..F(S("Cancel")).."]"
.."button_exit[1,5;2,0.5;cancel;"..F(S("Cancel")).."]" .."list[current_player;main;0,5;8,4;]")
.."list[current_player;main;0,6;8,4;]")
end end
teleports.on_receive_fields = function(pos, formname, fields, player) teleports.on_receive_fields = function(pos, formname, fields, player)
local meta = minetest.env:get_meta(pos); local meta = minetest.env:get_meta(pos);
@ -133,7 +137,7 @@ teleports.on_receive_fields = function(pos, formname, fields, player)
if inv:contains_item("price", price) then if inv:contains_item("price", price) then
inv:remove_item("price", price); inv:remove_item("price", price);
teleports.lastplayername = "" teleports.lastplayername = ""
local available = teleports:find_nearby(pos, 5) local available = teleports:find_nearby(pos, 6)
if player ~= nil and player:is_player() then if player ~= nil and player:is_player() then
local playerpos = player:getpos() local playerpos = player:getpos()
if fields.tp1 and #available>0 then if fields.tp1 and #available>0 then
@ -250,7 +254,7 @@ minetest.register_abm({
player = objectsnear[2]; player = objectsnear[2];
end end
if player:is_player() and player:get_player_name()~=teleports.lastplayername then if player:is_player() and player:get_player_name()~=teleports.lastplayername then
local positions = teleports:find_nearby(pos, 10) local positions = teleports:find_nearby(pos, 11)
if #positions>0 then if #positions>0 then
local key = math.random(1, #positions) local key = math.random(1, #positions)
local dir, dirmag; local dir, dirmag;