auto_controller: Avoid nil error when digging slopes (#69)

Crashes otherwise if offset field is left empty.
Related: https://github.com/minetest/minetest/issues/10180
This commit is contained in:
tuedel 2020-08-11 18:57:09 +02:00 committed by GitHub
parent eea743185d
commit 1c85c822e8
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -270,6 +270,7 @@ minetest.register_node("digtron:auto_controller", {
local node = minetest.get_node(pos)
local controlling_coordinate = digtron.get_controlling_coordinate(pos, node.param2)
offset = offset or 0
local newpos = pos
local markerpos = {x=newpos.x, y=newpos.y, z=newpos.z}
local x_pos = math.floor((newpos[controlling_coordinate]+offset)/slope)*slope - offset