Posted 09 February 2013 - 03:54 PM
Howdy.
So I've recently set up a Wither farming Mystcraft world. Wither Skeleton Soul Shard spawner that provides me with Skulls, to assemble and fight Withers in a blastproof room.
I've been trying to get a computer "counter" that, upon hearing a Redstone Signal to its left, increases a variable by 1 and overwrites the count line on a 3x2 monitor on its front to display the total number of Wither kills. I'm also hoping to have this somehow keep the variable's value upon world reload, as I play LAN as opposed to servers.
For the counter to keep its number, I'm not too sure how to accomplish this. One method could be to have a WR-CBE transmitter next to the computer, and treat the Transmitter's frequency as the solid-state "kill" variable. Not sure if there's an inherent CC way of keeping values over world reload, but this would work for me.
Question is. How best would I construct a program that runs indefinitely and listens for Redstone signals?
EDIT: Okay, I figured out <something>. This, however, will return a "Too long without yielding" error after around 10 seconds of non-use. Here's my startup program:
The error suggests that "while true do" is inappropriate for what I am hoping to do here. Nobody likes infinite loops that do basically nothing for ages.
So I've recently set up a Wither farming Mystcraft world. Wither Skeleton Soul Shard spawner that provides me with Skulls, to assemble and fight Withers in a blastproof room.
I've been trying to get a computer "counter" that, upon hearing a Redstone Signal to its left, increases a variable by 1 and overwrites the count line on a 3x2 monitor on its front to display the total number of Wither kills. I'm also hoping to have this somehow keep the variable's value upon world reload, as I play LAN as opposed to servers.
For the counter to keep its number, I'm not too sure how to accomplish this. One method could be to have a WR-CBE transmitter next to the computer, and treat the Transmitter's frequency as the solid-state "kill" variable. Not sure if there's an inherent CC way of keeping values over world reload, but this would work for me.
Question is. How best would I construct a program that runs indefinitely and listens for Redstone signals?
EDIT: Okay, I figured out <something>. This, however, will return a "Too long without yielding" error after around 10 seconds of non-use. Here's my startup program:
monitor = peripheral.wrap("front")
trans = peripheral.wrap("back")
kill = trans.getFreq()
monitor.clear()
monitor.setCursorPos(1,1)
monitor.write("Wither Kill Count: "..tostring(kill))
while true do
if redstone.getInput("right") == true then do
trans.setFreq(kill + 1)
kill = trans.getFreq()
monitor.clear()
monitor.setCursorPos(1,1)
monitor.write("Wither Kill Count: "..tostring(kill))
os.sleep(1)
end
end
end
The error suggests that "while true do" is inappropriate for what I am hoping to do here. Nobody likes infinite loops that do basically nothing for ages.