feat(inferium-harvester): crash the process when no response from the inferium server
This commit is contained in:
parent
d4cbe6e808
commit
b075b953ab
@ -1,21 +1,4 @@
|
|||||||
local function mystical(essenceName)
|
|
||||||
return 'mysticalagriculture:' .. essenceName .. '_seeds'
|
|
||||||
end
|
|
||||||
|
|
||||||
-- FALLBACK WHEN CANNOT FETCH THE REMOTE PLAN
|
|
||||||
local DEFAULT_REMOTE_PLAN = {
|
|
||||||
mystical('coal'),
|
|
||||||
mystical('inferium'),
|
|
||||||
mystical('inferium'),
|
|
||||||
mystical('inferium'),
|
|
||||||
mystical('inferium'),
|
|
||||||
mystical('inferium'),
|
|
||||||
mystical('inferium'),
|
|
||||||
mystical('inferium')
|
|
||||||
}
|
|
||||||
|
|
||||||
return {
|
return {
|
||||||
length = 8,
|
length = 8,
|
||||||
firstCropZ = 2,
|
firstCropZ = 2
|
||||||
defaultRemotePlan = DEFAULT_REMOTE_PLAN
|
|
||||||
}
|
}
|
||||||
|
|||||||
@ -263,14 +263,12 @@ local function retrieveLocalPlan()
|
|||||||
goBackToHome()
|
goBackToHome()
|
||||||
end
|
end
|
||||||
|
|
||||||
-- TODO: fetch timeout ?
|
-- TODO: fetch retry + timeout ?
|
||||||
local function fetchRemotePlan()
|
local function fetchRemotePlan()
|
||||||
local fallbackPlan = config.defaultRemotePlan or {}
|
|
||||||
|
|
||||||
local modem = peripheral.find("modem")
|
local modem = peripheral.find("modem")
|
||||||
|
|
||||||
if not modem then
|
if not modem then
|
||||||
return fallbackPlan
|
error('no modem found')
|
||||||
end
|
end
|
||||||
|
|
||||||
modem.open(INFERIUM_REPLY_PORT)
|
modem.open(INFERIUM_REPLY_PORT)
|
||||||
@ -286,7 +284,7 @@ local function fetchRemotePlan()
|
|||||||
modem.close(INFERIUM_REPLY_PORT)
|
modem.close(INFERIUM_REPLY_PORT)
|
||||||
|
|
||||||
if not replyRawMessage then
|
if not replyRawMessage then
|
||||||
return fallbackPlan
|
error('empty response from the server')
|
||||||
end
|
end
|
||||||
|
|
||||||
local replyMessage = textutils.unserialize(replyRawMessage)
|
local replyMessage = textutils.unserialize(replyRawMessage)
|
||||||
@ -295,7 +293,7 @@ local function fetchRemotePlan()
|
|||||||
return replyMessage.payload
|
return replyMessage.payload
|
||||||
end
|
end
|
||||||
|
|
||||||
return fallbackPlan
|
error('message received but there is no payload: ' .. replyRawMessage)
|
||||||
end
|
end
|
||||||
|
|
||||||
local function removeSeeds(seeds)
|
local function removeSeeds(seeds)
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user