Advertisement
jBlume

pulse?

Feb 24th, 2014
143
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 2.08 KB | None | 0 0
  1. local tArgs = {...}
  2. local tSides = rs.getSides() -- this gest a list of the sides front back left right top bottom and and puts it in a table
  3. local tSorted = {} -- this will store a list to compair against latter
  4. for i = 1,#tSides do -- this will loop ounce for eatch of items in tSides this should be 6
  5.     tSorted[tSides[i]] = "" -- use the strings from from tSdies as elemsnts in the table.
  6. end
  7. local function pulse(sSide,sColour,nRepeat) -- decalre pulse function
  8.     for i = 1,nRepeat do -- start loop it will run for the number stored in nRepeat
  9.             sleep(0.3) -- pause bstween redstone change
  10.             rs.setBundledOutput(sSide,colors[sColour]) -- turn on the color
  11.             sleep(0.3) -- pause bstween redstone change
  12.             rs.setBundledOutput(sSide,0) -- turn off the color
  13.     end
  14. end
  15. if #tArgs == 3 then -- check for three input values from user
  16.     if tSorted[tArgs[1]] then -- test if the string given by the user is a elemsnt in this table. it will be true if et exists
  17.             if colors[tArgs[2]] then -- test if it is realy a color
  18.                     local nLoop = tonumber(tArgs[3]) -- change the string to number if it cant it will be nill
  19.                     if nLoop then
  20.                             print("pulsing "..tArgs[1].." side "..tArgs[2].." "..tostring(nLoop).." times.")
  21.                             pulse(tArgs[1],tArgs[2],nLoop)
  22.                     else
  23.                             print("not a number")
  24.                             print("usage pulse <side> <color> <loops> ")
  25.                     end
  26.             else -- if not color then tell then
  27.                     print("not a color")
  28.                     print("usage pulse <side> <color> <loops> ")
  29.             end
  30.     else -- if the user given srring is not one of the sides top bottom left right front back tell them
  31.             print("not a side")
  32.             print("usage pulse <side> <color> <loops> ") -- tell the user how to use program
  33.     end
  34. else -- if not three input values then
  35.     print("usage pulse <side> <color> <loops> ") -- tell the user how to use program
  36. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement