View difference between Paste ID: 8TsdD5J4 and wwkGAXtL
SHOW: | | - or go back to the newest paste.
1-
-- This program will wait for the "player" event with my username and emit redstone to the left if the player is me.
1+
-- This program will wait for the "rednet_message" event with the set computer id and emit redstone to the left.
2
term.clear()
3
term.setCursorPos(1,1)
4-
local pd, param1 = os.pullEvent()
4+
local pd, param1, param2 = os.pullEvent()
5-
function openDoor()
5+
function cowon()
6
  rs.setOutput("left", false)
7-
  sleep(2)
7+
8
function cowoff()
9
  rs.setOutput("left", true)
10-
10+
11-
if pd == "player" and param1 == "dyl421421" then
11+
if pd == "rednet_message" and param1 == 173 and param2 == "cowon" then
12-
  print("Player Detected. Door is Open.")
12+
  print("Message received to turn on cow spawner.")
13-
  openDoor()
13+
  print("Cow spawner is on.")
14-
  print("Door Closed")
14+
  cown()
15-
  sleep(.5)
15+
elseif pd == "rednet_message" and param1 == 173 and param2 == "cowoff" then
16
  print("Message received to turn off cow spawner.")
17
  print("Cow spawner is off.")
18
  cowoff()
19
end
20
term.clear()
21
shell.run("startup")