From f0c5c2659f03d4a10870cc98375cf3e88f9a52ed Mon Sep 17 00:00:00 2001 From: Wuzzy Date: Sun, 4 Apr 2021 16:44:14 +0200 Subject: [PATCH] Prevent adding dupe slice definitions --- init.lua | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/init.lua b/init.lua index 64c149f..b372c1b 100644 --- a/init.lua +++ b/init.lua @@ -635,7 +635,18 @@ schemedit.add_form("slice", { index = self.selected end - slice_list[index] = {ypos = ypos, prob = prob} + local dupe = false + if fields.done_add then + for k,v in pairs(slice_list) do + if v.ypos == ypos then + v.prob = prob + dupe = true + end + end + end + if not dupe then + slice_list[index] = {ypos = ypos, prob = prob} + end meta:set_string("slices", minetest.serialize(slice_list))