Does this code snippet do anything?
Posted: Thu May 30, 2019 11:49
The pathfinding code of Minetest Defense contains this piece of code:
(https://github.com/Kalabasa/minetest_de ... finder.lua, line 388+)
From my understanding of lua in the snippet
#players never evaluates to a nil or false and thus will always be interpreted as true. Am I missing something?
Code: Select all
local players = minetest.get_connected_players()
if #players then
for _,p in ipairs(players) do
local x, y, z = get_player_pos(p)
local sector = find_containing_sector(class, x, y, z)
if not sector then
Queue.push_back(sector_seeds, {x,y,z, nil,0})
should_refresh_distances = true
else
local distance = sector.distance
if distance == nil or distance > 0 then
should_refresh_distances = true
end
end
end
end
From my understanding of lua in the snippet
Code: Select all
if #players then