Guest User

Untitled

a guest
Sep 1st, 2018
90
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 12.98 KB | None | 0 0
  1.  
  2. os.loadAPI("sha256")
  3. os.loadAPI("json")
  4. local horline = [[+-------------------------------------+]]
  5.  
  6. local vertline = [[| |]]
  7. interface = peripheral.wrap("front")
  8. returnedItemCount = nil
  9. CC = "indbuildcraft:ibcItemCoinCopper"
  10. IC = "IC2:itemCoin"
  11. GC = "indbuildcraft:ibcItemCoinGold"
  12. DC = "indbuildcraft:ibcItemCoinDiamond"
  13. ANY = ""
  14. xddd = nil
  15.  
  16. --GC = "minecraft:iron_ingot"
  17.  
  18. cipa = 1
  19. --while true do
  20. --shell.run("rename startup pizda")
  21. --sleep(1)
  22. --end
  23. --print(GC)
  24.  
  25. function isCoin(slot,typ)
  26. local item = turtle.getItemDetail(slot)
  27. if item == nil then
  28. xddd = false
  29. elseif typ == "ANY" then
  30. xddd = item.name == item.name
  31. else
  32. xddd = item.name == typ
  33. end
  34. return xddd
  35. end
  36.  
  37. function getCount(slot)
  38. local item = turtle.getItemDetail(slot)
  39. if not item then
  40. return false
  41. end
  42. return item.count
  43. end
  44.  
  45. function clear()
  46. shell.run("clear")
  47. end
  48.  
  49. clear()
  50.  
  51. function drawMenu()
  52. clear()
  53. print(horline)
  54. for i = 0, 9 do
  55. print(vertline)
  56. end
  57. print(horline)
  58. end
  59.  
  60. function centerPrint(y, tekst)
  61. term.setCursorPos((39 / 2) - (string.len(tekst) / 2), y)
  62. term.write(tekst)
  63. end
  64.  
  65. function printOption(y, tekst, numer)
  66. term.setCursorPos((39 / 2) - 14, y)
  67. term.write(numer .. "> ")
  68. centerPrint(y, tekst)
  69. end
  70.  
  71. function getInput(tekst)
  72. term.setCursorPos(1, 13)
  73. term.write(tekst)
  74. term.setCursorPos(string.len(tekst) + 1, 13)
  75. local textinput = read()
  76. return textinput
  77. end
  78. function getInputPass(tekst)
  79. term.setCursorPos(1, 13)
  80. term.write(tekst)
  81. term.setCursorPos(string.len(tekst) + 1, 13)
  82. local textinput = read("*")
  83. return textinput
  84. end
  85.  
  86. function buy(ilosc,typ)
  87. if tonumber(ilosc) == nil then
  88. print("ty kurwa wpisz normalna liczbe pacanie")
  89. sleep(2)
  90. os.reboot() --wypierdola biosa to reboot
  91. end
  92. if not isCoin(1,typ) then
  93. if typ==CC then
  94. return "Wloz " .. ilosc .. "CC lub ctrl+r aby wyjsc"
  95. elseif typ==IC then
  96. return "Wloz " .. ilosc .. "IC lub ctrl+r aby wyjsc"
  97. elseif typ==GC then
  98. return "Wloz " .. ilosc .. "GC lub ctrl+r aby wyjsc"
  99. elseif typ==DC then
  100. return "Wloz " .. ilosc .. "DC"
  101. elseif typ=="ANY" then
  102. return "Dowolny item lub ctrl+r aby wyjsc"
  103. end
  104. end
  105. if typ ~= "ANY" then
  106. if getCount(1) < ilosc then
  107. return "Za malo"
  108. end
  109. else
  110. turtle.drop(64)
  111. end
  112. turtle.drop(ilosc)
  113.  
  114. return true;
  115. end
  116.  
  117. function kupShop(ilosc,typ,username)
  118. while true do
  119. clear()
  120. local val = buy(ilosc,typ)
  121. if val == true then
  122. drawMenu()
  123. centerPrint(5,"Zakup udany!")
  124. sleep(1.5)
  125. break
  126. end
  127.  
  128.  
  129. drawMenu()
  130. centerPrint(5,val)
  131. sleep(0.5)
  132. end
  133. end
  134.  
  135. function kup(ilosc,typ)
  136. while true do
  137. clear()
  138. local val = buy(ilosc,typ)
  139. if val == true then
  140. drawMenu()
  141. centerPrint(5,"Zakup udany!")
  142. sleep(3)
  143. os.reboot()
  144. end
  145. drawMenu()
  146. centerPrint(5,val)
  147. sleep(0.5)
  148. end
  149. end
  150.  
  151. function rejestracja()
  152. drawMenu()
  153. centerPrint(5,"REJESTRACJA")
  154. username = getInput("Podaj nick: ")
  155. username = string.gsub(username," ", "")
  156. -- username = read()
  157. clear()
  158. drawMenu()
  159. centerPrint(5,"REJESTRACJA")
  160. password = getInputPass("Podaj haslo: ")
  161. password = string.gsub(password," ", "")
  162. if http.get("http://nightgang.pw/cc/register.php?username="..username.."&password="..sha256.sha256(password)).readAll() == "true" then
  163. centerPrint(5,"Rejestracja powiodla sie!")
  164. sleep(1)
  165. main()
  166. else
  167. -- centerPrint(5,"Rejestracja nie powiodla sie!")
  168. centerPrint(5,"Blad polaczenia z serwerem lub")
  169. centerPrint(6," konto juz istnieje ")
  170. sleep(3)
  171. main()
  172. end
  173. end
  174. function logowanie()
  175. drawMenu()
  176. centerPrint(5,"LOGOWANIE")
  177. username = getInput("Podaj nick: ")
  178. username = string.gsub(username," ", "")
  179. -- username = read()
  180. clear()
  181. drawMenu()
  182. centerPrint(5,"LOGOWANIE")
  183. password = getInputPass("Podaj haslo: ")
  184. password = string.gsub(password," ", "")
  185. if http.get("http://nightgang.pw/cc/loginx.php?username="..username.."&password="..sha256.sha256(password)).readAll() == "true" then
  186. centerPrint(5,"Logowanie powiodlo sie!")
  187. loggedMenu(username)
  188. else
  189. -- centerPrint(5,"Rejestracja nie powiodla sie!")
  190. centerPrint(5,"Blad polaczenia z serwerem lub")
  191. centerPrint(6," podano bledne dane ")
  192. sleep(3)
  193. main()
  194. end
  195. end
  196.  
  197. function loggedMenu(username)
  198. sleep(1)
  199. drawMenu()
  200. printOption(5,"Sprawdz IC",1)
  201. printOption(6,"Kup przedmioty",2)
  202. printOption(7,"Wyloguj sie",3)
  203. local wyborx = getInput("Twoj wybor: ")
  204. if wyborx == "1" then
  205. drawMenu()
  206. centerPrint(5,"Twoje IC: ")
  207. centerPrint(6,json.decode(http.get("http://indbuildcraft.pl/tech/p/api/minecraft_bank_balance&lite=1&username="..username).readAll()).minecraft_bank_balance)
  208. sleep(3)
  209. loggedMenu(username)
  210. elseif wyborx == "2" then
  211. drawBuyerMenu(username)
  212. elseif wyborx == "3" then
  213. os.reboot()
  214. else
  215. loggedMenu(username)
  216. end
  217. end
  218.  
  219. function drawBuyerMenu(username)
  220. drawMenu()
  221. term.setCursorPos(3,2)
  222. print("1> Rubber: 1 CC za 64 szt | "..getItemCountInAE("IC2:itemRubber","0"))
  223. term.setCursorPos(3,3)
  224. print("2> Steel: 2 IC za 5 szt | "..getItemCountInAE("Railcraft:ingot","0"))
  225. term.setCursorPos(3,4)
  226. print("3> Iron: 1 IC za 32 szt | "..getItemCountInAE("minecraft:iron_ingot","0"))
  227. term.setCursorPos(3,5)
  228. print("4> Diamond: 1 IC za 16 szt | "..getItemCountInAE("minecraft:diamond","0"))
  229. term.setCursorPos(3,6)
  230. print("5> Emerald: 1 IC za 2 szt | "..getItemCountInAE("minecraft:emerald","0"))
  231. term.setCursorPos(3,7)
  232. print("6> W_Hex: 1 IC za 16 szt | "..getItemCountInAE("hexcraft:itemHexoriumCrystalWhite","0"))
  233. term.setCursorPos(3,8)
  234. print("7> Wyloguj sie")
  235. term.setCursorPos(3,10)
  236. print("W_Hex = White Hexorium")
  237. local wyborkupna = getInput("Twoj wybor: ")
  238. if wyborkupna == "1" then
  239. if getItemCountInAE("IC2:itemRubber","0") >= 64 then
  240. wyborkupna = 0
  241. kupShop(1,CC,username)
  242. interface.exportItem({id="IC2:itemRubber"},"east",64)
  243. drawBuyerMenu(username)
  244. elseif getItemCountInAE("IC2:itemRubber","0") == nil then
  245. drawMenu()
  246. centerPrint(5,"Zbyt malo itemow aby zakupic")
  247. sleep(2)
  248. drawBuyerMenu(username)
  249. else
  250. drawMenu()
  251. centerPrint(5,"Zbyt malo itemow aby zakupic")
  252. sleep(2)
  253. drawBuyerMenu(username)
  254. end
  255. elseif wyborkupna == "2" then
  256. if getItemCountInAE("Railcraft:ingot","0") >= 5 then
  257. wyborkupna = 0
  258. kupShop(2,IC,username)
  259. interface.exportItem({id="Railcraft:ingot"},"east",5)
  260. drawBuyerMenu(username)
  261. elseif getItemCountInAE("Railcraft:ingot","0") == nil then
  262. drawMenu()
  263. centerPrint(5,"Zbyt malo itemow aby zakupic")
  264. sleep(2)
  265. drawBuyerMenu(username)
  266. else
  267. drawMenu()
  268. centerPrint(5,"Zbyt malo itemow aby zakupic")
  269. sleep(2)
  270. drawBuyerMenu(username)
  271. end
  272. elseif wyborkupna == "3" then
  273. if getItemCountInAE("minecraft:iron_ingot","0") >= 32 then
  274. wyborkupna = 0
  275. kupShop(1,IC,username)
  276. interface.exportItem({id="minecraft:iron_ingot"},"east",32)
  277. drawBuyerMenu(username)
  278. elseif getItemCountInAE("minecraft:iron_ingot","0") == nil then
  279. drawMenu()
  280. centerPrint(5,"Zbyt malo itemow aby zakupic")
  281. sleep(2)
  282. drawBuyerMenu(username)
  283. else
  284. drawMenu()
  285. centerPrint(5,"Zbyt malo itemow aby zakupic")
  286. sleep(2)
  287. drawBuyerMenu(username)
  288. end
  289. elseif wyborkupna == "4" then
  290. if getItemCountInAE("minecraft:diamond","0") >= 16 then
  291. wyborkupna = 0
  292. kupShop(1,IC,username)
  293. interface.exportItem({id="minecraft:diamond"},"east",16)
  294. drawBuyerMenu(username)
  295. elseif getItemCountInAE("minecraft:diamond","0") == nil then
  296. drawMenu()
  297. centerPrint(5,"Zbyt malo itemow aby zakupic")
  298. sleep(2)
  299. drawBuyerMenu(username)
  300. else
  301. drawMenu()
  302. centerPrint(5,"Zbyt malo itemow aby zakupic")
  303. sleep(2)
  304. drawBuyerMenu(username)
  305. end
  306. elseif wyborkupna == "5" then
  307. if getItemCountInAE("minecraft:emerald","0") >= 2 then
  308. wyborkupna = 0
  309. kupShop(1,IC,username)
  310. interface.exportItem({id="minecraft:emerald"},"east",2)
  311. drawBuyerMenu(username)
  312. elseif getItemCountInAE("minecraft:emerald","0") == nil then
  313. drawMenu()
  314. centerPrint(5,"Zbyt malo itemow aby zakupic")
  315. sleep(2)
  316. drawBuyerMenu(username)
  317. else
  318. drawMenu()
  319. centerPrint(5,"Zbyt malo itemow aby zakupic")
  320. sleep(2)
  321. drawBuyerMenu(username)
  322. end
  323. elseif wyborkupna == "7" then
  324. os.reboot()
  325. elseif wyborkupna == "6" then
  326. if getItemCountInAE("hexcraft:itemHexoriumCrystalWhite","0") >= 16 then
  327. wyborkupna = 0
  328. kupShop(1,IC,username)
  329. interface.exportItem({id="hexcraft:itemHexoriumCrystalWhite"},"east",16)
  330. drawBuyerMenu(username)
  331. elseif getItemCountInAE("hexcraft:itemHexoriumCrystalWhite","0") == nil then
  332. drawMenu()
  333. centerPrint(5,"Zbyt malo itemow aby zakupic")
  334. sleep(2)
  335. drawBuyerMenu(username)
  336. else
  337. drawMenu()
  338. centerPrint(5,"Zbyt malo itemow aby zakupic")
  339. sleep(2)
  340. drawBuyerMenu(username)
  341. end
  342. else
  343. drawBuyerMenu(username)
  344. end
  345.  
  346. end
  347.  
  348. function getItemCountInAE(itemid,dmg)
  349. returnedItemCount = 0
  350. itemList = interface.getAvailableItems()
  351. for k,v in pairs(itemList) do
  352. if v.fingerprint.id == itemid then
  353. if v.fingerprint.dmg == tonumber(dmg) then
  354. returnedItemCount = v.size
  355. end
  356. end
  357. end
  358. if returnedItemCount == nil then
  359. returnedItemCount = 0
  360. end
  361. return returnedItemCount
  362. end
  363.  
  364. function dotacja()
  365. drawMenu()
  366. printOption(5,"CC",1)
  367. printOption(6,"IC",2)
  368. printOption(7,"GC",3)
  369. printOption(8,"DC",4)
  370. printOption(9,"Dowolny przedmiot",5)
  371. local wybor = getInput("Twoj wybor: ")
  372. if wybor == "1" then
  373. drawMenu()
  374. centerPrint(5,"Podaj ilosc CC")
  375. local cc = getInput("Ilosc: ")
  376. kup(tonumber(cc),CC)
  377. elseif wybor == "2" then
  378. drawMenu()
  379. centerPrint(5,"Podaj ilosc IC")
  380. local ic = getInput("Ilosc: ")
  381. kup(tonumber(ic),IC)
  382. elseif wybor == "3" then
  383. drawMenu()
  384. centerPrint(5,"Podaj ilosc GC")
  385. local gc = getInput("Ilosc: ")
  386. kup(tonumber(gc),GC)
  387. elseif wybor == "4" then
  388. drawMenu()
  389. centerPrint(5,"Podaj ilosc DC")
  390. local dc = getInput("Ilosc: ")
  391. kup(tonumber(dc),DC)
  392. elseif wybor == "5" then
  393. kup(1,"ANY")
  394. else
  395. dotacja()
  396. end
  397. end
  398.  
  399.  
  400. function urlencode(str)
  401. if (str) then
  402. str = string.gsub(str, "\n", "\r\n")
  403. str =
  404. string.gsub(
  405. str,
  406. "([^%w ])",
  407. function(c)
  408. return string.format("%%%02X", string.byte(c))
  409. end
  410. )
  411. str = string.gsub(str, " ", "%%20")
  412. end
  413. return str
  414. end
  415.  
  416. function forward(ilosc)
  417. end
  418.  
  419. --clear()
  420. --drawMenu()
  421. --centerPrint(5, "nudzi ci sie nereq?")
  422. --sleep(233)
  423.  
  424. --clear()
  425. --if not http.get("http://nightgang.pw:3000/ping") then
  426. -- drawMenu()
  427. -- centerPrint(5, "Nie udalo sie polaczyc z serwerem")
  428. -- sleep(5)
  429. -- os.reboot()
  430. --end
  431. --centerPrint(5, )
  432. --sleep(10)
Add Comment
Please, Sign In to add comment