hello, i just made an update with wireless redstone, but its crashing every time i tried to use it. I dont know very much about rednet so could you help me out with this, please?
The code of the beta version:
Spoiler
function wirelesssend(...)
write("Modem side:")
modemside = io.read()
rednet.open(modemside)
write("ID of receiver:")
receiverid = io.read()
write("Input side:")
inputside = io.read()
while true do
redstoneinput = redstone.getInput(inputside)
if redstoneinput == true then
rednet.send(receiverid, 1)
elseif redstoneinput == false then
rednet.send(receiverid, 0)
end
sleep(0.1)
end
end
function wirelessreceive(...)
write("Modem side:")
modemside = io.read()
rednet.open(modemside)
write("Output side:")
Outputside = io.read()
while true do
message = rednet.receive(10)
if message == 1 then
redstone.setOutput(Outputside, true)
elseif message == 0 then
redstone.setOutput(Outputside, false)
end
sleep(0.1)
end
end
function waitforkey()
while true do
local sEvent, param = os.pullEvent("key")
if sEvent == "key" then
if param == 15 then
redstone.setOutput("right", false)
redstone.setOutput("left", false)
redstone.setOutput("top", false)
redstone.setOutput("bottom", false)
redstone.setOutput("front", false)
redstone.setOutput("back", false)
break
end
end
end
end
function RedClock(...)
print("RedClock")
write("Ticks:")
clockspeed = io.read()
clockspeedm = tonumber(clockspeed)
clockspeedm = clockspeedm/10
write("Side:")
side = io.read()
while true do
redstone.setOutput(side, true)
sleep(clockspeedm/2)
redstone.setOutput(side, false)
sleep(clockspeedm/2)
end
end
function AndGate(...)
print("AndGate")
write("Side of input a:")
sidea = io.read()
write("Side of input b:")
sideb = io.read()
write("Output Side:")
sidec = io.read()
while true do
rightredstone = redstone.getInput(sidea)
leftredstone = redstone.getInput(sideb)
if rightredstone == true and leftredstone == true then
redstone.setOutput(sidec, true)
else
redstone.setOutput(sidec, false)
end
sleep(0.1)
end
end
function OrGate(...)
print("OrGate")
write("Side of input a:")
sidea = io.read()
write("Side of input b:")
sideb = io.read()
write("Output Side:")
sidec = io.read()
while true do
rightredstone = redstone.getInput(sidea)
leftredstone = redstone.getInput(sideb)
if rightredstone == true or leftredstone == true then
redstone.setOutput(sidec, true)
else
redstone.setOutput(sidec, false)
end
sleep(0.1)
end
end
function XorGate(...)
print("XorGate")
write("Side of input a:")
sidea = io.read()
write("Side of input b:")
sideb = io.read()
write("Output Side:")
sidec = io.read()
while true do
rightredstone = redstone.getInput(sidea)
leftredstone = redstone.getInput(sideb)
if rightredstone == true and leftredstone == false then
redstone.setOutput(sidec, true)
elseif rightredstone == false and leftredstone == true then
redstone.setOutput(sidec, true)
else
redstone.setOutput(sidec, false)
end
sleep(0.1)
end
end
function NotGate(...)
print("NotGate")
write("Input Side:")
sidea = io.read()
write("Output Side:")
sideb = io.read()
while true do
frontredstone = redstone.getInput(sidea)
if frontredstone == false then
redstone.setOutput(sideb, true)
else
redstone.setOutput(sideb, false)
end
sleep(0.1)
end
end
function NandGate(...)
print("NandGate")
write("Side of input a:")
sidea = io.read()
write("Side of input b:")
sideb = io.read()
write("Output Side:")
sidec = io.read()
while true do
rightredstone = redstone.getInput(sidea)
leftredstone = redstone.getInput(sideb)
if rightredstone == false and leftredstone == false then
redstone.setOutput(sidec, true)
else
redstone.setOutput(sidec, false)
end
sleep(0.1)
end
end
function XnorGate(...)
print("XnorGate")
write("Side of input a:")
sidea = io.read()
write("Side of input b:")
sideb = io.read()
write("Output Side:")
sidec = io.read()
while true do
rightredstone = redstone.getInput(sidea)
leftredstone = redstone.getInput(sideb)
if rightredstone == true and leftredstone == true then
redstone.setOutput(sidec, true)
elseif rightredstone == false and leftredstone == false then
redstone.setOutput(sidec, true)
else
redstone.setOutput(sidec, false)
end
sleep(0.1)
end
end
function TFlipFlop(...)
print("NotGate")
write("Input Side:")
sidea = io.read()
write("Output Side:")
sideb = io.read()
On = false
while true do
redstoneinput = redstone.getInput(sidea)
if redstoneinput == true then
if On == false then
redstone.setOutput(sideb, true)
On = true
elseif On == true then
redstone.setOutput(sideb, false)
On = false
end
end
sleep(0.1)
end
end
function ChooseGate(...)
print("1=NotGate 2=AndGate 3=NandGate 4=OrGate 5=RedClock 6=XorGate 7=XnorGate")
Gate = io.read()
if Gate == "1" then
parallel.waitForAny(NotGate, waitforkey)
elseif Gate == "2" then
parallel.waitForAny(AndGate, waitforkey)
elseif Gate == "3" then
parallel.waitForAny(NandGate, waitforkey)
elseif Gate == "4" then
parallel.waitForAny(OrGate, waitforkey)
elseif Gate == "5" then
parallel.waitForAny(RedClock, waitforkey)
elseif Gate == "6" then
parallel.waitForAny(XorGate, waitforkey)
elseif Gate == "7" then
parallel.waitForAny(XnorGate, waitforkey)
elseif Gate == "8" then
parallel.waitForAny(TFlipFlop, waitforkey)
elseif Gate == "9" then
parallel.waitForAny(wirelessreceive, waitforkey)
elseif Gate == "10" then
parallel.waitForAny(wirelesssend, waitforkey)
end
end
print("RedGates 1.01")
ChooseGate()
edit : i have figured out what i did wrong and fixed it
edit 2: update 1.1 is out now, which contains this