no encryption yet but it works
local args = {...}
local modem = peripheral.wrap(args[2]) or error("Missing Modem on " .. args[2] .. " side!")
local clutch = args[3] or error("Missing Clutch Side Argument")
local gearshift = args[4] or error("Missing Gearshift Side Argument")
local side = args[5] or error("Missing Mech Side Argument")
local modes = {
[1] = function() -- FORWARD
redstone.setAnalogOutput(gearshift, 0)
redstone.setAnalogOutput(clutch, 0)
end,
[2] = function() -- LEFT
if side == "left" then
redstone.setAnalogOutput(gearshift, 15)
else
redstone.setAnalogOutput(gearshift, 0)
end
redstone.setAnalogOutput(clutch, 0)
end,
[3] = function() -- RIGHT
if side == "left" then
redstone.setAnalogOutput(gearshift, 0)
else
redstone.setAnalogOutput(gearshift, 15)
end
redstone.setAnalogOutput(clutch, 0)
end,
[4] = function() -- BACKWARD
redstone.setAnalogOutput(gearshift, 15)
redstone.setAnalogOutput(clutch, 0)
end,
[5] = function() -- STOP
redstone.setAnalogOutput(clutch, 15)
end
}
local mode = 5
local function switchMode(number)
print("This is beding called")
if not(type(number) == "number") then
return
elseif number < 1 or number > 5 then
return
else
mode = number
end
end
modem.open(tonumber(args[1]))
while true do
local _, _, _, _, msg, distance = os.pullEvent("modem_message")
local value = mode
if distance < 20 then
value = tonumber(msg)
end
mode = value
modes[mode]()
end
If you want more control over the speed, use rotation speed controllers
Only inconvenience is that the setRotation function locks the computer for one tick
The solution I use is to set the desired speed to a variable, and then have a separate “motor daemon” function that actually applies the speed using SetTargetSpeed (or whatever the method is) and use parallel.waitForAll with that and the main function, and that allows the main function to run faster without waiting for the motor/speed controller to update.
Yeah, or you can just use on computer for each track like here
:clueless:
But you have a computer for each side, so that should not be a problem
This conversation is on Discord · Reply there