consistent command line processing-usage
This commit is contained in:
@@ -12,22 +12,23 @@ local window = _G.window
|
|||||||
|
|
||||||
local function syntax()
|
local function syntax()
|
||||||
printError('Syntax:')
|
printError('Syntax:')
|
||||||
error('mwm sessionName [monitor]')
|
error('mwm [--config=filename] [monitor]')
|
||||||
end
|
end
|
||||||
|
|
||||||
local args = { ... }
|
local args = Util.parse(...)
|
||||||
local UID = 0
|
local UID = 0
|
||||||
local multishell = { }
|
local multishell = { }
|
||||||
local processes = { }
|
local processes = { }
|
||||||
local parentTerm = term.current()
|
local parentTerm = term.current()
|
||||||
local sessionFile = args[1] or 'usr/config/mwm'
|
local sessionFile = args.config or 'usr/config/mwm'
|
||||||
|
local monName = args[1]
|
||||||
local running
|
local running
|
||||||
local parentMon
|
local parentMon
|
||||||
|
|
||||||
local defaultEnv = Util.shallowCopy(_ENV)
|
local defaultEnv = Util.shallowCopy(_ENV)
|
||||||
defaultEnv.multishell = multishell
|
defaultEnv.multishell = multishell
|
||||||
if args[2] then
|
if monName then
|
||||||
parentMon = peripheral.wrap(args[2]) or syntax()
|
parentMon = peripheral.wrap(monName) or syntax()
|
||||||
else
|
else
|
||||||
parentMon = peripheral.find('monitor') or syntax()
|
parentMon = peripheral.find('monitor') or syntax()
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -1,3 +1,5 @@
|
|||||||
|
local Util = require('opus.util')
|
||||||
|
|
||||||
local device = _G.device
|
local device = _G.device
|
||||||
local multishell = _ENV.multishell
|
local multishell = _ENV.multishell
|
||||||
local os = _G.os
|
local os = _G.os
|
||||||
@@ -6,9 +8,9 @@ local term = _G.term
|
|||||||
-- list this terminal in the devices list so it's available via
|
-- list this terminal in the devices list so it's available via
|
||||||
-- peripheral sharing
|
-- peripheral sharing
|
||||||
|
|
||||||
local args = { ... }
|
local args = Util.parse(...)
|
||||||
local name = args[1] or error('Syntax: termShare [device name] <title>')
|
local name = args[1] or error('Syntax: termShare [--title=title] term_name')
|
||||||
local title = args[2]
|
local title = args.title
|
||||||
|
|
||||||
device[name] = term.current()
|
device[name] = term.current()
|
||||||
device[name].name = name
|
device[name].name = name
|
||||||
|
|||||||
@@ -6,7 +6,7 @@ local Proxy = require('core.proxy')
|
|||||||
local os = _G.os
|
local os = _G.os
|
||||||
|
|
||||||
local args = { ... }
|
local args = { ... }
|
||||||
local remoteId = args[1] or error('mobFollow <remote id>')
|
local remoteId = args[1] or error('mobFollow REMOTE_ID')
|
||||||
local ni = Proxy.create(remoteId, 'device/neuralInterface')
|
local ni = Proxy.create(remoteId, 'device/neuralInterface')
|
||||||
|
|
||||||
if not ni then
|
if not ni then
|
||||||
|
|||||||
@@ -3,15 +3,20 @@
|
|||||||
Must be run on a mob with the same height.
|
Must be run on a mob with the same height.
|
||||||
]]
|
]]
|
||||||
|
|
||||||
|
local Array = require('opus.array')
|
||||||
|
local Config = require('opus.config')
|
||||||
local neural = require('neural.interface')
|
local neural = require('neural.interface')
|
||||||
local Sound = require('opus.sound')
|
local Sound = require('opus.sound')
|
||||||
local Map = require('opus.map')
|
local Map = require('opus.map')
|
||||||
|
|
||||||
local os = _G.os
|
local os = _G.os
|
||||||
|
|
||||||
local BREEDING = 'Cow'
|
local config = Config.load('mobRancher', {
|
||||||
|
animal = 'Cow',
|
||||||
|
maxAdults = 12,
|
||||||
|
})
|
||||||
|
|
||||||
local WALK_SPEED = 1.5
|
local WALK_SPEED = 1.5
|
||||||
local MAX_GROWN = 12
|
|
||||||
|
|
||||||
neural.assertModules({
|
neural.assertModules({
|
||||||
'plethora:sensor',
|
'plethora:sensor',
|
||||||
@@ -76,8 +81,17 @@ local function kill(entity)
|
|||||||
end
|
end
|
||||||
|
|
||||||
local function getEntities()
|
local function getEntities()
|
||||||
|
local sheep = Array.filter(neural.sense(), function(entity)
|
||||||
|
if entity.name == 'Sheep' and entity.y > -.5 then
|
||||||
|
return true
|
||||||
|
end
|
||||||
|
end)
|
||||||
|
if #sheep > config.maxAdults then
|
||||||
|
return sheep
|
||||||
|
end
|
||||||
|
|
||||||
return Map.filter(neural.sense(), function(entity)
|
return Map.filter(neural.sense(), function(entity)
|
||||||
if entity.name == BREEDING and entity.y > -.5 then
|
if entity.name == config.animal and entity.y > -.5 then
|
||||||
return true
|
return true
|
||||||
end
|
end
|
||||||
end)
|
end)
|
||||||
@@ -107,7 +121,7 @@ while true do
|
|||||||
|
|
||||||
local entities = getEntities()
|
local entities = getEntities()
|
||||||
|
|
||||||
if Map.size(entities) > MAX_GROWN then
|
if Map.size(entities) > config.maxAdults then
|
||||||
kill(randomEntity(entities))
|
kill(randomEntity(entities))
|
||||||
else
|
else
|
||||||
local entity = getHungry(entities)
|
local entity = getHungry(entities)
|
||||||
|
|||||||
@@ -7,6 +7,7 @@ local colors = _G.colors
|
|||||||
local fs = _G.fs
|
local fs = _G.fs
|
||||||
|
|
||||||
UI:configure('Shoplogs', ...)
|
UI:configure('Shoplogs', ...)
|
||||||
|
|
||||||
local args = Util.parse( ... )
|
local args = Util.parse( ... )
|
||||||
local logFile = args[1] or '/usr/swshop.log'
|
local logFile = args[1] or '/usr/swshop.log'
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user