Advertisement
jille_Jr

CC: Lua Emmy types

Nov 21st, 2020
810
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 15.17 KB | None | 0 0
  1. if string.find("ComputerCraft .*", _HOST or "") then
  2.   return
  3. end
  4.  
  5. ---Like `print`, but without trailing newline
  6. ---@vararg any
  7. ---@return nil
  8. function _G.write(...)
  9.   --ignored
  10.   return ...
  11. end
  12.  
  13. ---@class ColourAPI
  14. ---@field combine fun(colour1:integer, colour2:integer|nil, colour3:integer|nil):integer[]
  15. ---@field subtract fun(colours:integer[], colour1:integer, colour2:integer|nil, colour3:integer|nil):integer[]
  16. ---@field test fun(colours:integer[], colour:integer):boolean
  17. ---@field packRGB fun(r:number, g:number, b:number):string
  18. ---@field unpackRGB fun(rgb:string):number,number,number
  19. ---@field toBlit fun(colour:integer):string
  20. _G.colours = {
  21.   white = 1,
  22.   orange = 2,
  23.   magenta = 4,
  24.   lightBlue = 8,
  25.   yellow = 16,
  26.   lime = 32,
  27.   pink = 64,
  28.   grey = 128,
  29.   lightGrey = 256,
  30.   cyan = 512,
  31.   purple = 1024,
  32.   blue = 2048,
  33.   brown = 4096,
  34.   green = 8192,
  35.   red = 16384,
  36.   black = 32768,
  37. }
  38.  
  39. ---@class ColorAPI
  40. ---@field combine fun(color1:integer, color2:integer|nil, color3:integer|nil):integer[]
  41. ---@field subtract fun(colors:integer[], color1:integer, color2:integer|nil, color3:integer|nil):integer[]
  42. ---@field test fun(colors:integer[], color:integer):boolean
  43. ---@field packRGB fun(r:number, g:number, b:number):string
  44. ---@field unpackRGB fun(rgb:string):number,number,number
  45. ---@field toBlit fun(color:integer):string
  46. _G.colors = {
  47.   white = 1,
  48.   orange = 2,
  49.   magenta = 4,
  50.   lightBlue = 8,
  51.   yellow = 16,
  52.   lime = 32,
  53.   pink = 64,
  54.   gray = 128,
  55.   lightGray = 256,
  56.   cyan = 512,
  57.   purple = 1024,
  58.   blue = 2048,
  59.   brown = 4096,
  60.   green = 8192,
  61.   red = 16384,
  62.   black = 32768,
  63. }
  64.  
  65. ---@class Redirect
  66. ---@field write fun(text:string)
  67. ---@field scroll fun(y:integer)
  68. ---@field getCursorPos fun():integer,integer
  69. ---@field setCursorPos fun(x:integer, y:integer)
  70. ---@field getCursorBlink fun():boolean
  71. ---@field setCursorBlink fun(blink:boolean)
  72. ---@field getSize fun():integer,integer
  73. ---@field clear fun()
  74. ---@field clearLine fun()
  75. ---@field getTextColour fun():integer
  76. ---@field getTextColor fun():integer
  77. ---@field setTextColour fun(colour:integer)
  78. ---@field setTextColor fun(color:integer)
  79. ---@field getBackgroundColour fun():integer
  80. ---@field getBackgroundColor fun():integer
  81. ---@field setBackgroundColour fun(colour:integer)
  82. ---@field setBackgroundColor fun(color:integer)
  83. ---@field isColour fun():boolean
  84. ---@field isColor fun():boolean
  85. ---@field blit fun(text:string, textColour:string, backgroundColour:string)
  86. ---@field setPaletteColour fun(colour:integer, hexOrR:integer, g:integer|nil, b:integer|nil)
  87. ---@field setPaletteColor fun(color:integer, hexOrR:integer|number, g:number|nil, b:number|nil)
  88. ---@field getPaletteColour fun(colour:integer):number,number,number
  89. ---@field getPaletteColor fun(color:integer):number,number,number
  90. local _
  91.  
  92. ---@class term : Redirect
  93. ---@field write fun(text:string)
  94. ---@field scroll fun(y:integer)
  95. ---@field getCursorPos fun():integer,integer
  96. ---@field setCursorPos fun(x:integer, y:integer)
  97. ---@field getCursorBlink fun():boolean
  98. ---@field setCursorBlink fun(blink:boolean)
  99. ---@field getSize fun():integer,integer
  100. ---@field clear fun()
  101. ---@field clearLine fun()
  102. ---@field getTextColour fun():integer
  103. ---@field getTextColor fun():integer
  104. ---@field setTextColour fun(colour:integer)
  105. ---@field setTextColor fun(color:integer)
  106. ---@field getBackgroundColour fun():integer
  107. ---@field getBackgroundColor fun():integer
  108. ---@field setBackgroundColour fun(colour:integer)
  109. ---@field setBackgroundColor fun(color:integer)
  110. ---@field isColour fun():boolean
  111. ---@field isColor fun():boolean
  112. ---@field blit fun(text:string, textColour:string, backgroundColour:string)
  113. ---@field setPaletteColour fun(colour:integer, hexOrR:integer, g:integer|nil, b:integer|nil)
  114. ---@field setPaletteColor fun(color:integer, hexOrR:integer|number, g:number|nil, b:number|nil)
  115. ---@field getPaletteColour fun(colour:integer):number,number,number
  116. ---@field getPaletteColor fun(color:integer):number,number,number
  117. ---
  118. ---@field redirect fun(target:Redirect)
  119. ---@field current fun():Redirect
  120. ---@field native fun():Redirect
  121. _G.term = term
  122.  
  123. ---@class Window : Redirect
  124. ---@field write fun(text:string)
  125. ---@field scroll fun(y:integer)
  126. ---@field getCursorPos fun():integer,integer
  127. ---@field setCursorPos fun(x:integer, y:integer)
  128. ---@field getCursorBlink fun():boolean
  129. ---@field setCursorBlink fun(blink:boolean)
  130. ---@field getSize fun():integer,integer
  131. ---@field clear fun()
  132. ---@field clearLine fun()
  133. ---@field getTextColour fun():integer
  134. ---@field getTextColor fun():integer
  135. ---@field setTextColour fun(colour:integer)
  136. ---@field setTextColor fun(color:integer)
  137. ---@field getBackgroundColour fun():integer
  138. ---@field getBackgroundColor fun():integer
  139. ---@field setBackgroundColour fun(colour:integer)
  140. ---@field setBackgroundColor fun(color:integer)
  141. ---@field isColour fun():boolean
  142. ---@field isColor fun():boolean
  143. ---@field blit fun(text:string, textColour:string, backgroundColour:string)
  144. ---@field setPaletteColour fun(colour:integer, hexOrR:integer, g:integer|nil, b:integer|nil)
  145. ---@field setPaletteColor fun(color:integer, hexOrR:integer|number, g:number|nil, b:number|nil)
  146. ---@field getPaletteColour fun(colour:integer):number,number,number
  147. ---@field getPaletteColor fun(color:integer):number,number,number
  148. ---
  149. ---@field getLine fun(y:integer):string,string,string @Get the buffered contents of a line in this window
  150. ---@field setVisible fun(visible:boolean) @Set whether this window is visible. Invisible windows will not be drawn to the screen until they are made visible again. Making an invisible window visible will immediately draw it.
  151. ---@field isVisible fun():boolean @Get whether this window is visible. Invisible windows will not be drawn to the screen until they are made visible again.
  152. ---@field redraw fun() @Draw this window. This does nothing if the window is not visible.
  153. ---@field restoreCursor fun() @Set the current terminal's cursor to where this window's cursor is. This does nothing if the window is not visible.
  154. ---@field getPosition fun():integer,integer @Get the position of the top left corner of this window.
  155. ---@field reposition fun(new_x:integer, new_y:integer, new_width:integer|nil, new_height:integer|nil, new_parent:Redirect|nil) @Reposition or resize the given window.
  156. local _
  157.  
  158. ---@class window
  159. ---@field create fun(parent:Redirect, x:integer, y:integer, width:integer, height:integer, startVisible:boolean|nil):Window
  160. _G.window = window
  161.  
  162. ---@class JSONSerializeOptions
  163. ---@field nbt_style boolean
  164. ---@field parse_null boolean
  165. local _
  166.  
  167. ---@class textutils
  168. ---@field slowWrite fun(sText:string, nRate:number|nil)
  169. ---@field slowPrint fun(sText:string, nRate:number|nil)
  170. ---@field formatTime fun(nTime:integer, bTwentyFourHour:boolean):string
  171. ---@field pagedPrint fun(_sText:string, _nFreeLines:integer)
  172. ---@field tabulate fun(t1:table, t2:table|nil, t3:table|nil)
  173. ---@field pagedTabulate fun(t1:table, t2:table|nil, t3:table|nil)
  174. ---@field serialise fun(t:any):string
  175. ---@field serialize fun(t:any):string
  176. ---@field unserialise fun(s:string):any
  177. ---@field unserialize fun(s:string):any
  178. ---@field serialiseJSON fun(t:any, bNBTStyle:boolean|nil):string
  179. ---@field serializeJSON fun(t:any, bNBTStyle:boolean|nil):string
  180. ---@field unserialiseJSON fun(s:string, options:table|nil):any,nil|string
  181. ---@field unserializeJSON fun(s:string, options:table|nil):any,nil|string
  182. ---@field urlEncode fun(str:string):string
  183. ---@field complete fun(sSearchText:string, sSearchTable:table|nil):string[]
  184. _G.textutils = {
  185.   empty_json_array = {},
  186.   json_null = {},
  187. }
  188.  
  189. ---@class itemDetail
  190. ---@field name string
  191. ---@field count integer
  192. ---@field damage integer
  193. local _
  194.  
  195. ---@class itemInspected
  196. ---@field name string
  197. ---@field metadata integer
  198. ---@field state table
  199. local _
  200.  
  201. ---@class turtle
  202. ---@field forward fun():boolean
  203. ---@field back fun():boolean
  204. ---@field up fun():boolean
  205. ---@field down fun():boolean
  206. ---@field turnLeft fun():boolean
  207. ---@field turnRight fun():boolean
  208. ---@field refuel fun(itemCount:integer):boolean
  209. ---@field select fun(slot:integer|nil):integer
  210. ---@field getSelectedSlot fun()
  211. ---@field place fun():boolean
  212. ---@field placeUp fun():boolean
  213. ---@field placeDown fun():boolean
  214. ---@field dig fun():boolean
  215. ---@field digUp fun():boolean
  216. ---@field digDown fun():boolean
  217. ---@field suck fun():boolean
  218. ---@field suckUp fun():boolean
  219. ---@field suckDown fun():boolean
  220. ---@field drop fun():boolean
  221. ---@field dropUp fun():boolean
  222. ---@field dropDown fun():boolean
  223. ---@field attack fun():boolean
  224. ---@field attackUp fun():boolean
  225. ---@field attackDown fun():boolean
  226. ---@field compareTo fun(slot:integer):boolean
  227. ---@field compare fun():boolean
  228. ---@field compareUp fun():boolean
  229. ---@field compareDown fun():boolean
  230. ---@field inspect fun():boolean,itemInspected|nil
  231. ---@field inspectUp fun():boolean,itemInspected|nil
  232. ---@field inspectDown fun():boolean,itemInspected|nil
  233. ---@field detect fun():boolean
  234. ---@field detectUp fun():boolean
  235. ---@field detectDown fun():boolean
  236. ---@field transferTo fun(slot:integer)
  237. ---@field getFuelLevel fun():integer
  238. ---@field getFuelLimit fun():integer
  239. ---@field getItemCount fun(slot:integer):integer
  240. ---@field getItemDetail fun(slot:integer):itemDetail|nil
  241. ---@field getItemSpace fun(slot:integer):integer
  242. ---@field equipLeft fun(slot:integer):boolean
  243. ---@field equipRight fun(slot:integer):boolean
  244. ---@field craft fun(amount:integer|nil):boolean
  245. _G.turtle = turtle
  246.  
  247. ---@class peripheralWrapped
  248. local _
  249.  
  250. ---@class peripheral
  251. ---@field getNames fun():string[]
  252. ---@field isPresent fun(name:string):boolean
  253. ---@field getName fun(peripheral:peripheralWrapped):string
  254. ---@field getType fun(name:string)
  255. ---@field getMethods fun(name:string):string[]
  256. ---@field call fun(name:string, param1:any, param2:any, etc:any):any
  257. ---@field wrap fun(name:string):peripheralWrapped
  258. ---@field find fun(type:string, fnFilter:function|nil):peripheralWrapped
  259. _G.peripheral = peripheral
  260.  
  261. ---Monitors are a block which act as a terminal, displaying information on one side. This allows them to be read and interacted with in-world without opening a GUI.
  262. ---@class Monitor : Redirect, peripheral
  263. ---@field write fun(text:string):nil
  264. ---@field scroll fun(y:integer):nil
  265. ---@field getCursorPos fun():integer,integer
  266. ---@field setCursorPos fun(x:integer, y:integer):nil
  267. ---@field getCursorBlink fun():boolean
  268. ---@field setCursorBlink fun(blink:boolean):nil
  269. ---@field getSize fun():integer,integer
  270. ---@field clear fun():nil
  271. ---@field clearLine fun():nil
  272. ---@field getTextColour fun():integer
  273. ---@field getTextColor fun():integer
  274. ---@field setTextColour fun(colour:integer):nil
  275. ---@field setTextColor fun(color:integer):nil
  276. ---@field getBackgroundColour fun():integer
  277. ---@field getBackgroundColor fun():integer
  278. ---@field setBackgroundColour fun(colour:integer):nil
  279. ---@field setBackgroundColor fun(color:integer):nil
  280. ---@field isColour fun():boolean
  281. ---@field isColor fun():boolean
  282. ---@field blit fun(text:string, textColour:string, backgroundColour:string):nil
  283. ---@field setPaletteColour fun(colour:integer, hexOrR:integer, g:integer|nil, b:integer|nil):nil
  284. ---@field setPaletteColor fun(color:integer, hexOrR:integer|number, g:number|nil, b:number|nil):nil
  285. ---@field getPaletteColour fun(colour:integer):number,number,number
  286. ---@field getPaletteColor fun(color:integer):number,number,number
  287. ---
  288. ---@field setTextScale fun(size:number):nil
  289. local _
  290.  
  291. ---@class quarkItemMeta
  292. ---@field displayName string
  293. ---@field count integer
  294. ---@field name string
  295. ---@field rawName string
  296. ---@field maxDamage integer
  297. ---@field maxCount integer
  298. ---@field damage integer
  299. local _
  300.  
  301. ---@class quarkItemObj
  302. ---@field drop fun(limit:integer|nil, direction:string|nil):integer @Drop an item on the ground. Returns the number of items dropped
  303. ---@field getDocs fun(name:string):string|table @Get the documentation for all functions or the function specified. Errors if the function cannot be found.
  304. ---@field getMetadata fun():quarkItemMeta @Get metadata about this object
  305. local _
  306.  
  307. ---@class quarkMaterial
  308. ---@field solid boolean
  309. ---@field burns boolean
  310. ---@field blocksLight boolean
  311. ---@field liquid boolean
  312. ---@field requiresTool boolean
  313. ---@field opaque boolean
  314. ---@field blocksMovement boolean
  315. ---@field replaceable boolean
  316. local _
  317.  
  318. ---@class quarkMetadata
  319. ---@field color integer
  320. ---@field colour integer
  321. ---@field metadata integer
  322. ---@field state table
  323. ---@field translationKey string
  324. ---@field name string
  325. ---@field displayName string
  326. ---@field material quarkMaterial
  327. ---@field hardness number
  328. local _
  329.  
  330. ---@class quarkInventory : peripheralWrapped
  331. ---@field pullItems fun(fromName:string, fromSlot:integer, limit:integer|nil, toSlot:integer|nil):integer @Pull items to this inventory from another inventory. Returns the amount transferred.
  332. ---@field size fun():integer @The size of the inventory
  333. ---@field pushItems fun(toNAme:string, fromSlot:integer, limit:integer|nil, toSlot:integer|nil):integer @Push items from this inventory to another inventory. Return the amount transferred.
  334. ---@field getItemMeta fun(slot:integer):quarkItemMeta|nil @The metadata of the item in the specified slot. The slot number starts from 1.
  335. ---@field getItem fun(slot:integer):quarkItemObj|nil @The item in the specified slot. The slot number starts from 1.
  336. ---@field drop fun(slot:integer, limit:integer|nil, direction:string|nil):integer @Drop an item on the ground. Return the number of items dropped
  337. ---@field list fun():itemDetail[] @List all items in this inventory
  338. ---@field suck fun(slot:integer|nil, limit:integer|nil):integer @Suck an item from the ground
  339. ---@field getMetadata fun():table @Get metadata about this object
  340. ---@field getTransferLocations fun(location:string|nil):string[] @Get a list of all available objects which can be transferred to or from
  341. ---@field getDocs fun(name:string|nil):table<string,string>|string @Get the documentation for all functions or the function specified. Errors if the function cannot be found.
  342. local _
  343.  
  344. ---@class quarkFurnace : quarkInventory
  345. ---@field pullItems fun(fromName:string, fromSlot:integer, limit:integer|nil, toSlot:integer|nil):integer @Pull items to this inventory from another inventory. Returns the amount transferred.
  346. ---@field size fun():integer @The size of the inventory
  347. ---@field pushItems fun(toNAme:string, fromSlot:integer, limit:integer|nil, toSlot:integer|nil):integer @Push items from this inventory to another inventory. Return the amount transferred.
  348. ---@field getItemMeta fun(slot:integer):quarkItemMeta|nil @The metadata of the item in the specified slot. The slot number starts from 1.
  349. ---@field getItem fun(slot:integer):quarkItemObj|nil @The item in the specified slot. The slot number starts from 1.
  350. ---@field drop fun(slot:integer, limit:integer|nil, direction:string|nil):integer @Drop an item on the ground. Return the number of items dropped
  351. ---@field list fun():itemDetail[] @List all items in this inventory
  352. ---@field suck fun(slot:integer|nil, limit:integer|nil):integer @Suck an item from the ground
  353. ---@field getMetadata fun():table @Get metadata about this object
  354. ---@field getTransferLocations fun(location:string|nil):string[] @Get a list of all available objects which can be transferred to or from
  355. ---@field getDocs fun(name:string|nil):table<string,string>|string @Get the documentation for all functions or the function specified. Errors if the function cannot be found.
  356. ---
  357. ---@field getCookTime fun():integer @Number of ticks the current item has cooked for
  358. ---@field getBurnTime fun():integer @Number of ticks of burning the current fuel provides
  359. ---@field getRemainingBurnTime fun():integer @Number of ticks of fuel left
  360. local _
  361.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement