3 posts
                
             
            
                Posted 20 June 2012 - 02:25 AM
                Hey i know there have been plenty of topics with rednet, none seem to answer my question though. I was wondering if it is possible to run a program (say a keycard security) on one computer and enabled it to receive signals from another computer. What im trying to do is computer A is running the keycard program, to open doors if the right keycard is presented, if it receives a command signal from computer B then it powers down or prevents(in some way) the keycard from working until another command is sent to enable it again. Is this possible in any way? if so could someone help me with it, im just a little confused on how to do it.
                
             
         
        
        
            
            
                
                    
                
                134 posts
                
                    
                        Location
                        Salt Lake, UT
                    
                
             
            
                Posted 20 June 2012 - 02:55 AM
                ya. 
while true do
local event param1, param2, param3 = os.pullEvent()
if event == "rednet_message" then
if param2 == "Shutdown" then
os.shutdown()
end
elseif event == "disk" then
x = disk.getLabel
if x == "name" then
-- do whatever
else
print("wrong key card")
sleep(2)
os.shutdown()
end
end
end
 
                
             
         
        
        
            
            
                
                    
                
                3 posts
                
             
            
                Posted 20 June 2012 - 06:16 AM
                
while true do
local event param1, param2, param3 = os.pullEvent()
if event == "rednet_message" then
if param2 == "Shutdown" then
os.shutdown()
end
elseif event == "disk" then
x = disk.getLabel
if x == "name" then
redstone.setOutput("right", true)
disk.eject("left")
sleep(5)
restone.setOutput("right", false)
end
os.reboot()
end
else
disk.eject("left")
sleep(2)
os.reboot()
end
end
end
So would this code work? If i wanted to make this computer listen to commands only from one computer would i put a line in such as
if param1 == "11" then
correct?
 
                
             
         
        
        
            
            
                
                    
                
                351 posts
                
             
            
                Posted 20 June 2012 - 02:45 PM
                Yes, that is right, and I recommend doing it every time.
                
             
         
        
        
            
            
                
                    
                
                134 posts
                
                    
                        Location
                        Salt Lake, UT
                    
                
             
            
                Posted 20 June 2012 - 03:55 PM
                Now you do not have to use
local event param1, param2, param3 = os.pullEvent()
you can change "param1, param2, param3". These are the names of varriables that os.pullEvent() stores. You can make them param1, diskname, param3 =… I usually use a,b,c because it is easier but you can do whatever you want. Many people do not know that.
 
                
             
         
        
        
            
            
                
                    
                
                992 posts
                
             
            
                Posted 20 June 2012 - 05:04 PM
                there are bugs with your code tfoote here is a corrected ver.
Spoiler
rednet.open("back")
while true do
    local event, param1, param2, param3 = os.pullEvent() -- missed a ","
    if event == "rednet_message" then
	    if param2 == "shutdown" then
		    os.shutdown()
	    end
    elseif event == "disk" then
	    x = disk.getLabel(param1)
	    if x == "name" then
		    -- do whatever
		    print("user entered disk named name")
	    else
		    print("wrong key card")
		    sleep(2)
		    os.shutdown()
	    end
    end
end
 
                
             
         
        
        
            
            
                
                    
                
                134 posts
                
                    
                        Location
                        Salt Lake, UT
                    
                
             
            
                Posted 20 June 2012 - 05:07 PM
                there are bugs with your code tfoote here is a corrected ver.
Spoiler
rednet.open("back")
while true do
	local event, param1, param2, param3 = os.pullEvent() -- missed a ","
	if event == "rednet_message" then
		if param2 == "shutdown" then
			os.shutdown()
		end
	elseif event == "disk" then
		x = disk.getLabel(param1)
		if x == "name" then
			-- do whatever
			print("user entered disk named name")
		else
			print("wrong key card")
			sleep(2)
			os.shutdown()
		end
	end
end
Hey thanks!
I didn't know if I needed a "," there… I havent been on minecraft in a while