diff --git a/sys/apis/turtle/pathfind.lua b/sys/apis/turtle/pathfind.lua index 14cd9bf..ec6bc79 100644 --- a/sys/apis/turtle/pathfind.lua +++ b/sys/apis/turtle/pathfind.lua @@ -226,7 +226,7 @@ local function pathTo(dest, options) -- use single turn method so the turtle doesn't turn around -- when encountering obstacles -- IS THIS RIGHT ?? - if not turtle.gotoSingleTurn(pt.x, pt.z, pt.y, node.heading) then + if not turtle.gotoSingleTurn(pt.x, pt.z, pt.y) then table.insert(blocks, pt) --if device.turtlesensorenvironment then -- addSensorBlocks(blocks, device.turtlesensorenvironment.sonicScan()) diff --git a/sys/apis/ui.lua b/sys/apis/ui.lua index 954d8c0..7496f94 100644 --- a/sys/apis/ui.lua +++ b/sys/apis/ui.lua @@ -453,21 +453,12 @@ end function Manager:getDefaults(element, args) local defaults = Util.deepCopy(element.defaults) if args then - Manager:setProperties(defaults, args) + Manager:mergeProperties(defaults, args) end return defaults end -function Manager:pullEvents(...) - Event.pullEvents(...) - self.term:reset() -end - -function Manager:exitPullEvents() - Event.exitPullEvents() -end - -function Manager:setProperties(obj, args) +function Manager:mergeProperties(obj, args) if args then for k,v in pairs(args) do if k == 'accelerators' then @@ -483,6 +474,15 @@ function Manager:setProperties(obj, args) end end +function Manager:pullEvents(...) + Event.pullEvents(...) + self.term:reset() +end + +function Manager:exitPullEvents() + Event.exitPullEvents() +end + function Manager:dump(inEl) if inEl then local function clean(el) @@ -526,12 +526,12 @@ UI.Window.defaults = { function UI.Window:init(args) -- merge defaults for all subclasses local defaults = args - local m = self + local m = getmetatable(self) -- get the class for this instance repeat defaults = UI:getDefaults(m, defaults) m = m._base until not m - UI:setProperties(self, defaults) + UI:mergeProperties(self, defaults) -- each element has a unique ID self.uid = UI.Window.uid @@ -546,13 +546,8 @@ function UI.Window:init(args) local lpi repeat if m.postInit and m.postInit ~= lpi then ---debug('calling ' .. m.defaults.UIElement) ---debug(rawget(m, 'postInit')) m.postInit(self) lpi = m.postInit --- else ---debug('skipping ' .. m.defaults.UIElement) ---debug(rawget(m, 'postInit')) end m = m._base until not m @@ -661,7 +656,7 @@ function UI.Window:resize() end function UI.Window:add(children) - UI:setProperties(self, children) + UI:mergeProperties(self, children) self:initChildren() end @@ -2007,7 +2002,7 @@ function UI.MenuBar:addButtons(buttons) centered = false, } self.lastx = self.lastx + buttonProperties.width - UI:setProperties(buttonProperties, button) + UI:mergeProperties(buttonProperties, button) button = UI[self.buttonClass](buttonProperties) if button.name then @@ -3158,7 +3153,7 @@ function UI.NftImage:setImage(image) end UI:loadTheme('usr/config/ui.theme') -if Util.getVersion() >= 1.79 then +if Util.getVersion() >= 1.76 then UI:loadTheme('sys/etc/ext.theme') end diff --git a/sys/apis/util.lua b/sys/apis/util.lua index 7659494..1ca6557 100644 --- a/sys/apis/util.lua +++ b/sys/apis/util.lua @@ -79,15 +79,36 @@ function Util.getVersion() local version if _G._CC_VERSION then - version = tonumber(_G._CC_VERSION:gmatch('[%d]+%.?[%d][%d]', '%1')()) + version = tonumber(_G._CC_VERSION:match('[%d]+%.?[%d][%d]')) end if not version and _G._HOST then - version = tonumber(_G._HOST:gmatch('[%d]+%.?[%d][%d]', '%1')()) + version = tonumber(_G._HOST:match('[%d]+%.?[%d][%d]')) end return version or 1.7 end +function Util.getMinecraftVersion() + local mcVersion = _G._MC_VERSION or 'unknown' + if _G._HOST then + local version = _G._HOST:match('%S+ %S+ %((%S.+)%)') + if version then + mcVersion = version:match('Minecraft (%S+)') or version + end + end + return mcVersion +end + +function Util.checkMinecraftVersion(minVersion) + local version = Util.getMinecraftVersion() + local function convert(v) + local m1, m2, m3 = v:match('(%d)%.(%d)%.?(%d?)') + return tonumber(m1) * 10000 + tonumber(m2) * 100 + (tonumber(m3) or 0) + end + + return convert(version) >= convert(tostring(minVersion)) +end + -- http://lua-users.org/wiki/SimpleRound function Util.round(num, idp) local mult = 10^(idp or 0) diff --git a/sys/apps/System.lua b/sys/apps/System.lua index ea2b1ce..f5d2957 100644 --- a/sys/apps/System.lua +++ b/sys/apps/System.lua @@ -15,14 +15,6 @@ local shell = _ENV.shell multishell.setTitle(multishell.getCurrent(), 'System') UI:configure('System', ...) -local mcVersion = _G._MC_VERSION or 'unknown' -if _G._HOST then - local version = _G._HOST:match('%S+ %S+ %((%S.+)%)') - if version then - mcVersion = version:match('Minecraft (%S+)') or version - end -end - local env = { path = shell.path(), aliases = shell.aliases(), @@ -129,7 +121,7 @@ local systemPage = UI.Page { { name = '', value = '' }, { name = 'CC version', value = Util.getVersion() }, { name = 'Lua version', value = _VERSION }, - { name = 'MC version', value = mcVersion }, + { name = 'MC version', value = Util.getMinecraftVersion() }, { name = 'Disk free', value = Util.toBytes(fs.getFreeSpace('/')) }, { name = 'Computer ID', value = tostring(os.getComputerID()) }, { name = 'Day', value = tostring(os.day()) }, diff --git a/sys/etc/app.db b/sys/etc/app.db index f85b0a9..00b6b27 100644 --- a/sys/etc/app.db +++ b/sys/etc/app.db @@ -246,10 +246,10 @@ [ "a2accffe95b2c8be30e8a05e0c6ab7e8f5966f43" ] = { title = "Strafe", category = "Games", - icon = "\030f\031f \03131\0308\031f \030f\031d2\ -\030f\031f \031d2\03131\0308\031f \030f\03131\ -\030f\03131\0308\031f \030f\03131\031e3", - run = "https://pastebin.com/raw/bj3qj1Pj", + icon = "\0308\031f \0300 \0308 \ +\0308\031f \0300 \030f \ +\0300\031f \030f ", + run = "https://pastebin.com/raw/jyDH7mLH", }, [ "48d6857f6b2869d031f463b13aa34df47e18c548" ] = { title = "Breakout", diff --git a/sys/extensions/tl3.lua b/sys/extensions/tl3.lua index 66fcdb6..30a0270 100644 --- a/sys/extensions/tl3.lua +++ b/sys/extensions/tl3.lua @@ -695,6 +695,9 @@ function turtle.goto(dx, dz, dy, dh) return true end +-- avoid lint errors +turtle._goto = turtle.goto + function turtle.gotoX(dx) turtle.headTowardsX(dx)