luanti-org/luanti
VoxelArea: `iter` / `iterp` should safely handle "invalid" areas
Aperta
#17.065 aperta il 26 mar 2026
@ Script APIRequest / Suggestiongood first issue
Metriche repository
- Star
- (13.341 stelle)
- Metriche merge PR
- (Merge medio 13g 22h) (48 PR mergiate in 30 g)
Descrizione
The following code
core.register_chatcommand("test_va", {
func = function(name, param)
local p1, p2 = vector.new(0,16,0), vector.new(15,31,15)
local va = VoxelArea(p1, p2)
local vmax = va:getVolume() -- this is 4096
for i in va:iter(0, 16, 0, 15, 0, 15) do
if i < 0 or i > vmax then
return false, ("index %d is invalid"):format(i)
end
end
return true
end
})
currently fails as iter returns nonsense and eventually even out-of-range values.
The "mistake" by the caller is that y=0 is not even in the area. However I think it would be more useful if the API handled such usage safely and correctly.
Wanted behavior (with the values from the example code):
va:iter(0, 10, 0, 15, 20, 15)is equivalent tova:iter(0, 16, 0, 15, 20, 15)va:iter(0, 10, 0, 15, 12, 15)produces no results