Posted 30 October 2012 - 10:59 PM
Hello everyone, I am new to Computercraft and fairly new to programming generally (I have written some very basic python programs like a roulette simulator) and I have a few questions about keeping track of time and detecting inputs. At least, I think I do, because that seems like it would be needed, but I may be (read: I am almost certainly) tackling this problem the wrong way so I was hoping for any and all input. Sorry for the WALL OF TEXT, but I have tried to make it at least somewhat readable.
What I want to do relates to Industrialcraft brewing. Because it takes many hours it brew a beer I thought it would be nice to have a program where I could input the beer I am making and then have the computer keep track of how long all the beers have been fermenting and how many drinks are left in each barrel. The high level overview is as follows:
Overview:
A large monitor displays the name of beers that are being brewed and how long they have been fermenting. In another column it displays the names of the beers that are done fermenting and how many pints are left in each barrel. When a new beer is to be brewed, the name and quantity of water is entered into a computer and a lever or button near the barrel is pressed after adding the ingredients. This starts the timer and causes that beer to be displayed on the "fermenting" side of the monitor. pressing the button/lever again will signify the end of the fermentation and will move the beer to the other side of the display that shows the number of beers left in the barrel. Subsequent presses of the button/lever (which will be done every time a pint of beer is extracted from the barrel) will decrement the counter for that beer down by 1 until it reaches 0 at which point it will be removed from the list.
Concepts:
The way that I intend to tackle this is to use redstone bundled cable to attach to the back of the computer. Each lever near a beer barrel will be connected to the bundle with a different colored redstone wire. The program will associate the color of wire with the name and quantity of each beer upon creation. Each pulse of that color will then update the information associated with that beer.
Potential problems: I am not sure the best way to actually track the time because all time tracking I know if is linked to world time and sleeping will throw this off. I was considering using redpower timers and counters to emit a pulse to the computer every hour to update the time on the computer because setting the timer to a couple seconds with a long counter will make any time sync problems negligible. However, this breaks the idea of using a pulse to signify the end of the brewing unless we also include how long we want to brew each beer in the creation process so that it automatically marks it as done and moves it over when that many pulses are received. However, I will have to remember to quickly tap the barrel shortly after this or the beer may over-ferment compared to what the computer thinks it is.
Questions:
1. Am I going about the basic task in a good way? Are there concepts that I just don't know about that would allow me to work this more efficiently? I would greatly appreciate a high-level critique of the concept.
2. Is using redpower counters with short timers the most effective way to minimize time divergence when trying to have the server accurately track 12 hours of real life time as opposed to world-time? Can ComputerCraft do this by itself? How do server reboots affect systems like this?
—-
Thanks for any help you could offer and I will be sure to share my code once I start–I just wanted to make sure that my conceptual overview made sense and I am not missing anything important before I begin working it out.
What I want to do relates to Industrialcraft brewing. Because it takes many hours it brew a beer I thought it would be nice to have a program where I could input the beer I am making and then have the computer keep track of how long all the beers have been fermenting and how many drinks are left in each barrel. The high level overview is as follows:
Overview:
A large monitor displays the name of beers that are being brewed and how long they have been fermenting. In another column it displays the names of the beers that are done fermenting and how many pints are left in each barrel. When a new beer is to be brewed, the name and quantity of water is entered into a computer and a lever or button near the barrel is pressed after adding the ingredients. This starts the timer and causes that beer to be displayed on the "fermenting" side of the monitor. pressing the button/lever again will signify the end of the fermentation and will move the beer to the other side of the display that shows the number of beers left in the barrel. Subsequent presses of the button/lever (which will be done every time a pint of beer is extracted from the barrel) will decrement the counter for that beer down by 1 until it reaches 0 at which point it will be removed from the list.
Concepts:
The way that I intend to tackle this is to use redstone bundled cable to attach to the back of the computer. Each lever near a beer barrel will be connected to the bundle with a different colored redstone wire. The program will associate the color of wire with the name and quantity of each beer upon creation. Each pulse of that color will then update the information associated with that beer.
Potential problems: I am not sure the best way to actually track the time because all time tracking I know if is linked to world time and sleeping will throw this off. I was considering using redpower timers and counters to emit a pulse to the computer every hour to update the time on the computer because setting the timer to a couple seconds with a long counter will make any time sync problems negligible. However, this breaks the idea of using a pulse to signify the end of the brewing unless we also include how long we want to brew each beer in the creation process so that it automatically marks it as done and moves it over when that many pulses are received. However, I will have to remember to quickly tap the barrel shortly after this or the beer may over-ferment compared to what the computer thinks it is.
Questions:
1. Am I going about the basic task in a good way? Are there concepts that I just don't know about that would allow me to work this more efficiently? I would greatly appreciate a high-level critique of the concept.
2. Is using redpower counters with short timers the most effective way to minimize time divergence when trying to have the server accurately track 12 hours of real life time as opposed to world-time? Can ComputerCraft do this by itself? How do server reboots affect systems like this?
—-
Thanks for any help you could offer and I will be sure to share my code once I start–I just wanted to make sure that my conceptual overview made sense and I am not missing anything important before I begin working it out.