refactor: replace hardcoded channel IDs with dynamic retrieval from platform.channels
This commit is contained in:
14
turtle.lua
14
turtle.lua
@@ -3,9 +3,11 @@
|
||||
-- This script only handles: eval execution, status broadcasting,
|
||||
-- GPS tracking, inventory/peripheral events.
|
||||
|
||||
local CHANNEL_RECEIVE = 100
|
||||
local CHANNEL_SEND = 101
|
||||
local STATUS_CHANNEL = 102
|
||||
local Channels = require('platform.channels')
|
||||
|
||||
local CHANNEL_RECEIVE = Channels.get('remoteturtle.command')
|
||||
local CHANNEL_SEND = Channels.get('remoteturtle.response')
|
||||
local STATUS_CHANNEL = Channels.get('remoteturtle.status')
|
||||
|
||||
-- State tracking (lightweight - server drives everything)
|
||||
local state = {
|
||||
@@ -23,11 +25,13 @@ local config = {
|
||||
}
|
||||
|
||||
-- Check for modem
|
||||
local modem = peripheral.find("modem")
|
||||
local WebBridge = require('platform.webbridge')
|
||||
local modem, modemSide = WebBridge.findModem(true)
|
||||
if not modem then
|
||||
error("No wireless modem found!")
|
||||
end
|
||||
modem.open(CHANNEL_RECEIVE)
|
||||
-- Open command channel (respects dual-mode migration)
|
||||
WebBridge.openChannels(modem, { 'remoteturtle.command' })
|
||||
|
||||
print("Server-Driven Turtle v5 (Pure Eval Protocol)")
|
||||
print("ID: " .. os.getComputerID())
|
||||
|
||||
Reference in New Issue
Block a user