20 posts
Posted 19 December 2012 - 09:14 AM
As the title says I'm having trouble creating a program to monitor my reactor status VIA wifi… the master PC is the software i'm writing right now and haven't even started on the slave. Basically my reactors send a redstone signal to the MASTER if they get too hot since the PC can only receive four signals at a time with a wifi attached i can only use bottom, left, right, and back as the top and front are reserved for viewing when on site at the reactor and wifi transmission. My hope is to write a easily configurable script that can be used to transmit any redstone data Via wifi for any device.
The problem I'm currently having is I'm just too noob at this and just cant seem to understand how to properly loop my program to send the data over and over updating the reactor status until a user ends the program (honestly don't want it to end at all just loop).
Currently it will loop until a overheat signal is received send the message via wifi then ends–this needs to be fixed– and wont detect a signal that is already active but once a new signal is detected it will then detect the prior undetected signals at startup–this needs to be fixed– (spending alot of time trying to type this as detailed and simplistically as possible -.-*), anywho… no I don't have RP2 or tekkit and don't want or plan to get them so they are not an option.
If someone can help, please!!! I love writing code!!!
here is the current code for the MASTER PC I will be working on it until i hear back so there may be more added
P.S. I only have 2 of my 4 nuclear reactors written into the code for testing purposes (I couldn't get the entire program to loop) and have not written code for the SLAVE PC
while true do
rs.getInput("left")
os.pullEvent("redstone")
if rs.getInput("left") then
rednet.open("top")
rednet.send(85, "Blue Core is Hot")
rednet.close("top")
print("Blue core Overheating")
print("Please check Coolant levels")
sleep(2)
rs.getInput("right")
if rs.getInput("right") then
rednet.open("top")
rednet.send(85, "Yellow Core Hot")
rednet.close("top")
print("Yellow Core Overheating")
print("Pleade check coolant levels")
end
break
end
end
again thanks to all… g43tt0d3xt3r a.k.a ghetto n3rd
120 posts
Posted 19 December 2012 - 09:40 AM
first off use the code tags
second , you dont have an end statement after the first reactor , so it will check first if over heating , then only after it has over heated it will check the other one. then when you do finish the yellow check it immeaditly break out of the loop
20 posts
Posted 19 December 2012 - 09:48 AM
Awesome FRIGGIN AWESOME!!!! yo dude thanks soooooo much and again i'm noob so i have no clue how to use the
tag thingy first I've heard of it. and don't know how can you explain so i don't have the problem here in the future and maybe get banned or something?
2088 posts
Location
South Africa
Posted 19 December 2012 - 09:55 AM
[*code]Your code here[*/code]
.. but don't include the *'s
20 posts
Posted 19 December 2012 - 10:00 AM
thanks
20 posts
Posted 19 December 2012 - 10:25 AM
ok now im getting a tool long without yeilding error…. Im sure its because it just endlessly looping but i need it to… is there a way to fix it?
while true do
rs.getInput("left")
os.pullEvent("redstone")
if rs.getInput("left") then
rednet.open("top")
rednet.send(85, "Blue Core is Hot")
rednet.close("top")
print("Blue core Overheating")
print("Please check Coolant levels")
end
while true do
rs.getInput("right")
if rs.getInput("right") then
rednet.open("top")
rednet.send(85, "Yellow Core Hot")
rednet.close("top")
print("Yellow Core Overheating")
print("Please check coolant levels")
end
while true do
rs.getInput("bottom")
if rs.getInput("bottom")then
rednet.open("top")
rednet.send(85, "Red Core Hot")
rednet.close("top")
print("Red Core Overheating")
print("Please check coolant levels")
end
while true do
rs.getInput("back")
if rs.getInput("back") then
rednet.open("top")
rednet.send(85, "Green Core Hot")
rednet.close("top")
print("Green Core Overheating")
print("Please check coolant levels")
break
end
end
end
end
end
2088 posts
Location
South Africa
Posted 19 December 2012 - 10:28 AM
Yeah add a sleep(0):
while true do
rs.getInput("left")
os.pullEvent("redstone")
if rs.getInput("left") then
rednet.open("top")
rednet.send(85, "Blue Core is Hot")
rednet.close("top")
print("Blue core Overheating")
print("Please check Coolant levels")
end
while true do
rs.getInput("right")
if rs.getInput("right") then
rednet.open("top")
rednet.send(85, "Yellow Core Hot")
rednet.close("top")
print("Yellow Core Overheating")
print("Please check coolant levels")
end
while true do
rs.getInput("bottom")
if rs.getInput("bottom")then
rednet.open("top")
rednet.send(85, "Red Core Hot")
rednet.close("top")
print("Red Core Overheating")
print("Please check coolant levels")
end
while true do
rs.getInput("back")
if rs.getInput("back") then
rednet.open("top")
rednet.send(85, "Green Core Hot")
rednet.close("top")
print("Green Core Overheating")
print("Please check coolant levels")
break
end
end
end
end
sleep(0)
end
EDIT: Actually you had too much unnecessary stuff in the code, try this:
Spoiler
rednet.open("top")
while true do
os.pullEvent("redstone")
if rs.getInput("left") then
rednet.send(85, "Blue Core is Hot")
print("Blue core Overheating")
print("Please check Coolant levels")
elseif rs.getInput("right") then
rednet.send(85, "Yellow Core Hot")
print("Yellow Core Overheating")
print("Please check coolant levels")
elseif rs.getInput("bottom")then
rednet.send(85, "Red Core Hot")
print("Red Core Overheating")
print("Please check coolant levels")
elseif rs.getInput("back") then
rednet.send(85, "Green Core Hot")
print("Green Core Overheating")
print("Please check coolant levels")
break
end
end
20 posts
Posted 19 December 2012 - 10:41 AM
cool… it no longer says the error but now just reads only one core then hangs, hmm testing different codes to see why… Lua Maniac your too awesome though dude.
*sorry didnt see your update
Edited on 19 December 2012 - 09:46 AM
20 posts
Posted 19 December 2012 - 10:42 AM
yea it'll read only the first one to send a signal then do nothing else but at least it doesn't exit the program anymore.
20 posts
Posted 19 December 2012 - 10:45 AM
ohh I love this… first time coding was in HS on a TI-83 lol i made a tetris wannabe and my teacher was amazed, unfortunately I havent done anything in a long time to remember anything useful…. ahhh I suck :angry:/>
20 posts
Posted 19 December 2012 - 10:52 AM
Lua maniac WTF dude!!! I bow down to you and all your coding glory good job im now gonna start on the slave.
2088 posts
Location
South Africa
Posted 19 December 2012 - 10:53 AM
Oh my bad, didn't see that all the if's were different sides ;)/> didn't really look. Change it to this then :)/>
rednet.open("top")
while true do
os.pullEvent("redstone")
term.clear() term.setCursorPos(1,1) -- reset cursor position
if rs.getInput("left") then
rednet.send(85, "Blue Core is Hot")
print("Blue core Overheating")
print("Please check Coolant levels")
end
if rs.getInput("right") then
rednet.send(85, "Yellow Core Hot")
print("Yellow Core Overheating")
print("Please check coolant levels")
end
if rs.getInput("bottom")then
rednet.send(85, "Red Core Hot")
print("Red Core Overheating")
print("Please check coolant levels")
end
if rs.getInput("back") then
rednet.send(85, "Green Core Hot")
print("Green Core Overheating")
print("Please check coolant levels")
break
end
end
514 posts
Location
Over there
Posted 19 December 2012 - 10:53 AM
Lua Maniac your too awesome though dude.
"Lua Maniac" is just the title, the use names are in the blue bar above, his real name is remiX, just so you know,
This happened to me too, when I was new :P/>
20 posts
Posted 19 December 2012 - 11:08 AM
remiX sorry dude…. :rolleyes:/> I'm an idiot and dont read before i talk… gosh i feel dumb… the other one you gave seems to work fine though havent started a slave to test it yet and still dont know how to make a command list for the other end either but a will figure it out…
I've only been playing PC version for a few days and just learned about the coding aspect a day ago so im literally fresh to all this but i can see the possibilities of using CC on MC, I have the Yalies (Yale) in my neborhood coming to me for PC repairs and custom shizzle (i got a laser engraver and 3D printer) so learning the coding side as well as repair would be great! Plus im buying a Nao as an X-mas gift to me so that will be awesome knowing a lil' bit ya digg?
2088 posts
Location
South Africa
Posted 19 December 2012 - 11:45 AM
Haha a lot of people get confused with where to read peoples' names.
You're buying yourself a X-mas present? Haha nice ;)/>
20 posts
Posted 19 December 2012 - 01:09 PM
Hey the program works ok so far small issue im having though startup 7 attempt to call nil I know that means nothing but im just trying to refresh the screen… what am i doing wrong?
rednet.open("back")
mon = peripheral.wrap("top")
while true do
id,message = rednet.receive()
if id == 86 and message == "Blue Core Hot" then
term.redirect(mon)
term.clearScreen()
mon.setTextScale(1.5)
term.setBackgroundColor(2048)
term.setCursorPos(1,1)
print("Blue reactor core is hot")
end
if id == 86 and message == "Yellow Core Hot" then
term.redirect(mon)
term.clearScreen()
mon.setTextScale(1.5)
term.setBackgroundColor(16)
term.setTextColor(32768)
term.setCursorPos(1,1)
print("Yellow reactor core is hot")
end
if id == 86 and message == "Red Core Hot" then
term.redirect(mon)
term.clearScreen()
mon.setTextScale(1.5)
term.setBackgroundColor(16384)
term.setTextColor(32768)
term.setCursorPos(1,1)
print("Red reactor core is hot")
end
if id == 86 and message == "Green Core Hot" then
term.redirect(mon)
term.clearScreen()
mon.setTextScale(1.5)
term.setBackgroundColor(8192)
term.setTextColor(2048)
term.setCursorPos(1,1)
print("Green reactor core is hot")
end
if id == 86 and message == "ERS Restart must be initiated on site" then
term.redirect(mon)
term.clearScreen()
mon.setTextScale(1.5)
term.setBackgroundColor(16384)
term.setTextColor(32768)
term.setCursorPos(1,1)
print("Emergency Reactor shutdown Venting active. Clean in 30 seconds, cooldown time is 1 minute.")
break
end
end
2088 posts
Location
South Africa
Posted 19 December 2012 - 01:29 PM
It's term.clear() not term.clearScreen()
20 posts
Posted 19 December 2012 - 01:47 PM
yea i fixed it already… It works GREAT!!! better than expected. I'm now done with the master and slave and am introducing a 3rd party… the turtle… this will start the emergency reactor shutdown then go back to its 'home' location until ERS is activated again.
I know why have a turtle do it… well because i have no more ways left to input/output information from my PC to the reactor so i updated it to send a message to my turtle ERS MODE :D/>
if rs.getInput("front") then
rednet.send(85, "ERS Restart must be initiated on site")
rednet.send(84, "ERS MODE")
print("Emergency Reactor Shutdown")
print("Venting active. Clean in 30 seconds, cooldown time is 1 minute.")
break
end
end
20 posts
Posted 19 December 2012 - 01:49 PM
i'll load the completed program when done… testing..
20 posts
Posted 19 December 2012 - 05:53 PM
This is the latest and so far final update to this code until a new idea crosses my mind
Put this on the MASTER PC as a startup file.
rednet.open("top")
while true do -- loop from here
os.pullEvent("redstone")
if rs.getInput("left") then -- basically you'll want to set your core or cores to have its thermometers going to each side of the pc
rednet.send(85, "Blue Core Hot") -- sending a message to the slave that...
print("Blue core Overheating")
print("Please check Coolant levels")
end
if rs.getInput("right") then
rednet.send(85, "Yellow Core Hot")
print("Yellow Core Overheating")
print("Please check coolant levels")
end
if rs.getInput("bottom")then
rednet.send(85, "Red Core Hot")
print("Red Core Overheating")
print("Please check coolant levels")
end
if rs.getInput("back") then
rednet.send(85, "Green Core Hot")
print("Green Core Overheating")
print("Please check coolant levels")
end
if rs.getInput("front") then --this is the part that controls emergency shutoff you can again change to whatever side suits your design.
rednet.send(85, "ERS Restart must be initiated on site")
sleep(3) -- for some reason it wont send a message to the turtle unless it sleeps first idk but it works so...
rednet.send(92, "ERS MODE") -- starting the turtle to destroy the block or fuse that shuts of all power and or clears uraniun from the core
print("Emergency Reactor Shutdown")
print("Venting active. Clean in 30 seconds, cooldown time is 1 minute.")
break -- ends the loop here
end
end
20 posts
Posted 19 December 2012 - 06:01 PM
This goes onto the SLAVE PC
rednet.open("back")
mon = peripheral.wrap("top") -- unless you have a advanced monitor then delet all line with a -- DEL at the end
while true do -- loop
id,message = rednet.receive()
if id == 86 and message == "Blue Core Hot" then
term.redirect(mon) -- DEL
term.clear()
mon.setTextScale(1.5) -- DEL
term.setBackgroundColor(2048) -- DEL
term.setCursorPos(1,1)
print("Blue reactor core is hot")
end
if id == 86 and message == "Yellow Core Hot" then
term.redirect(mon) -- DEL
term.clear()
mon.setTextScale(1.5) -- DEL
term.setBackgroundColor(16) -- DEL
term.setTextColor(32768) -- DEL
term.setCursorPos(1,1)
print("Yellow reactor core is hot")
end
if id == 86 and message == "Red Core Hot" then
term.redirect(mon) -- DEL
term.clear()
mon.setTextScale(1.5) -- DEL
term.setBackgroundColor(16384) -- DEL
term.setTextColor(32768) -- DEL
term.setCursorPos(1,1)
print("Red reactor core is hot")
end
if id == 86 and message == "Green Core Hot" then
term.redirect(mon) -- DEL
term.clear()
mon.setTextScale(1.5) -- DEL
term.setBackgroundColor(8192) -- DEL
term.setTextColor(2048) -- DEL
term.setCursorPos(1,1)
print("Green reactor core is hot")
end
if id == 86 and message == "ERS Restart must be initiated on site" then
term.redirect(mon) -- DEL
term.clear()
mon.setTextScale(1.5) -- DEL
term.setBackgroundColor(16384) -- DEL
term.setTextColor(32768) -- DEL
term.setCursorPos(1,1)
print("Emergency Reactor shutdown Venting active. Clean in 30 seconds, cooldown time is 1 minute.")
break
end
end
20 posts
Posted 19 December 2012 - 06:06 PM
Lastly this is the program I use for my turtle, I guess its useless unless you dont know how to make your turtle just sit waiting for a command to do something without ending the program either way the code is easy and no matter what you'll have to write something to get you own turtle from a to b.
This is also just like the others made to be a startup file.
rednet.open("right") -- opens wifi
while true do -- loop from here
id,message = rednet.receive() -- leave blank to listen forever
if id == 86 and message == "ERS MODE" then -- recive message from master computer
turtle.refuel(32) -- create your own code to get your turtle to mover where need to break a wire causing the reactor to shut off
turtle.forward(1) -- moving to shut off
turtle.forward(1)
turtle.forward(1)
turtle.forward(1)
turtle.forward(1)
turtle.forward(1)
turtle.turnRight(1)
turtle.forward(1)
turtle.forward(1)
turtle.forward(1)
turtle.forward(1)
turtle.forward(1)
turtle.forward(1)
turtle.forward(1)
turtle.turnLeft(1)
turtle.forward(1)
turtle.forward(1)
turtle.forward(1)
turtle.forward(1)
turtle.dig(1) -- yay it cut the wire now to go back to start position
turtle.turnLeft(1) -- going to home
turtle.turnLeft(1)
turtle.forward(1)
turtle.forward(1)
turtle.forward(1)
turtle.forward(1)
turtle.turnRight(1)
turtle.forward(1)
turtle.forward(1)
turtle.forward(1)
turtle.forward(1)
turtle.forward(1)
turtle.forward(1)
turtle.forward(1)
turtle.turnLeft(1)
turtle.forward(1)
turtle.forward(1)
turtle.forward(1)
turtle.forward(1)
turtle.forward(1)
turtle.forward(1)
turtle.turnRight(1)
turtle.turnRight(1) -- you may want to add a line for the turtle to contact you when complete
end
end -- done
20 posts
Posted 19 December 2012 - 06:12 PM
well thats that my current setup is awesome and now i dont need to run across the map to check my reactors status because the information is all right there on the main screen at my base over 300 blocks away with nothing but wifi…. awesome!!!