Posted 31 July 2013 - 02:57 PM
Hello, I am fairly new to ComputerCraft. I have currently made a program detects when my BuildCraft quarry is done mining, then sends it off to another computer, and displays that it is done. The only problem, is that I want to get rid of the scrolling…one way I figured I could do that, was have the message state an if command, and then set/change a variable, and then print it. The only problem, is that because of the repeat, it is pointless and just keeps repeating. It is hard to explain, so take a look at the code. But I was looking to somehow set a variable, and the message change the variable. That way, I could display something like "Quarry Status: *VARIABLE*", and have the variable state the activity. This way, I do not have to have it keep repeatedly updating with "Quarry Running, Quarry Running, etc."
Edit: I explained that rather bad, if you run the code, you can notice that as an item passes over the item detector, and emits a signal, it appears on the monitor, but because it only pulses, it will then display the "Quarry is done" message. Is there an alternative to this? I am okay with it doing this, if it wouldnt appear on the monitor to many times. Which was why i was wondering if it were possible to assign the variables, to avoid the scrolling and have more of "Quarry Status : VAR".
Here is the code.
Receiver code…where I was trying to do this:
Sender Code:
Edit: I explained that rather bad, if you run the code, you can notice that as an item passes over the item detector, and emits a signal, it appears on the monitor, but because it only pulses, it will then display the "Quarry is done" message. Is there an alternative to this? I am okay with it doing this, if it wouldnt appear on the monitor to many times. Which was why i was wondering if it were possible to assign the variables, to avoid the scrolling and have more of "Quarry Status : VAR".
Here is the code.
Receiver code…where I was trying to do this:
rednet.open("top")
message = 0
-- sets a variable called message to 0. This will
-- allow us to store a message later
print("ComputerID")
print(os.getComputerID())
print("Listening...")
function checkMessage() -- start of function
if message == "RUNNING" then
print("Quarry - running.")
elseif message == "NORUNNING" then
print("Quarry - not running.")
end
end
repeat
event,p1,p2,p3 = os.pullEvent()
if event == "rednet_message" then
message=p2 -- overwrites our message variable
checkMessage() -- this calls our function above
end
until event == "char" and p1 == "x"
Sender Code:
rednet.open("top")
print("Computer ID")
print(os.getComputerID())
function checkSide() -- start of the function
if redstone.getInput("right","true")
then
rednet.send(36,"RUNNING")
print("RUNNING sent to ID 36")
else
rednet.send(36,"NORUNNING")
print("NOT RUNNING sent to ID 36")
end
end -- end of the function
repeat
event,p1,p2,p3 = os.pullEvent()
if event=="redstone" then
checkSide() -- this runs our function
end
until event=="char" and p1== "x"