This is a read-only snapshot of the ComputerCraft forums, taken in April 2020.
revjoe's profile picture

Rednet Error Help Me Plz :)

Started by revjoe, 12 May 2014 - 05:15 PM
revjoe #1
Posted 12 May 2014 - 07:15 PM
Line 52 says unexpected symbol, if i remove the label of the other computer i get rednet 347 positive number expected. I keep trying to get this menu workin this is the last component to it and just cant get it to work.







local function menu(...) -- ver 0.1
    local sel = 1
    local list = {...}
    local offX,offY = term.getCursorPos()
    local curX,curY = term.getCursorPos()
    while true do
		    if sel > #list then sel = 1 end
		    if sel < 1 then sel = #list end
		    for i = 1,#list do
				    term.setCursorPos(offX,offY+i-1)
				    if sel == i then
						    print("["..list[i].."]")
				    else
						    print(" "..list[i].." ")
				    end
		    end
		    while true do
				    local e,e1,e2,e3,e4,e5,e6 = os.pullEvent()
				    if e == "key" then
						    if e1 == 200 then -- up key
								    sel = sel-1
								    break
						    end
						    if e1 == 208 then -- down key
								    sel = sel+1
								    break
						    end
						    if e1 == 28 then
								    term.setCursorPos(curX,curY)
								    return list[sel],sel
						    end
				    end
		    end
    end
end
-- Example Usage
term.clear()
term.setCursorPos(1,1)
print("Uber Prison- RevJoes Security Control System")
term.setCursorPos(2,2)
print("Please select Option")
local selection = menu("Activate Holding Shield", "Deactivate Holding Shield", "Electrify Holding Area")
if selection == "Activate Holding Shield" then
    term.clear()
    password = "holder"
    term.setCursorPos(1,1)
    print("Warden Access, Please Enter Security Code:-")
    pass = read("*")
    if pass == password then
    print("Security Code Accepted, Activating Holding Shield")
    rednet.open("top")
    rednet.send(77,”activate”)
    else
    term.clear()
    term.setCursorPos(1,1)
    print("Wrong Code Entered, Alarm Activating")
    sleep(0.5)
    redstone.setBundledOutput("bottom",colors.green,true)
    sleep(3)
    redstone.setBundledOutput("bottom",colors.green,false)
    os.reboot()
    end
elseif selection == "Deactivating Holding Shield" then
    term.clear()
    password = "unhold"
    term.setCursorPos(1,1)
    print("Warden Access, Please Enter Security Code:-")
    pass = read("*")
    if pass == password then
    print("Security Code Accepted, Deactivating Holding Shield")
    redstone.setBundledOutput("bottom",colors.black,false)
    os.reboot()
    else
    term.clear()
    term.setCursorPos(1,1)
    print("Wrong Code Entered, Alarm Activating")
    sleep(0.5)
    redstone.setBundledOutput("bottom",colors.green,true)
    sleep(3)
    redstone.setBundledOutput("bottom",colors.green,false)
    os.reboot()
    end
elseif selection == "Electrify Holding Area" then
    term.clear()
    password = "shock"
    term.setCursorPos(1,1)
    print("Caution This Will Kill All Vulnerable Players In Holding Area")
    term.setCursorPos(2,2)
    print("Warden Access, Please Enter Security Code:-")
    pass = read("*")
    if pass == password then
    print("Security Code Accepted, Frying Bitch's")
    sleep(1)
    local i = 5
    repeat
    redstone.setBundledOutput("bottom",colors.brown,true)
    sleep(2)
    redstone.setBundledOutput("bottom",colors.brown,false)
    i = i + 1
    until i == 5
    os.reboot()
    else
    term.clear()
    term.setCursorPos(1,1)
    print("Wrong Code Entered, Alarm Activating")
    sleep(0.5)
    redstone.setBundledOutput("bottom",colors.green,true)
    sleep(3)
    redstone.setBundledOutput("bottom",colors.green,false)
    os.reboot()
    end
