tommyroyall

MineX 0.1

Aug 11th, 2012
262
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 5.76 KB | None | 0 0
  1. -- MINEX
  2.  
  3. --[[
  4. SYSTEM:
  5. sys.version() - var=sys.version(). Returns the version of MineX.
  6.  
  7. AUDIO:
  8. audio.note(note) - audio.note(A#) OR audio.note(A) OR audio.note(Cb). doesn't matter about the letter being capitalized, but the flat and sharp must be correct (flat must be a lower-case b). Note listing below.
  9. audio.side(side) - audio.side(back). For if the bundled cable is on the back of the computer.
  10.  
  11. UTIL:
  12. util.sprint(text to slow print) - This just slow prints the text.
  13. util.openAll() - Opens all ports.
  14. util.ejectAll() - Ejects all disks from surrounding disk drives.
  15. util.bytecode("infile","outfile") - util.bytecode("path/to/input_file","path/to/output_file"). Turns a file into bytecode.
  16.  
  17. DRAW:
  18. draw.clear() - Clears the screen and sets the cursor to 1,1.
  19. draw.square(char,topleftx,toplefty,bottomrightx,bottomrighty) - draw.square("x",1,1,6,6). draws a square with the 1 and 1 being the x and y of the top left corner, and the 6 and 6 being the x and y of the bottom right corner.
  20. draw.dchar(char,x,y) - draw.dChar("X",1,4). Draws an X at 1,4.
  21. draw.line(char,dir,xTo,yTo,len) - draw.line("O","right",4,6,5). Draws a 5 long line, at 4,6, going to the right, with O as the character.
  22.  
  23. SOUND-CARD SETUP
  24. Order of Notes: (For sound-card setup)
  25.   List Number. color - note - clicks on noteblock to attain this.
  26.     1. white - A - 3
  27.     2. orange - A#/Bb - 4
  28.     3. magenta - B - 5
  29.     4. lightBlue - C - 6
  30.     5. yellow - C#/Db - 7
  31.     6. lime - D - 8
  32.     7. pink - D#/Eb - 9
  33.     8. gray - E - 10
  34.     9. lightGray - F - 11
  35.     10. cyan - F#/Gb - 12
  36.     11. purple - G - 13
  37.     12. blue - G#/Ab - 14
  38. ]]--
  39.  
  40.  
  41. draw={} -- Establish the function tables
  42. util={}
  43. obj={}
  44. sys={}
  45. audio={}
  46.  
  47. function sys.version()
  48.     return "0.1"
  49. end
  50.  
  51.  
  52. function draw.line(char,dir,xTo,yTo,len)
  53.  xTo=tonumber(xTo)
  54.  yTo=tonumber(yTo)
  55.   if char == nil then print("Char is nil") end
  56.   if dir == nil then print("Direction is nil") end
  57.   if xTo == nil then print("X is nil") end
  58.   if yTo == nil then print("Y is nil") end
  59.   if len == nil then print("Length is nil") end
  60.  len=len-1
  61.     for i=0,len do
  62.         term.setCursorPos(xTo,yTo)
  63.         write(tostring(char))
  64.             if dir == "down" then yTo=yTo-1 end
  65.             if dir == "up" then yTo=yTo+1 end
  66.             if dir == "right" then xTo=xTo+1 end
  67.             if dir == "left" then xTo=xTo-1 end
  68.     end
  69. end
  70.  
  71. function draw.dChar(char,x,y)
  72.   if char == nil then print("Char is nil") end
  73.   if x == nil then print("X is nil") end
  74.   if y == nil then print("Y is nil") end
  75.     term.setCursorPos(tonumber(x),tonumber(y))
  76.         write(tostring(char))
  77. end
  78.  
  79. function draw.square(char,topx,topy,botx,boty) -- square("X",1,1,6,6)
  80.     len=botx-topx
  81.         draw.line(char,"right",topx,topy,len)
  82.         draw.line(char,"left",botx,boty,len)   
  83.         draw.dChar(char,topx+len,topy)
  84.         draw.dChar(char,botx-len,boty)
  85.     hlen=boty-topy
  86.         draw.line(char,"up",topx,topy,len)
  87.         draw.line(char,"up",botx,boty-hlen,len)
  88. end
  89.  
  90. function draw.clean()
  91.     term.clear()
  92.     term.setCursorPos(1,1)
  93. end
  94.  
  95. function util.sprint(text)
  96.   textutils.slowPrint(tostring(text))
  97. end
  98.  
  99. function util.bytecode(path, outname)
  100.     -- Passing a non-string into a string excepting function is... not an expected case.
  101.     local f=fs.open(path,"r") -- Open the file to read from
  102.     local out=fs.open(outname,"wb") -- Open the file to write too
  103.     local contents=f.readAll() -- Read the file
  104.     local func=loadstring(contents) -- Loadstring the file
  105.     local outfile=string.dump(func) -- Turn it into bin
  106.     for i=1,#outfile do -- Files opened with wb are written byte by byte
  107.         out.write(outfile:byte(i)) -- And write it
  108.     end
  109. end
  110.  
  111. function util.openAll()
  112.   rednet.open("right")
  113.   rednet.open("left")
  114.   rednet.open("top")
  115.   rednet.open("back")
  116. end
  117.  
  118. function util.ejectAll()
  119.   disk.eject("right")
  120.   disk.eject("left")
  121.   disk.eject("bottom")
  122.   disk.eject("back")
  123.   disk.eject("top")
  124. end
  125.  
  126. function audio.side(side)
  127.     aSide=tostring(side)
  128. end
  129.  
  130. function audio.wipe()
  131. rs.setBundledOutput(aSide,0)
  132. end
  133.  
  134. function audio.note(note)
  135. if tostring(note)=="a" or tostring(note)=="A" then redstone.setBundledOutput(aSide, colors.white) sleep(0.5) audio.wipe() end
  136. if tostring(note)=="a#" or tostring(note)=="A#" or tostring(note)=="bb" or tostring(note)=="Bb" then redstone.setBundledOutput(aSide, colors.orange) sleep(0.5) audio.wipe() end
  137. if tostring(note)=="b" or tostring(note)=="B" then redstone.setBundledOutput(aSide, colors.magenta) sleep(0.5) audio.wipe() end
  138. if tostring(note)=="c" or tostring(note)=="C" then redstone.setBundledOutput(aSide, colors.lightBlue) sleep(0.5) audio.wipe() end
  139. if tostring(note)=="c#" or tostring(note)=="C#" or tostring(note)=="db" or tostring(note)=="Db" then redstone.setBundledOutput(aSide, colors.yellow) sleep(0.5) audio.wipe() end
  140. if tostring(note)=="d" or tostring(note)=="D" then redstone.setBundledOutput(aSide, colors.lime) sleep(0.5) audio.wipe() end
  141. if tostring(note)=="d#" or tostring(note)=="D#" or tostring(note)=="eb" or tostring(note)=="Eb" then redstone.setBundledOutput(aSide, colors.pink) sleep(0.5) audio.wipe() end
  142. if tostring(note)=="e" or tostring(note)=="E" then redstone.setBundledOutput(aSide, colors.gray) sleep(0.5) audio.wipe() end
  143. if tostring(note)=="f" or tostring(note)=="F" then redstone.setBundledOutput(aSide, colors.lightGray) sleep(0.5) audio.wipe() end
  144. if tostring(note)=="f#" or tostring(note)=="F#" or tostring(note)=="gb" or tostring(note)=="Gb" then redstone.setBundledOutput(aSide, colors.cyan) sleep(0.5) audio.wipe() end
  145. if tostring(note)=="g" or tostring(note)=="G" then redstone.setBundledOutput(aSide, colors.purple) sleep(0.5) audio.wipe() end
  146. if tostring(note)=="g#" or tostring(note)=="G#" or tostring(note)=="ab" or tostring(note)=="Ab" then redstone.setBundledOutput(aSide, colors.blue) sleep(0.5) audio.wipe() end
  147. end
  148.  
  149. -- Order of notes and sound-card setup at top of page.
Advertisement
Add Comment
Please, Sign In to add comment