 
                
                19 posts
                
             
            
                Posted 20 April 2015 - 08:44 PM
                Hey i was writing an OS and i wanted to detect an user input (the password)
and in the meanwhile i wanted to detect for an Event ("mouse_click")
so maybe you guys could help me …
                
             
         
        
        
            
            
                
                     
                
                2427 posts
                
                    
                        Location
                        UK
                    
                
             
            
                Posted 20 April 2015 - 10:21 PM
                you will want an event loop
while true do
  e, info[1],info[2],info[3] = os.pullEven()
  if e == "mouse_click" then
	mouseClickFunc(info)
  elseif e== "char" then --#this event name may be wrong
	inputfunc(info)
  end
end
if you want to use read then you will need to use the 
parallel APIEdited on 20 April 2015 - 08:23 PM
                
             
         
        
        
            
            
                
                     
                
                2679 posts
                
                    
                        Location
                        You will never find me, muhahahahahaha
                    
                
             
            
                Posted 20 April 2015 - 10:29 PM
                you will want an event loop
while true do
  e, info[1],info[2],info[3] = os.pullEven()
  if e == "mouse_click" then
	mouseClickFunc(info)
  elseif e== "char" or e == "key" then --#this event name may be wrong
	inputfunc(info)
  end
end
if you want to use read then you will need to use the 
parallel API
I adder or e == "key" since it is also used by read. What you could do is take the read function from the bios.lua and doing this:
while true do
  event = {os.pullEven()}
  if event[1] == "mouse_click" then
	mouseClickFunc(info)
  else
   put the internal part of the read function, that is to say everything inside while true do loop
  end
end
Edited on 20 April 2015 - 08:29 PM
                
             
         
        
        
            
            
                
                     
                
                19 posts
                
             
            
                Posted 21 April 2015 - 03:41 PM
                This works great but i actually wanna determine where they need to click, because now you could click everywhere and it would work,i would also like to determine a certain string for the input
No need for that anymore i found out already