25 lines
633 B
Lua
25 lines
633 B
Lua
|
local CHANNEL = 666
|
||
|
|
||
|
settings.define("dimension", {
|
||
|
description = "Dimension to serve",
|
||
|
default = "overworld",
|
||
|
type = "string",
|
||
|
})
|
||
|
local dim = settings.get("dimension")
|
||
|
|
||
|
local modem = peripheral.find("modem")
|
||
|
assert(modem)
|
||
|
modem.open(CHANNEL)
|
||
|
|
||
|
print("Serving requests for dimension '" .. dim .. "'")
|
||
|
while true do
|
||
|
local event, side, channel, replyChannel, reply, distance = os.pullEvent("modem_message")
|
||
|
assert(channel == CHANNEL)
|
||
|
|
||
|
-- AKA we are in the same dimension
|
||
|
if distance then
|
||
|
print("Responding to request from computer #" .. replyChannel - CHANNEL)
|
||
|
modem.transmit(replyChannel, channel, dim)
|
||
|
end
|
||
|
end
|