antonvrg

EC.lua

Sep 23rd, 2011
231
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 5.97 KB | None | 0 0
  1. -- Made2shred's Electronic Components
  2. -- Licensed under the MIT license: http://www.opensource.org/licenses/mit-license.php
  3.  
  4. tpt.log("Electronic Components By Made2shred")
  5.  
  6. function flipflop(x, y)
  7.     tpt.log("Drawing flipflop...")
  8.     tpt.create(x + 0, y + 0, "SWCH")
  9.     tpt.create(x + 0, y - 2, "PSCN")
  10.     tpt.create(x - 1, y - 4, "PSCN")
  11.     tpt.create(x - 3, y - 4, "PSCN")
  12.     tpt.create(x - 3, y - 2, "PSCN")
  13.     tpt.create(x + 0, y + 2, "NSCN")
  14.     tpt.create(x + 1, y + 4, "NSCN")
  15.     tpt.create(x + 3, y + 4, "NSCN")
  16.     tpt.create(x + 3, y + 2, "NSCN")
  17.     tpt.create(x - 5, y + 0, "METL")
  18.     tpt.create(x - 4, y + 0, "METL")
  19.     tpt.create(x - 3, y + 0, "METL")
  20.     tpt.create(x - 2, y + 0, "METL")
  21.     tpt.create(x + 2, y + 0, "METL")
  22.     tpt.create(x + 3, y + 0, "METL")
  23.     tpt.create(x + 4, y + 0, "METL")
  24.     tpt.create(x + 5, y + 0, "METL")
  25. end
  26.  
  27. function ORgate(x, y)
  28.     tpt.log("Drawing OR gate...")
  29.     tpt.create(x + 0, y + 1, "NSCN")
  30.     tpt.create(x + 0, y - 1, "NSCN")
  31.     tpt.create(x + 2, y + 0, "METL")
  32.     tpt.create(x + 3, y + 0, "METL")
  33.     tpt.create(x + 4, y + 0, "METL")
  34.     tpt.create(x - 2, y - 1, "PSCN")
  35.     tpt.create(x - 3, y - 1, "PSCN")
  36.     tpt.create(x - 4, y - 1, "PSCN")
  37.     tpt.create(x - 2, y - 0, "INSL")
  38.     tpt.create(x - 3, y - 0, "INSL")
  39.     tpt.create(x - 4, y - 0, "INSL")
  40.     tpt.create(x - 2, y + 1, "PSCN")
  41.     tpt.create(x - 3, y + 1, "PSCN")
  42.     tpt.create(x - 4, y + 1, "PSCN")
  43. end
  44.  
  45. function ANDgate(x, y)
  46.     tpt.log("Drawing AND gate...")
  47.     tpt.create(x - 3, y - 1, "METL")
  48.     tpt.create(x - 4, y - 1, "METL")
  49.     tpt.create(x - 5, y - 1, "METL")
  50.     tpt.create(x - 6, y - 1, "METL")
  51.     tpt.create(x - 3, y + 2, "METL")
  52.     tpt.create(x - 4, y + 2, "METL")
  53.     tpt.create(x - 5, y + 2, "METL")
  54.     tpt.create(x - 6, y + 2, "METL")
  55.     tpt.create(x - 3, y - 1, "METL")
  56.     tpt.create(x - 4, y - 1, "METL")
  57.     tpt.create(x - 5, y - 1, "METL")
  58.     tpt.create(x - 2, y - 2, "METL")
  59.     tpt.create(x - 1, y + 1, "METL")
  60.     tpt.create(x + 1, y + 1, "NTCT")
  61.     tpt.create(x + 2, y - 1, "PSCN")
  62.     tpt.create(x + 2, y + 3, "PSCN")
  63.     tpt.create(x + 4, y + 3, "METL")
  64.     tpt.create(x + 5, y + 3, "METL")
  65.     tpt.create(x + 6, y + 3, "METL")
  66.     tpt.create(x + 0, y - 3, "METL")
  67.     tpt.create(x + 2, y - 3, "METL")
  68. end
  69.  
  70. function NOTgate(x, y)
  71.     tpt.log("Drawing NOT gate...")
  72.     tpt.create(x +0, y + 0, "PTCT")
  73.     tpt.create(x - 2, y + 0, "METL")
  74.     tpt.create(x - 3, y + 0, "METL")
  75.     tpt.create(x - 4, y + 0, "METL")
  76.     tpt.create(x - 5, y + 0, "METL")
  77.     tpt.create(x + 1, y + 2, "PSCN")
  78.     tpt.create(x + 1, y - 2, "PSCN")
  79.     tpt.create(x + 1, y - 3, "BTRY")
  80.     tpt.create(x + 3, y + 2, "METL")
  81.     tpt.create(x + 3, y + 0, "METL")
  82.     tpt.create(x + 4, y + 0, "METL")
  83.     tpt.create(x + 5, y + 0, "METL")
  84.     tpt.create(x + 6, y + 0, "METL")
  85. end
  86.  
  87. function diode(x, y)
  88.     tpt.log("Drawing a Diode...")
  89.     tpt.create(x + 0, y + 0, "PSCN")
  90.     tpt.create(x - 1, y + 0, "PSCN")
  91.     tpt.create(x - 1, y + 1, "PSCN")
  92.     tpt.create(x - 1, y - 1, "PSCN")
  93.     tpt.create(x - 2, y + 0, "PSCN")
  94.     tpt.create(x - 2, y + 1, "PSCN")
  95.     tpt.create(x - 2, y - 1, "PSCN")
  96.     tpt.create(x - 2, y - 2, "PSCN")
  97.     tpt.create(x - 2, y + 2, "PSCN")
  98.     tpt.create(x - 3, y + 0, "PSCN")
  99.     tpt.create(x - 3, y + 1, "PSCN")
  100.     tpt.create(x - 3, y - 1, "PSCN")
  101.     tpt.create(x - 3, y - 2, "PSCN")
  102.     tpt.create(x - 3, y + 2, "PSCN")
  103.     tpt.create(x - 3, y + 3, "PSCN")
  104.     tpt.create(x - 3, y - 3, "PSCN")
  105.     tpt.create(x - 4, y + 0, "PSCN")
  106.     tpt.create(x - 5, y + 0, "PSCN")
  107.     tpt.create(x + 1, y + 0, "NSCN")
  108.     tpt.create(x + 1, y + 1, "NSCN")
  109.     tpt.create(x + 1, y + 2, "NSCN")
  110.     tpt.create(x + 1, y + 3, "NSCN")
  111.     tpt.create(x + 1, y - 1, "NSCN")
  112.     tpt.create(x + 1, y - 2, "NSCN")
  113.     tpt.create(x + 1, y - 3, "NSCN")
  114.     tpt.create(x + 2, y + 0, "NSCN")
  115.     tpt.create(x + 3, y + 0, "NSCN")
  116.     tpt.create(x + 4, y + 0, "NSCN")
  117.     tpt.create(x - 6, y + 0, "METL")
  118.     tpt.create(x - 7, y + 0, "METL")
  119.     tpt.create(x - 8, y + 0, "METL")
  120.     tpt.create(x - 9, y + 0, "METL")
  121.     tpt.create(x - 10, y + 0, "METL")
  122.     tpt.create(x - 11, y + 0, "METL")
  123.     tpt.create(x - 12, y + 0, "METL")
  124.     tpt.create(x + 5, y + 0, "METL")
  125.     tpt.create(x + 6, y + 0, "METL")
  126.     tpt.create(x + 7, y + 0, "METL")
  127.     tpt.create(x + 8, y + 0, "METL")
  128.     tpt.create(x + 9, y + 0, "METL")
  129.     tpt.create(x + 10, y + 0, "METL")
  130.     tpt.create(x + 11, y + 0, "METL")
  131. end
  132.  
  133. function diode2(x, y)
  134.     tpt.log("Drawing a Diode...")
  135.     tpt.create(x + 0, y - 1, "PSCN")
  136.     tpt.create(x + 0, y + 0, "PSCN")
  137.     tpt.create(x + 0, y + 1, "PSCN")
  138.     tpt.create(x - 1, y - 1, "PSCN")
  139.     tpt.create(x - 1, y + 0, "PSCN")
  140.     tpt.create(x - 1, y + 1, "PSCN")
  141.     tpt.create(x - 2, y - 1, "PSCN")
  142.     tpt.create(x - 2, y + 0, "PSCN")
  143.     tpt.create(x - 2, y + 1, "PSCN")
  144.     tpt.create(x - 3, y - 1, "PSCN")
  145.     tpt.create(x - 3, y + 0, "PSCN")
  146.     tpt.create(x - 3, y + 1, "PSCN")
  147.     tpt.create(x - 4, y - 1, "PSCN")
  148.     tpt.create(x - 4, y + 0, "PSCN")
  149.     tpt.create(x - 4, y + 1, "PSCN")
  150.     tpt.create(x + 1, y - 1, "NSCN")
  151.     tpt.create(x + 1, y + 0, "NSCN")
  152.     tpt.create(x + 1, y + 1, "NSCN")
  153.     tpt.create(x + 2, y - 1, "NSCN")
  154.     tpt.create(x + 2, y + 0, "NSCN")
  155.     tpt.create(x + 2, y + 1, "NSCN")
  156.     tpt.create(x - 4, y + 0, "METL")
  157.     tpt.create(x - 5, y + 0, "METL")
  158.     tpt.create(x - 6, y + 0, "METL")
  159.     tpt.create(x - 7, y + 0, "METL")
  160.     tpt.create(x - 8, y + 0, "METL")
  161.     tpt.create(x - 9, y + 0, "METL")
  162.     tpt.create(x - 10, y + 0, "METL")
  163.     tpt.create(x - 11, y + 0, "METL")
  164.     tpt.create(x - 12, y + 0, "METL")
  165.     tpt.create(x + 3, y + 0, "METL")
  166.     tpt.create(x + 4, y + 0, "METL")
  167.     tpt.create(x + 5, y + 0, "METL")
  168.     tpt.create(x + 6, y + 0, "METL")
  169.     tpt.create(x + 7, y + 0, "METL")
  170.     tpt.create(x + 8, y + 0, "METL")
  171.     tpt.create(x + 9, y + 0, "METL")
  172.     tpt.create(x + 10, y + 0, "METL")
  173. end
  174.  
  175. function smalldiode(x, y)
  176.     tpt.log("Drawing Diode...")
  177.     tpt.create(x + 0, y + 0, "PSCN")
  178.     tpt.create(x - 1, y + 0, "PSCN")
  179.     tpt.create(x - 2, y + 0, "PSCN")
  180.     tpt.create(x + 1, y + 0, "NSCN")
  181.     tpt.create(x + 2, y + 0, "NSCN")
  182. end
  183.  
  184. function ALL(x, y)
  185.     flipflop(x +0, y + 0)
  186.     ORgate(x + 20, y + 0)
  187.     ANDgate(x + 38, y + 0)
  188.     NOTgate(x + 59, y + 0)
  189.     diode(x +88, y + 0)
  190.     diode2(x + 120, y + 0)
  191.     smalldiode(x + 140, y + 0)
  192.     tpt.log("Drawing Everything...")
  193. end
Advertisement
Add Comment
Please, Sign In to add comment