Make the UID return hopefully actually work
This commit is contained in:
parent
cd6a4fc08d
commit
c15d4a26a0
@ -138,9 +138,8 @@ function processRequests()
|
|||||||
local ok, r = pcall(processRequest, msg)
|
local ok, r = pcall(processRequest, msg)
|
||||||
|
|
||||||
if not ok then r = "ERROR" end
|
if not ok then r = "ERROR" end
|
||||||
if ok and r then r.uid = msg.uid end
|
|
||||||
|
|
||||||
rednet.send(id, r, "dragon")
|
rednet.send(id, { msg = r, uid = msg.uid }, "dragon")
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
6
util.lua
6
util.lua
@ -23,12 +23,12 @@ local errors = {
|
|||||||
local function query(m)
|
local function query(m)
|
||||||
local uid = math.random(0, 1000000000)
|
local uid = math.random(0, 1000000000)
|
||||||
m.uid = uid
|
m.uid = uid
|
||||||
local msg
|
local resp
|
||||||
repeat
|
repeat
|
||||||
rednet.broadcast(m, "dragon")
|
rednet.broadcast(m, "dragon")
|
||||||
_, msg = rednet.receive("dragon", 1)
|
_, msg = rednet.receive("dragon", 1)
|
||||||
until msg and msg.uid == uid
|
until resp and resp.msg and resp.uid == uid
|
||||||
return msg
|
return resp.msg
|
||||||
end
|
end
|
||||||
|
|
||||||
-- Fetches an item with the given display name in the given quantity.
|
-- Fetches an item with the given display name in the given quantity.
|
||||||
|
Loading…
x
Reference in New Issue
Block a user