View difference between Paste ID: vQGyMpUY and 1DB3pZ8N
SHOW: | | - or go back to the newest paste.
1
--[[ Code by NeverCast
2
     This should be loaded like a typical api
3
     Feel free to name it what you like
4
--]]
5
local directions = { [0]=0,[1]=1,[2]=2,[3]=3,[4]=4,[5]=5,["down"] = 0, ["up"] = 1, ["-Z"] = 2, ["+Z"] = 3, ["-X"] = 4, ["+X"] = 5, ["+Y"] = 1, ["-Y"] = 0}
6
directions.south = directions["+Z"]
7
directions.east = directions["+X"]
8
directions.north = directions["-Z"]
9
directions.west = directions["-X"]
10
 
11
-- Gets the Unique ID based on the ID and Meta
12
function getID(id, meta)
13
  if meta == nil then
14
    meta = 27268
15-
	-- Reverse RG's fancy math
15+
  else
16-
	local subt = bit.band(uuid, 0xffff)
16+
    meta = bit.bxor(meta, 0x6E6C)
17-
	local dexorm = bit.bxor(subt, 0x3a69)
17+
  end
18-
	local metadata = nil
18+
  local uuid = bit.bxor(id, 0x4F89) * 0x8000 + bit.bxor(meta, 0x3A69)
19-
	if dexorm ~= 28262 then -- item takes dmg
19+
  return uuid
20-
		metadata = bit.bxor(dexorm, 0x6e6c)
20+
21-
	end
21+
22-
	local id = bit.bxor((uuid-subt)/0x8000, 0x4f89)
22+
23-
	-- put it in to a nice table
23+
24-
	local stack = {}
24+
25-
	stack.amount = c
25+
26-
	stack.id = id
26+
        -- Reverse RG's fancy math
27-
	stack.meta = metadata
27+
        local subt = bit.band(uuid, 0xffff)
28-
	return stack
28+
        local dexorm = bit.bxor(subt, 0x3a69)
29
        local metadata = nil
30
        if dexorm ~= 28262 then -- item takes dmg
31
                metadata = bit.bxor(dexorm, 0x6e6c)
32
        end
33
        local id = bit.bxor((uuid-subt)/0x8000, 0x4f89)
34
        -- put it in to a nice table
35
        local stack = {}
36
        stack.amount = c
37
        stack.id = id
38-
	if not peripheral.isPresent(direction) then
38+
        stack.meta = metadata
39-
		return false, "No Peripheral"
39+
        return stack
40-
	end
40+
41-
	if peripheral.getType(direction) ~= "interactiveSorter" then
41+
 
42-
		return false, "Not a sorter"
42+
43-
	end
43+
44-
	local stacks = {}
44+
45-
	for uuid,count in pairs(peripheral.call(direction, "list", directions[invDirection])) do
45+
46-
		table.insert(stacks, getStack(uuid, count))
46+
47-
	end
47+
48-
	return true, stacks	
48+
49
        if not peripheral.isPresent(direction) then
50
                return false, "No Peripheral"
51
        end
52
        if peripheral.getType(direction) ~= "interactiveSorter" then
53
                return false, "Not a sorter"
54
        end
55
        local stacks = {}
56
        for uuid,count in pairs(peripheral.call(direction, "list", directions[invDirection])) do
57
                table.insert(stacks, getStack(uuid, count))
58
        end
59
        return true, stacks    
60
end