the reason i would like this to work is so i can develop a computercraft controlled progressive heat monitor using nuclear control, computercraft, openccSensors and project red, any help would be appreciated
regards V497_vesper
--#These lines with the --# are comments, don't actually type them
--#First thing, getting to the place to type commands.
lua
--# That's it, that's the program that lets you type commands.
chatbox = peripheral.wrap("right")
--# Change the right to the side the chatbox is in. You have now wrapped the peripheral.
--# Should we want to use the chatbox, we use that chatbox variable name.
--# At this stage we don't know what the chatbox can do, we can google it, or we can just grab the names of what it does.
print(textutils.tabulate(chatbox))
--#This will print out two columns of words, these words are the methods of the chatbox, and are our commands to use it.
--#Now after working with chatboxes myself, I can tell you that one of them will be say.
--#Lets say something to everyone in a radius around the box.
chatbox.say("Hello there people")
--#To put it in a few lines, here's the commands you're typing.
lua
chatbox = peripheral.wrap("right")
print(textutils.tabulate(chatbox))
chatbox.say("Hello there people")
thanks for the response, however when i put in the commands that you say i get thisIt is already recognizing it, however the way the computer is setup is that you cannot actually type code commands such as peripheral.wrap into the shell. You'd need to get to the area that allows you to do so. The reason that this is so is that it works like that on your computer you're using right now. You cannot just go into the file browers and tell it to execute code. It will try to search for a file with the name of whatever code you typed, and tell you no file found. However, if you go to the command prompt, it will allow you to type commands into it.
I'll give a short tutorial of how to do so in CC.--#These lines with the --# are comments, don't actually type them --#First thing, getting to the place to type commands. lua --# That's it, that's the program that lets you type commands. chatbox = peripheral.wrap("right") --# Change the right to the side the chatbox is in. You have now wrapped the peripheral. --# Should we want to use the chatbox, we use that chatbox variable name. --# At this stage we don't know what the chatbox can do, we can google it, or we can just grab the names of what it does. print(textutils.tabulate(chatbox)) --#This will print out two columns of words, these words are the methods of the chatbox, and are our commands to use it. --#Now after working with chatboxes myself, I can tell you that one of them will be say. --#Lets say something to everyone in a radius around the box. chatbox.say("Hello there people") --#To put it in a few lines, here's the commands you're typing. lua chatbox = peripheral.wrap("right") print(textutils.tabulate(chatbox)) chatbox.say("Hello there people")
Moved to Ask A Pro.
Please post any code you have, so that we may help you troubleshoot what you have.
edit filename
Boom, you'll get a mostly blank screen, with a bit of text at the bottom left. You are now inside a file and making a script. Whatever you type here, as long as it's code or comments (Denoted by typing –) it will work. Of course you should of noticed the code I gave you failed to work and sent an error, that was my mistake. Now lets say that you've put in whatever code you want into the file, and want to test it. You need to press ctrl, then move the cursor to save and press enter, then ctrl and move it to exit and press enter.
filename:lineNumber:error
So if we were to go into the textutils api file we would look at line 104 to see our error, however we already know the error problem is that I didn't supply the correct type of data to the function textutils.tabulate and it errored for that.
filename:1:Attempt to index ? (A nil value)
Ah so on line one, we're screwing up, okay.Unfortunately, while quite clever, Dragon's solution will only allow you to detect one colour at a time - whichever enabled one is closest to your computer. If you want to use the bundled cable as a proper bundled cable, you'll have to get rs.getBundledInput() working.
Maybe you've got read-only capabilities? I've got a memory that some version of Project Red was limited in that way, but for your purposes, that may be enough! Try rs.getBundledInput("back") with various colours lit/unlit and see what results you get back.
Please post the version numbers for ComputerCraft and ProjectRed.
You appear to have an outdated version of ProjectRed. Try updating to a more recent build (4.6+).
for i,v in pairs(API) do print(i) end
table = peripheral.getMethods("left")
for i=1,#table do
print(table[i])
end
Real quick. I watched the video, however I'm confused how the computer will be getting the information about the reactor being overheated. Earlier I assumed that the redstone was what gave the computer the information about the reactor being heated up, however now I'm not so sure.
print(colors.test(rs.getBundledInput("back"),colors.red))
Try this with the red cable turned on.
local input = rs.getBundledInput("back")
if colors.test(input,colors.red) then
--#Do emergency stuff
elseif colors.test(input,colors.orange) then --# Or whatever the next lowest is
--#Do the next level downs stuff
elseif colors.test(input,colors.green) then --# add more of these for each color, going down the line of highest to lowest.
--# Do the green stuffs
end
while true do
-- check input, do speaker stuff
os.pullEvent("redstone")
end
speaker=peripheral.wrap("right")
local input = rs.getBundledInput("back") --#set the input variable to whatever the bundled input was when
--#the program was started. This variable is not changed anywhere.
while true do --#forever
os.pullEvent("redstone") --#pull the redstone event
end
--#everything below here will not be executed, because you never exit the above loop
if colors.test(input,colors.red) then
speaker.speak("Reactor Critical! Reactor critical! Meltdown Imminent")
end --#this end is unnecessary and wrong; you can't have an else after you end your if.
--#it also causes the <eof> expected (End Of File) error.
elseif colors.test(input,colors.pink) then
speaker.speak("Danger! Reactor heat level Critical! Evacuate all none essentail Personnel!")
elseif colors.test(input,colors.green) then
speaker.speak("Danger! Reactor Heat level at 6000 Degrees!")
elseif colors.test(input,colors.yellow) then
speaker.speak("Warning! Reactor Heat Level above Acceptable limit!")
elseif colors.test(input,colors.blue) then
speaker.speak("Caution! reactor Heat level at 4000 degrees!")
elseif colors.test(input,colors.magenta) then
speaker.speak("Caution! Reactor Heat above Normal Level!")
elseif colors.test(input,colors.orange) then
speaker.speak("Attention! Reactor Heat Level at 2000 degrees")
elseif colors.test(input,colors.white) then
speaker.speak("attention, Reactor heat level increase detected")
end --#here you end your if/elseif statement.
</eof>speaker=peripheral.wrap("right")
while true do
os.pullEvent("redstone")
local input = rs.getBundledInput("back")
end
if colors.test(input,colors.red) then
speaker.speak("Reactor Critical! Reactor critical! Meltdown Imminent")
elseif colors.test(input,colors.pink) then
speaker.speak("Danger! Reactor heat level Critical! Evacuate all none essentail Personnel!")
elseif colors.test(input,colors.green) then
speaker.speak("Danger! Reactor Heat level at 6000 Degrees!")
elseif colors.test(input,colors.yellow) then
speaker.speak("Warning! Reactor Heat Level above Acceptable limit!")
elseif colors.test(input,colors.blue) then
speaker.speak("Caution! reactor Heat level at 4000 degrees!")
elseif colors.test(input,colors.magenta) then
speaker.speak("Caution! Reactor Heat above Normal Level!")
elseif colors.test(input,colors.orange) then
speaker.speak("Attention! Reactor Heat Level at 2000 degrees")
elseif colors.test(input,colors.white) then
speaker.speak("attention, Reactor heat level increase detected")
end
speaker=peripheral.wrap("right")
while true do
os.pullEvent("redstone")
local input = rs.getBundledInput("back")
if colors.test(input,colors.red) then
speaker.speak("Reactor Critical! Reactor critical! Meltdown Imminent")
elseif colors.test(input,colors.pink) then
speaker.speak("Danger! Reactor heat level Critical! Evacuate all none essentail Personnel!")
elseif colors.test(input,colors.green) then
speaker.speak("Danger! Reactor Heat level at 6000 Degrees!")
elseif colors.test(input,colors.yellow) then
speaker.speak("Warning! Reactor Heat Level above Acceptable limit!")
elseif colors.test(input,colors.blue) then
speaker.speak("Caution! reactor Heat level at 4000 degrees!")
elseif colors.test(input,colors.magenta) then
speaker.speak("Caution! Reactor Heat above Normal Level!")
elseif colors.test(input,colors.orange) then
speaker.speak("Attention! Reactor Heat Level at 2000 degrees")
elseif colors.test(input,colors.white) then
speaker.speak("attention, Reactor heat level increase detected")
end
end
speaker=peripheral.wrap("right")
local speaking = false
local red = true
while true do
while red or speaking do --#while we are waiting for redstone or the speaker to finish
local event = os.pullEvent() --#pull an event
if event == "speechComplete" then --#if the speaker stopped speaking
speaking = false --#we are no longer waiting for it to finish
elseif event == "redstone" then --#if a redstone change occured
red = false --#we are no longer waiting for redstone
end
end
local input = rs.getBundledInput("back")
speaking = true --#we're now waiting for it to speak
red = true --#and for a redstone change to occur
if colors.test(input,colors.red) then
speaker.speak("Reactor Critical! Reactor critical! Meltdown Imminent")
elseif colors.test(input,colors.pink) then
speaker.speak("Danger! Reactor heat level Critical! Evacuate all none essentail Personnel!")
elseif colors.test(input,colors.green) then
speaker.speak("Danger! Reactor Heat level at 6000 Degrees!")
elseif colors.test(input,colors.yellow) then
speaker.speak("Warning! Reactor Heat Level above Acceptable limit!")
elseif colors.test(input,colors.blue) then
speaker.speak("Caution! reactor Heat level at 4000 degrees!")
elseif colors.test(input,colors.magenta) then
speaker.speak("Caution! Reactor Heat above Normal Level!")
elseif colors.test(input,colors.orange) then
speaker.speak("Attention! Reactor Heat Level at 2000 degrees")
elseif colors.test(input,colors.white) then
speaker.speak("attention, Reactor heat level increase detected")
else
speaking = false --#we aren't waiting if it didn't speak, this is probably not needed but I like to program for any situation.
end
end
Compatibility is normally good in computer craft, as long as you try to run an old program in a newer version it will work most of the timedumb question but this program was built in computercraft 1.73, will it work in 1.74?