 
                
                4 posts
                
             
            
                Posted 15 March 2012 - 06:37 PM
                Ok so I tried doing a cobblestone miner with powercraft's miner. I used a timer so it can mine. I hooked it up to the computer and I tried doing a counter that increases by 1 when it receives a pulse from the bottom. It works until it gives me this error "mine:13: attempt to perform arithmetic __add on nil and number." I'm stuck on there. If you can help me it would be appreciated. :D/>/> Oh and the code is here:
http://pastebin.com/raw.php?i=KxjzmbdL 
         
        
        
            
            
                
                     
                
                1604 posts
                
             
            
                Posted 15 March 2012 - 07:30 PM
                You haven't defined the variable attempt, so it's nil.
Define it first with a start value:
local attempt = 0
I made a few modifications so it works as you want:
term.clear()
term.setCursorPos(1,1)
local pass = "cobblestone"
write("Enter Password: ")
local input = read()
if input == pass then
	write("Correct. Mining Cobblestone...")
	redstone.setOutput("left", true)
	local attempt = 0
	while true do
		if redstone.getInput("bottom") then
			attempt = attempt + 1
			print(attempt)
			sleep(1) -- change to the pulse duration
		else
			sleep(0.1) -- don't let the os end the program
		end
end
You should add a condition to break the loop, so the program finishes.
 
         
        
        
            
            
                
                     
                
                4 posts
                
             
            
                Posted 15 March 2012 - 07:37 PM
                Wow it works! Thanks. I'm a noob when it comes to lua lol