From 86db60ba9762d291d133f2c15dd271a741f29d17 Mon Sep 17 00:00:00 2001 From: Anavrins Date: Sat, 15 Aug 2020 02:28:54 -0400 Subject: [PATCH] Fix Ores crashing near water Fixes https://github.com/kepler155c/opus/issues/45 --- neural/ores.lua | 32 +++++++++++++++++++++++++------- 1 file changed, 25 insertions(+), 7 deletions(-) diff --git a/neural/ores.lua b/neural/ores.lua index c47a89e..fe31b0b 100644 --- a/neural/ores.lua +++ b/neural/ores.lua @@ -44,15 +44,20 @@ local canvas = modules.canvas3d().create({ -(offset.z % 1) + .5 } ) +local menuBarButtons = { + { text = 'Scan', event = 'scan' }, + { text = 'Size', event = 'size' }, +} + +if modules.fire then + table.insert(menuBarButtons, { text = 'Laser', event = 'laser' }) +end + local page = UI.Page { notification = UI.Notification {}, menuBar = UI.MenuBar { - buttons = { - { text = 'Scan', event = 'scan' }, - { text = 'Size', event = 'size' }, - -- { text = 'Laser', event = 'laser' }, -- If you dare - } + buttons = menuBarButtons }, sizeSlide = UI.MiniSlideOut { @@ -220,8 +225,21 @@ Event.addRoutine( b.box.addItem({ .25, .25 }, target[1], target[2], 2) --]] - b.box = canvas.addItem({ x, y, z }, target[1], target[2], page.blockSize) - b.box.setDepthTested(false) + pcall(function() + b.box = canvas.addItem({ + pos.x - offset.x + b.x + -(pos.x % 1) + .5, + pos.y - offset.y + b.y + -(pos.y % 1) + .5, + pos.z - offset.z + b.z + -(pos.z % 1) + .5 }, + target[1], target[2], page.blockSize) + end) + if not b.box then + b.box = canvas.addBox( + pos.x - offset.x + b.x + -(pos.x % 1) + .5, + pos.y - offset.y + b.y + -(pos.y % 1) + .5, + pos.z - offset.z + b.z + -(pos.z % 1) + .5, + .5, .5, .5, 0xFFFFFF7F) + end + b.box.setDepthTested(false) end end