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

Rednet programming

Started by Dragon53535, 08 December 2012 - 10:29 AM
Dragon53535 #1
Posted 08 December 2012 - 11:29 AM
HAHA COMPLETE! i tried removing the quotes around the key i wanted pressed and it worked!







function main()
local sSide = "back" --side monitor is on

local mon = peripheral.wrap(sSide)
    if not mon then
        print("No monitor on ", sSide)
        return
    elseif mon then
        main2()
    end
end

function main2()
local serverID = 0 -- computer connecting to sever
local sSide = "back" --monitor side again
local clear = "clear" -- command to clear screen
local command = "command" -- command to be able to run other programs, will send you to function command()
local music = "music" -- to turn on music in the disk drive connected
local drive = "right" -- side drive is on
local mon = peripheral.wrap("back")
mon.setCursorPos(1,1)
term.redirect(mon)
while true do
rednet.open("left") -- change to side modem is on
    event, id, msg, param1 = os.pullEvent()
        if event == "rednet_message" then
            if id == serverID then
                if msg == clear then
                    mon.clear()
                    mon.setCursorPos(1,1)
                elseif msg == command then
                    rom()
                elseif msg == music then
                    disk.playAudio(drive) 
                else
                   print(msg)
                end
            end 
        elseif event == "char" and param1 == r then
            os.reboot()  
        end
    end
end

function rom()
local serverID = 0 -- again the computer connecting
local exit = "exit" -- what you want to go back to putting text on the monitor
    while true do
    local id, msg = rednet.receive()
        if id == serverID then
            if msg == exit then
                main2()
            else shell.run(msg)
            end
        end
    end
end

main()


AndreWalia #2
Posted 08 December 2012 - 11:48 AM
before the end of the script and the last end put

shell.run(msg)
but the msg has to be something like "rom/exampleDirectory/exampleProgram" instead of shell.run("rom/exampleDirectory/exampleProgram")
Dragon53535 #3
Posted 08 December 2012 - 11:52 AM
before the end of the script and the last end put

shell.run(msg)
but the msg has to be something like "rom/exampleDirectory/exampleProgram" instead of shell.run("rom/exampleDirectory/exampleProgram")
i could do that, which is good but what i also want is if its connected to a screen i want to be able to remotely edit the text.
Lyqyd #4
Posted 08 December 2012 - 03:58 PM
I hate to advertise, but it kinda sounds like you're looking for nsh. Are you wanting a program that does that, or are you wanting to code it yourself? If it's just the first one, check out nsh.
Dragon53535 #5
Posted 09 December 2012 - 07:23 AM
I hate to advertise, but it kinda sounds like you're looking for nsh. Are you wanting a program that does that, or are you wanting to code it yourself? If it's just the first one, check out nsh.
i'm wanting to code for myself and i have been doing so, and i don't mind about adverts lol

Edit: I've tried your nsh and i like it, it makes it so i can edit or so whatever from far away, which is nice, but i like mine moreish since i'm almost done only thing left is to figure out how to make it shutdown or exit the program…