MinecraftのComputerCraft(Mod)でモデム通信を試してみました。
環境はこちら
- Minecraft Java Edition
- CurseForgeアプリ
- Fabric API
- CC: Tweaked
参考にさせていただいた記事
[ComputerCraftの無線通信を使いこなそう(2) ―RednetAPIの解説]
モデムを取り付けたTurtle(WT01)に受信側のプログラムを用意します。
receive.lua
ソースコードをpastebinから取得する場合は V1EwZLym です。
mon = peripheral.wrap("left")
rednet.open("right")
while true do
local sid, msg, dis = rednet.receive()
time = os.time()
time = textutils.formatTime(time)
mon.clear()
mon.setCursorPos(1, 1)
mon.write(time)
mon.setCursorPos(1, 2)
mon.write(sid..":"..msg)
end
Wireless Pocket Computer(WPC04)に送信側のプログラムを用意します。
send.lua
ソースコードをpastebinから取得する場合は PiiaxEVW です。
local args = {...}
rednet.open("back")
rednet.send(1, args[1])
WPC04を開いて次のように入力します。
> send hello
するとWT01に接続した左側のモニタに時刻とメッセージが表示されます。
![](https://i0.wp.com/www.netplan.co.jp/wp-content/uploads/2024/02/1bb47b377f54dbeb779e6613ed82b8df.png?resize=640%2C360&ssl=1)