From 8b50127f21dfbda6e998cf0093c3d4abd486ae83 Mon Sep 17 00:00:00 2001 From: "kepler155c@gmail.com" Date: Mon, 15 Oct 2018 16:05:43 -0400 Subject: [PATCH] new icon set + scanning miner --- sys/apis/event.lua | 23 ++++++++++++++++++++--- sys/apis/util.lua | 1 - sys/apps/telnet.lua | 8 ++++---- sys/etc/app.db | 30 ++++++++++++++++++++++++------ sys/extensions/6.tl3.lua | 1 + 5 files changed, 49 insertions(+), 14 deletions(-) diff --git a/sys/apis/event.lua b/sys/apis/event.lua index fda4946..ad0715f 100644 --- a/sys/apis/event.lua +++ b/sys/apis/event.lua @@ -136,6 +136,18 @@ function Event.waitForEvent(event, timeout) until e[1] == 'timer' and e[2] == timerId end +-- Set a handler for the terminate event. Within the function, return +-- true or false to indicate whether the event should be propagated to +-- all sub-threads +function Event.onTerminate(fn) + Event.termFn = fn +end + +function Event.termFn() + Event.terminate = true + return true -- propagate +end + function Event.addRoutine(fn) local r = setmetatable({ co = coroutine.create(fn), @@ -204,11 +216,16 @@ end function Event.pullEvent(eventType) while true do local e = { os.pullEventRaw() } + local propagate = true -- don't like this... - Event.terminate = Event.terminate or e[1] == 'terminate' + if e[1] == 'terminate' then + propagate = Event.termFn() + end - processHandlers(e[1]) - processRoutines(table.unpack(e)) + if propagate then + processHandlers(e[1]) + processRoutines(table.unpack(e)) + end if Event.terminate then return { 'terminate' } diff --git a/sys/apis/util.lua b/sys/apis/util.lua index 29fd5e1..3529583 100644 --- a/sys/apis/util.lua +++ b/sys/apis/util.lua @@ -653,7 +653,6 @@ function Util.getOptions(options, args, ignoreInvalid) end end return true, Util.size(rawOptions) - end return Util diff --git a/sys/apps/telnet.lua b/sys/apps/telnet.lua index 0684f8f..25c6c05 100644 --- a/sys/apps/telnet.lua +++ b/sys/apps/telnet.lua @@ -10,7 +10,7 @@ local os = _G.os local read = _G.read local term = _G.term -local options, args = Util.args({ ... }) +local args = { ... } local remoteId = tonumber(table.remove(args, 1) or '') if not remoteId then @@ -19,11 +19,11 @@ if not remoteId then end if not remoteId then - error('Syntax: telnet [-title TITLE] ID [PROGRAM]') + error('Syntax: telnet ID [PROGRAM] [ARGS]') end -if options.title and multishell then - multishell.setTitle(multishell.getCurrent(), options.title) +if multishell then + multishell.setTitle(multishell.getCurrent(), 'Telnet ' .. remoteId) end local socket, msg = Socket.connect(remoteId, 23) diff --git a/sys/etc/app.db b/sys/etc/app.db index fffc917..68b9abc 100644 --- a/sys/etc/app.db +++ b/sys/etc/app.db @@ -16,6 +16,9 @@ icon = "\0304\031f \030f\0310o..\0304\031f \ \0304\031f \030f\0310.o.\0304\031f \ \0304\031f - ", + iconExt = "\0307\031f\135\0300\0317\159\0307\0310\144\031f\139\ +\0300\0317\131\0307\0310\147\0300\0317\156\131\ +\130\143\143\129", run = "rom/programs/reboot", }, fb91e24fa52d8d2b32937bf04d843f730319a902 = { @@ -24,9 +27,9 @@ icon = "\0301\03171\03180\030 \031 \ \0301\03181\030 \031 \ \0301\03170\03180\03171\0307\031f>", - iconExt = "\031f\128\0315\152\131\131\132\031f\128\ -\0315\139\159\129\0305\031f\159\129\139\ -\031f\128\0315\136\0305\031f\143\143\030f\0315\134\031f\128", + iconExt = "\031f\128\0313\152\131\131\132\031f\128\ +\0313\139\159\129\0303\031f\159\129\139\ +\031f\128\0313\136\0303\031f\143\143\030f\0313\134\031f\128", run = "http://pastebin.com/raw/UzGHLbNC", }, c47ae15370cfe1ed2781eedc1dc2547d12d9e972 = { @@ -46,6 +49,9 @@ icon = "\030f \ \030f\0310lua>\031 \ \030f ", + iconExt = "\0300\031f\151\030f\128\0300\159\159\159\030f\0310\144\0304\031f\159\030f\128\ +\0300\031f\149\030f\128\0300\149\149\151\145\030f\128\0314\153\ +\130\131\130\131\130\131\0314\130\031f\128", run = "sys/apps/Lua.lua", }, df485c871329671f46570634d63216761441bcd6 = { @@ -54,6 +60,9 @@ icon = "\0304 \030 \ \030f \0304 \0307 \030 \031 \031f_\ \030f \0304 \0307 \030 \031f/", + iconExt = "\031f\128\128\128\0308\159\143\0300\0317\151\0307\0310\140\148\ +\0314\151\131\0304\031f\148\030f\0318\138\148\0307\0310\138\131\129\ +\0304\031f\138\143\133\030f\0318\131\129\031f\128\128\128", run = "Devices.lua", }, bc0792d8dc81e8aa30b987246a5ce97c40cd6833 = { @@ -73,6 +82,9 @@ icon = "\0304\031f \030 \0311e\ \030f\031f \0304 \030 \0311ee\031f \ \030f\031f \0304 \030 \0311e\031f ", + iconExt = "\0300\031f\159\135\030f\0310\156\0301\031f\159\030f\0311\144\0300\031f\147\139\030f\0310\144\ +\0300\128\128\030f\149\0311\157\142\0300\031f\149\0310\128\128\ +\130\139\141\0311\130\131\0310\142\135\129", run = "Events.lua", }, [ "2a4d562b1d9a9c90bdede6fac8ce4f7402462b86" ] = { @@ -82,8 +94,8 @@ \030f\031f \0315/\\/ \ \030f\0315/\031f ", iconExt = "\031f\128\128\0305\159\030f\128\0305\159\030f\0315\134\031f\128\ -\031f\128\0315\152\129\137\0305\031f\158\139\030f\0315\144\ -\0315\134\031f\128\128\128\128\0305\154\030f\0315\144", +\031f\128\0315\152\129\137\0305\031f\158\139\030f\0317 \ +\0315\134\031f\128\128\128\128\0305\154\030f\0317 ", run = "Tasks.lua", }, [ "6ce6c512ea433a7fc5c8841628e7696cd0ff7f2b" ] = { @@ -103,12 +115,18 @@ icon = "\0304\031f \ \0304\031f \030f\0310zz\031 \ \0304\031f \030f ", + iconExt = "\030e\031f\135\030f\031e\148\030e\128\031f\151\139\ +\030e\031e\128\030f\031f\128\031e\143\031f\128\030e\031e\128\ +\031e\139\030e\031f\130\131\129\030f\031e\135", run = "/rom/programs/shutdown", }, bdc1fd5d3c0f3dcfd55d010426e61bf9451e680d = { title = "Shell", category = "Apps", - icon = "\030f\0314\151\131\131\131\131\ + icon = "\0304 \030 \ +\0304 \030f\0314> \0310_\031 \ +\0304 \030f \030 ", + iconExt = "\030f\0314\151\131\131\131\131\ \030f\0314\149\030f\0314> \0310_ \ \030f\0314\149\030f ", run = "shell", diff --git a/sys/extensions/6.tl3.lua b/sys/extensions/6.tl3.lua index 5c41c49..3985dcf 100644 --- a/sys/extensions/6.tl3.lua +++ b/sys/extensions/6.tl3.lua @@ -458,6 +458,7 @@ function turtle.back() end local function moveTowardsX(dx) + if not tonumber(dx) then error('moveTowardsX: Invalid arguments') end local direction = dx - turtle.point.x local move