peripheral overhaul
This commit is contained in:
@@ -2,7 +2,7 @@ local Util = require('util')
|
||||
|
||||
local Adapter = { }
|
||||
|
||||
function Adapter.wrap(args, computerInfo)
|
||||
function Adapter.wrap(args)
|
||||
local adapters = {
|
||||
--'refinedAdapter',
|
||||
--'meAdapter',
|
||||
@@ -10,34 +10,32 @@ function Adapter.wrap(args, computerInfo)
|
||||
'chestAdapter',
|
||||
}
|
||||
|
||||
if computerInfo then
|
||||
if args and args.side and args.facing and not args.direction then
|
||||
args = Util.shallowCopy(args)
|
||||
if not args.direction and computerInfo.facing then
|
||||
local horz = { top = 'down', bottom = 'up' }
|
||||
args.direction = horz[args.wrapSide]
|
||||
local horz = { top = 'down', bottom = 'up' }
|
||||
args.direction = horz[args.side]
|
||||
|
||||
if not args.direction then
|
||||
local sides = {
|
||||
front = 0,
|
||||
back = 2,
|
||||
right = 1,
|
||||
left = 3,
|
||||
}
|
||||
if not args.direction then
|
||||
local sides = {
|
||||
front = 0,
|
||||
back = 2,
|
||||
right = 1,
|
||||
left = 3,
|
||||
}
|
||||
-- pretty sure computer/turtle have sides reversed
|
||||
local cards = {
|
||||
east = 0,
|
||||
south = 1,
|
||||
west = 2,
|
||||
north = 3,
|
||||
}
|
||||
local icards = {
|
||||
[ 0 ] = 'west',
|
||||
[ 1 ] = 'north',
|
||||
[ 2 ] = 'east',
|
||||
[ 3 ] = 'south',
|
||||
}
|
||||
args.direction = icards[(cards[computerInfo.facing] + sides[args.wrapSide]) % 4]
|
||||
end
|
||||
local cards = {
|
||||
east = 0,
|
||||
south = 1,
|
||||
west = 2,
|
||||
north = 3,
|
||||
}
|
||||
local icards = {
|
||||
[ 0 ] = 'west',
|
||||
[ 1 ] = 'north',
|
||||
[ 2 ] = 'east',
|
||||
[ 3 ] = 'south',
|
||||
}
|
||||
args.direction = icards[(cards[args.facing] + sides[args.side]) % 4]
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
Reference in New Issue
Block a user