lebalusch

Mnet

May 26th, 2014
404
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 3.52 KB | None | 0 0
  1. --[[    <Mnet>
  2. program:        Mnet
  3. language:       Lua - ComputerCraft
  4. Written by:     Lebalusch <May 26th, 2014>
  5.                 http://www.computercraft.info/forums2/index.php?/user/26838-lebalusch/
  6.  
  7. Contributors:   apemanzilla: advised looking at and use of some peripheral API, wired modem API code. (thank you)                
  8.  
  9.  
  10. Notes:      Small script to provide the user with a list of attached peripherals and allow easy identification of monitors on a cabled network
  11.          
  12. How To Use: Look at list provided and choose the monitor name you wish to help ID if its not on the list then its not on the network.
  13.  
  14. size:           3.52  KB
  15.  
  16. updates possible from:
  17.                         Online- http://pastebin.com/YtRRSzKP
  18.                         InGame- pastebin get YtRRSzKP Mnet
  19. ]]
  20. --[[    version 1.0.1 <major, minor, Tweak>
  21. Edits:  28/5/14 - added code to print to terminal a list of all peripherals on the network as you start program.
  22. ]]
  23. --[[    Licence: http://opensource.org/licenses/BSD-3-Clause
  24. Copyright (c) <2014>, <Lebalusch>
  25. All rights reserved.
  26.  
  27. Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
  28.  
  29. 1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
  30.  
  31. 2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.
  32.  
  33. 3. Neither the name of the copyright holder nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission.
  34.  
  35. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  36.  
  37. --ALSO--
  38. IN NO EVENT SHALL <COPYRIGHT HOLDER> BE LIABLE FOR LOSS OF DIAMONDS ,YOUR BASE GOING BOOM OR ANY OTHER MAJOR MUCK UP IN YOUR WORLD.  FEEL FREE TO CHOP IT, CHANGE IT, AND LEARN FROM IT.  BUT REMEMBER HAVE FUN AT ALL TIMES AND KEEP CODING.
  39.  
  40.  
  41. ]]
  42.  
  43. --
  44. --Program
  45. --
  46.  
  47. --ask what monitor to check
  48.  
  49. local periList = peripheral.getNames()
  50. term.clear()
  51. term.setCursorPos(1, 2)
  52. print("--Program To Check Presence of A\nNetworked Monitor.\n")
  53.  
  54. for i = 1, #periList do
  55.     print("I have a "..peripheral.getType(periList[i]).." attached as \""..periList[i].."\".")
  56. end
  57.  
  58. print (" \nWhat is the Networked monitors name?")
  59. local Mlocation = read()
  60.  
  61.  
  62. --monitor code
  63. local Nmon = peripheral.wrap(Mlocation)
  64.  
  65. Nmon.setTextScale(0.5)
  66. Nmon.setCursorPos(1,1)
  67. Nmon.clear()
  68.  
  69. Nmon.write(Mlocation)
  70. Nmon.setCursorPos(1,2)
  71. Nmon.write("Is Connected")
  72. Nmon.setCursorPos(1,3)
  73. Nmon.write("To The Network")
  74.  
  75.  
  76. --pc code
  77. term.clear()
  78. term.setCursorPos(1,2)
  79. print(Mlocation," Is Connected on Network")
  80. print("program terminated-- \n")
  81.  
  82. --end
Advertisement
Add Comment
Please, Sign In to add comment