Refactor slightly
This commit is contained in:
parent
5a4e0bd632
commit
b9faa51406
16
server.lua
16
server.lua
@ -71,6 +71,15 @@ function findSpace()
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
function search(msg)
|
||||||
|
return find(function(item)
|
||||||
|
return
|
||||||
|
(not msg.meta or item.damage == msg.meta) and
|
||||||
|
(not msg.name or item.name == msg.name) and
|
||||||
|
(not msg.dname or string.find(item.displayName:lower(), msg.dname:lower()))
|
||||||
|
end)
|
||||||
|
end
|
||||||
|
|
||||||
function processRequest(msg)
|
function processRequest(msg)
|
||||||
print(textutils.serialise(msg))
|
print(textutils.serialise(msg))
|
||||||
|
|
||||||
@ -78,12 +87,7 @@ function processRequest(msg)
|
|||||||
-- Applies a fuzzy search to display names
|
-- Applies a fuzzy search to display names
|
||||||
-- Extracted items are either deposited in buffer or directly in target inventory.
|
-- Extracted items are either deposited in buffer or directly in target inventory.
|
||||||
if msg.cmd == "extract" then
|
if msg.cmd == "extract" then
|
||||||
local inv, slot, item = find(function(item)
|
local inv, slot, item = search(msg)
|
||||||
return
|
|
||||||
(not msg.meta or item.damage == msg.meta) and
|
|
||||||
(not msg.name or item.name == msg.name) and
|
|
||||||
(not msg.dname or string.find(item.displayName:lower(), msg.dname:lower()))
|
|
||||||
end)
|
|
||||||
|
|
||||||
index[inv][slot] = nil
|
index[inv][slot] = nil
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user