I've been attempting to rebuild my old design for a vending machine payment circuit with little success. Essentially, I am looking for a circuit that locks a hopper until the required number of items are inserted and then releases that same number of items, however, my major catch is that I want the number of required items to be easily reprogrammed(doesn't require additional redstone to reprogram), and unrestricted(i.e. there are no specific number of items that don't work except a maximum, the bigger the max, the better.). I've formerly built such a design utilizing etho's hopper clock as the programmable part of the circuit but I lost the world, and have had little success in reproducing the circuit. I'd love to see someone make it tilable, however, this isn't a requirement, as my design was not tilable so I'm not sure if such a thing is possible. I apologize in advance to anyone severely frustrated by my restrictions, and will be eternally grateful if someone manages to end my frustration.
I've seen several attempts at something like this, but don't recall a fully sucessful implementation.
Starting with some theory:
On the front end one would need an item filter so only the currency_item (eg. emeralds) was accepted.
Once past the filter, the currency would need to run through a container (probably just another hopper) that used a comparator to generate pulses that were then counted.
The simplest counter I can think of is a ring of hoppers all of which are unlocked just long enough to move one (1) item with each pulse; the hopper with the counter item in it would then correspond to the number of currency_items that had passed through the system.
(Some sort of reset circuit would be needed to force the counter back to its initial (ie. count=zero) position.)
It might be easiest if the timings were arranged so that the counter could reliably lock the output from the item filter before the price+1 currency_item was released...this probably means slowing the input to the counter from the item filter.
Dispensing the right number of items would then be a simple flush of the holding container below the counter...
This is going to be big, it is going to be resource intensive, and I dont see how it could be made tileable. (Also, I can't see an easy way to change the price without at least a trivail amount of manual modification to the redstone — most likely moving the sensor in the counter... [possibly iteratively flicking a lever to move a piston tape might work???])
Hopefully someone can see solutions to some of the issues remaining or alternate methods of accomplishing the various parts...
Rollback Post to RevisionRollBack
WARNING: I have an extemely "grindy" playstyle; YMMV — if this doesn't seem fun to you, mine what you can from it & bin the rest.
Alright, I'm not sure why I suddenly got this to work, or why I have lost days to such a simple circuit, but since it does work, I figured I'd post some screenshots of the circuit for others to use, and thank ScotsMiser for his input.( Thanks ScotsMiser!! :] )
The number of items in the hopper clock is equal to the number that will be released when the circuit is activated and can be changed to your desired number. The button is where you send your input to activate the circuit, but as you can probably tell, I'm using a comparator to activate it.
If you're using a comparator to activate the circuit like in the screenshot then there is a number of buffer items required in the hopper line. To determine the number of buffer items necessary for your set up, just subtract the number released from the total number of items a hopper can hold (320 - release# = buffer). Nonstackables can be used in place of full stacks in the buffer. If an excessive number of items are inputted, the circuit may activate multiple times. To remedy this simply lock the hopper line until your mechanism has completed its process.
If anyone wants to ask me questions, or would like to compact this grotesque monstrosity, please do! I will periodically check this thread to answer questions, and gleefully await any attempt at compacting.