end
revjoe #2
Posted 13 May 2014 - 02:22 PM
Ok so ive now got the first function workin it tells a remote terminal to activate the shield but wen i try to use the deactivate function nothing happens, the menu in the console glitches and opens a command prompt in the middle of the previous options. This is the code im using currently.

local function menu(...) -- ver 0.1
    local sel = 1
    local list = {...}
    local offX,offY = term.getCursorPos()
    local curX,curY = term.getCursorPos()
    while true do
		    if sel > #list then sel = 1 end
		    if sel < 1 then sel = #list end
		    for i = 1,#list do
				    term.setCursorPos(offX,offY+i-1)
				    if sel == i then
						    print("["..list[i].."]")
				    else
						    print(" "..list[i].." ")
				    end
		    end
		    while true do
				    local e,e1,e2,e3,e4,e5,e6 = os.pullEvent()
				    if e == "key" then
						    if e1 == 200 then -- up key
								    sel = sel-1
								    break
						    end
						    if e1 == 208 then -- down key
								    sel = sel+1
								    break
						    end
						    if e1 == 28 then
								    term.setCursorPos(curX,curY)
								    return list[sel],sel
						    end
				    end
		    end
    end
end
-- Example Usage
term.clear()
term.setCursorPos(1,1)
print("Uber Prison- RevJoes Security Control System")
term.setCursorPos(2,2)
print("Please select Option")
local selection = menu("Activate Holding Shield", "Deactivate Holding Shield", "Electrify Holding Area")
if selection == "Activate Holding Shield" then
    term.clear()
    password = "holder"
    term.setCursorPos(1,1)
    print("Warden Access, Please Enter Security Code:-")
    pass = read("*")
    if pass == password then
    print("Security Code Accepted, Activating Holding Shield")
    rednet.open("top")
    rednet.send(23, "activate")
    shell.run("menu")
    else
    term.clear()
    term.setCursorPos(1,1)
    print("Wrong Code Entered, Alarm Activating")
    sleep(0.5)
    redstone.setBundledOutput("bottom",colors.green,true)
    sleep(3)
    redstone.setBundledOutput("bottom",colors.green,false)
    os.reboot()
    end
elseif selection == "Deactivating Holding Shield" then
    term.clear()
    password = "unhold"
    term.setCursorPos(1,1)
    print("Warden Access, Please Enter Security Code:-")
    pass = read("*")
    if pass == password then
    print("Security Code Accepted, Activating Holding Shield")
    rednet.open("top")
    rednet.send(23, "deactivate")
    shell.run("menu")
    else
    term.clear()
    term.setCursorPos(1,1)
    print("Wrong Code Entered, Alarm Activating")
    sleep(0.5)
    redstone.setBundledOutput("bottom",colors.green,true)
    sleep(3)
    redstone.setBundledOutput("bottom",colors.green,false)
    os.reboot()
    end
elseif selection == "Electrify Holding Area" then
    term.clear()
    password = "shock"
    term.setCursorPos(1,1)
    print("Caution This Will Kill All Vulnerable Players In Holding Area")
    term.setCursorPos(2,2)
    print("Warden Access, Please Enter Security Code:-")
    pass = read("*")
    if pass == password then
    print("Security Code Accepted, Frying Bitch's")
    sleep(1)
    local i = 5
    repeat
    redstone.setBundledOutput("bottom",colors.brown,true)
    sleep(2)
    redstone.setBundledOutput("bottom",colors.brown,false)
    i = i + 1
    until i == 5
    os.reboot()
    else
    term.clear()
    term.setCursorPos(1,1)
    print("Wrong Code Entered, Alarm Activating")
    sleep(0.5)
    redstone.setBundledOutput("bottom",colors.green,true)
    sleep(3)
    redstone.setBundledOutput("bottom",colors.green,false)
    os.reboot()
    end
end