lego11

VERSAMENTO MINERALI 1.19ù

May 27th, 2024 (edited)
66
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 11.36 KB | None | 0 0
  1. --Versamenti MINERALI 1.19
  2. local maxw, maxh = term.getSize()
  3.  
  4. --vuota il bancomat
  5. ben = peripheral.wrap("back")
  6. j=ben.getBlockData()
  7.  
  8. copper = 0
  9. gold = 0
  10. iron = 0
  11. diamond = 0
  12. emerald = 0
  13. steel = 0
  14. glowstone = 0
  15. silver = 0
  16. bronze = 0
  17. lead = 0
  18. invar = 0
  19. electrum = 0
  20. nickel = 0
  21. coal = 0
  22. coal_coke = 0
  23. osmium = 0
  24. salt = 0
  25.  
  26. for k,v in pairs(j.Items) do
  27. if v.id == "minecraft:copper_ingot" then
  28. copper = copper + v.Count
  29. elseif v.id == "minecraft:gold_ingot" then
  30. gold = gold + v.Count
  31. elseif v.id == "minecraft:iron_ingot" then
  32. iron = iron + v.Count
  33. elseif v.id == "minecraft:diamond" then
  34. diamond = diamond + v.Count
  35. elseif v.id == "minecraft:emerald" then
  36. emerald = emerald + v.Count
  37. elseif v.id == "immersiveengineering:ingot_steel" then
  38. steel = steel + v.Count
  39. elseif v.id == "railcraft:steel_ingot" then
  40. steel = steel + v.Count
  41. elseif v.id == "mekanism:ingot_steel" then
  42. steel = steel + v.Count
  43. elseif v.id == "minecraft:glowstone_dust" then
  44. glowstone = glowstone + v.Count
  45. elseif v.id == "ic2:ingot_silver" then
  46. silver = silver + v.Count
  47. elseif v.id == "thermal:ingot_silver" then
  48. silver = silver + v.Count
  49. end
  50. sleep(0.1)
  51. end
  52.  
  53. function clear()
  54. term.clear()
  55. term.setCursorPos(1,1)
  56. end
  57.  
  58.  
  59. if copper ~= 0 or gold ~= 0 or iron ~= 0 or diamond ~= 0 or emerald ~= 0 or steel ~= 0 or glowstone ~= 0 or silver ~= 0 or bronze ~= 0 or lead ~= 0 or invar ~= 0 or electrum ~= 0 or nickel ~= 0 or coal ~= 0 or coal_coke ~= 0 or osmium ~= 0 or salt ~= 0 then
  60. clear()
  61. print("Bancomat temporaneamente non disponibile, per favore attendere")
  62. rs.setOutput("left", true)
  63. for i=1,5 do
  64. term.setCursorPos(3, 3)
  65. term.write("*---")
  66. sleep(0.5)
  67. term.setCursorPos(3, 3)
  68. term.write("-*--")
  69. sleep(0.5)
  70. term.setCursorPos(3, 3)
  71. term.write("--*-")
  72. sleep(0.5)
  73. term.setCursorPos(3, 3)
  74. term.write("---*")
  75. sleep(0.5)
  76. end
  77. rs.setOutput("left", false)
  78. os.reboot()
  79. end
  80.  
  81. function clear()
  82. term.clear()
  83. term.setCursorPos(1, 1)
  84. end
  85.  
  86. function clearRed()
  87. sfondo(colors.red)
  88. term.clear()
  89. term.setCursorPos(1, 1)
  90. end
  91.  
  92. function colore(sfumatura) term.setTextColour(sfumatura) end
  93.  
  94. function sfondo(sfumaturaSfondo) term.setBackgroundColour(sfumaturaSfondo) end
  95.  
  96. function fineColore() term.setTextColour(colours.white) end
  97.  
  98. function fineSfondo() term.setBackgroundColour(colours.black) end
  99.  
  100.  
  101. -- IMPLEMENTAZIONE DEL DRAWFILLEDBOX
  102. local function drawPixelInternal(xPos, yPos)
  103. term.setCursorPos(xPos, yPos)
  104. term.write(" ")
  105. end
  106.  
  107. local tColourLookup = {}
  108. for n = 1, 16 do
  109. tColourLookup[string.byte("0123456789abcdef", n, n)] = 2 ^ (n - 1)
  110. end
  111.  
  112. function drawFilledBox(startX, startY, endX, endY, nColour)
  113. if type(startX) ~= "number" or type(startX) ~= "number" or type(endX) ~=
  114. "number" or type(endY) ~= "number" or
  115. (nColour ~= nil and type(nColour) ~= "number") then
  116. error("Expected startX, startY, endX, endY, colour", 2)
  117. end
  118.  
  119. startX = math.floor(startX)
  120. startY = math.floor(startY)
  121. endX = math.floor(endX)
  122. endY = math.floor(endY)
  123.  
  124. if nColour then term.setBackgroundColor(nColour) end
  125. if startX == endX and startY == endY then
  126. drawPixelInternal(startX, startY)
  127. return
  128. end
  129.  
  130. local minX = math.min(startX, endX)
  131. if minX == startX then
  132. minY = startY
  133. maxX = endX
  134. maxY = endY
  135. else
  136. minY = endY
  137. maxX = startX
  138. maxY = startY
  139. end
  140.  
  141. for x = minX, maxX do for y = minY, maxY do drawPixelInternal(x, y) end end
  142. end
  143.  
  144.  
  145. function titolo(testo)
  146. drawFilledBox(1, 1, maxw, 1, colors.yellow)
  147. term.setCursorPos((maxw - #testo) / 2, 1)
  148. colore(colors.black)
  149. term.write(testo)
  150. sfondo(colors.blue)
  151. end
  152.  
  153. function errore(errore)
  154. sfondo(colors.red)
  155. colore(colors.white)
  156. term.clear()
  157. term.setCursorPos(1, 1)
  158. titolo("Errore irreversibile")
  159. term.setCursorPos(1, 3)
  160. sfondo(colors.red)
  161. colore(colors.white)
  162. print(errore)
  163. print("\n\n\nAttendere qualche secondo...")
  164. os.sleep(5)
  165. os.reboot()
  166. end
  167.  
  168. sfondo(colours.blue)
  169. clear()
  170. titolo("Autorità Portuale di New Radeon")
  171. sfondo(colours.blue)
  172. colore(colors.white)
  173. print("\n\nVendita Minerali")
  174. print("")
  175. print("Premere un tasto per iniziare l'operazione")
  176. event = os.pullEvent()
  177.  
  178. sfondo(colours.blue)
  179. term.clear()
  180. term.setCursorPos(1, 1)
  181. titolo("Accredita su Nebraska Pay")
  182. sfondo(colours.blue)
  183. colore(colors.white)
  184. print(
  185. "\n\nInserire i propri dati. Premere Enter per confermare i dati inseriti. \nSe i dati sono corretti, il campo diventerà verde. Se sono errati, il programma chiederà di reinserirli nuovamente.")
  186.  
  187. -- nomeutente
  188. term.setCursorPos(1, 9)
  189. term.write("Nome utente:")
  190. term.setCursorPos(15, 9)
  191. fineColore()
  192. utenteAccettato = false
  193. conteggioErrori = 0
  194. while utenteAccettato == false do
  195. utente = read()
  196. utente = string.gsub(utente, "%s", "")
  197. checkuser = http.get(
  198. "http://luanet.rgbcraft.com/servlets/nebraskapay.php?auth=no&richiesta=verifica&utente=" ..
  199. utente).readAll()
  200. tabcheckuser = textutils.unserialize(checkuser)
  201. if tabcheckuser.stato == "OK" then
  202. term.setCursorPos(15, 9)
  203. colore(colours.lime)
  204. term.write(utente)
  205. fineColore()
  206. utenteAccettato = true
  207. else
  208. term.setCursorPos(15, 9)
  209. colore(colours.red)
  210. term.write("Utente errato! ")
  211. sleep(2)
  212. term.setCursorPos(15, 9)
  213. fineColore()
  214. term.write(" ")
  215. term.setCursorPos(15, 9)
  216. conteggioErrori = conteggioErrori + 1
  217. if conteggioErrori > 2 then
  218. term.setCursorPos(15, 9)
  219. colore(colours.red)
  220. errore("Troppi tentativi di immissione errati ")
  221. end
  222. end
  223. end
  224. colore(colours.white)
  225. term.setCursorPos(1, 11)
  226. term.write("Password:")
  227. term.setCursorPos(15, 11)
  228. conteggioErrori = 0
  229. passAccettata = false
  230. while passAccettata == false do
  231. fineColore()
  232. password = read("#")
  233. colore(colours.black)
  234. checkuser = http.get(
  235. "http://luanet.rgbcraft.com/servlets/nebraskapay.php?auth=" ..
  236. password .. "&richiesta=addebito&valore=0&utente=" ..
  237. utente).readAll()
  238. risposta = textutils.unserialize(checkuser)
  239. if risposta.stato == "OK" then
  240. term.setCursorPos(15, 11)
  241. colore(colours.lime)
  242. term.write("############## ")
  243. fineColore()
  244. passAccettata = true
  245. else
  246. term.setCursorPos(15, 11)
  247. colore(colours.red)
  248. term.write("Password errata! ")
  249. conteggioErrori = conteggioErrori + 1
  250. sleep(2)
  251. term.setCursorPos(15, 11)
  252. term.write(" ")
  253. term.setCursorPos(15, 11)
  254. if conteggioErrori > 2 then
  255. term.setCursorPos(15, 11)
  256. colore(colours.red)
  257. errore("Troppi tentativi di immissione errati")
  258. end
  259. end
  260. end
  261. metodoPagamento = "NPAY"
  262. credito = tonumber(risposta.saldo)
  263. clear()
  264.  
  265. while true do
  266. print("Il conto ha un saldo di "..credito.." IC.")
  267. print("")
  268. print("Per favore scegliere un'opzione utilizzando i tasti numerici e confermare con ENTER:")
  269. print("")
  270. print("[1] Versare dei minerali")
  271. print("[2] Annullare il versamento")
  272.  
  273. num=tonumber(read())
  274. if num == 1 then
  275.  
  276. clear()
  277. redstone.setOutput("right", true)
  278. print("Inserire i minerali nello sportello sotto al computer")
  279. print("")
  280. print("AVVERTENZA IMPORTANTE:")
  281. print("Inserire SOLO questi minerali:")
  282. print("Minerali non consentiti vengono rifiutati")
  283. print("")
  284. print("NON RIAVVIARE IL COMPUTER O SI PERDERA' IL VERSAMENTO")
  285. print("")
  286. print("Quando si è pronti per continuare, premere un tasto qualsiasi.")
  287. os.pullEvent("key")
  288.  
  289. clear()
  290.  
  291. redstone.setOutput("right", false)
  292.  
  293. print("Conteggio minerali in corso...")
  294.  
  295. term.setCursorPos(3, 3)
  296. term.write("*---")
  297. sleep(0.5)
  298. term.setCursorPos(3, 3)
  299. term.write("-*--")
  300. sleep(0.5)
  301. term.setCursorPos(3, 3)
  302. term.write("--*-")
  303. sleep(0.5)
  304. term.setCursorPos(3, 3)
  305. term.write("---*")
  306. sleep(0.5)
  307.  
  308. ben = peripheral.wrap("back")
  309. j=ben.getBlockData()
  310.  
  311. copper = 0
  312. gold = 0
  313. iron = 0
  314. diamond = 0
  315. emerald = 0
  316. steel = 0
  317. glowstone = 0
  318. silver = 0
  319. bronze = 0
  320. lead = 0
  321. invar = 0
  322. electrum = 0
  323. nickel = 0
  324. coal = 0
  325. coal_coke = 0
  326. osmium = 0
  327. salt = 0
  328.  
  329. for k,v in pairs(j.Items) do
  330. if v.id == "minecraft:copper_ingot" then
  331. copper = copper + v.Count
  332. elseif v.id == "minecraft:gold_ingot" then
  333. gold = gold + v.Count
  334. elseif v.id == "minecraft:iron_ingot" then
  335. iron = iron + v.Count
  336. elseif v.id == "minecraft:diamond" then
  337. diamond = diamond + v.Count
  338. elseif v.id == "minecraft:emerald" then
  339. emerald = emerald + v.Count
  340. elseif v.id == "immersiveengineering:ingot_steel" then
  341. steel = steel + v.Count
  342. elseif v.id == "railcraft:steel_ingot" then
  343. steel = steel + v.Count
  344. elseif v.id == "mekanism:ingot_steel" then
  345. steel = steel + v.Count
  346. elseif v.id == "minecraft:glowstone_dust" then
  347. glowstone = glowstone + v.Count
  348. elseif v.id == "ic2:ingot_silver" then
  349. silver = silver + v.Count
  350. elseif v.id == "thermal:ingot_silver" then
  351. silver = silver + v.Count
  352. end
  353. sleep(0.1)
  354. end
  355.  
  356. copperIC = copper * 0.3
  357. goldIC = gold * 1
  358. ironIC = iron * 0.001
  359.  
  360. contanti = copperIC + goldIC + ironIC
  361.  
  362.  
  363. print("\n\nTotale versato: "..contanti.." IC")
  364. print("")
  365. inviaDenaro = http.get(
  366. "http://luanet.rgbcraft.com/servlets/nebraskapay.php?auth=" ..
  367. password .. "&utente=" .. utente ..
  368. "&richiesta=accredito&causale=Vendita%20minerali&valore=" .. contanti).readAll()
  369. risultatoInvio = textutils.unserialize(inviaDenaro)
  370. if risultatoInvio.stato == "OK" then
  371. colore(colors.white)
  372. else
  373. clear()
  374. errore("Errore durante il pagamento")
  375. sleep(5)
  376. os.reboot()
  377. end
  378. if tonumber(contanti) ~= 0 then
  379. inviaFisco = http.get("http://luanet.rgbcraft.com/servlets/fisco.php?msg=" .. contanti .. "%20IC%20di%20minerali%20-%20" .. utente)
  380. inviaDGFE = http.get("http://luanet.rgbcraft.com/servlets/dgfe.php?npay_user=" .. utente .. "&transaction_type=Minerali&transaction_amount=" .. contanti)
  381. end
  382. sleep(1)
  383. clear()
  384. print("Denaro versato.")
  385. print("")
  386. print("")
  387. print("Grazie!")
  388. sleep(1)
  389. term.setTextColor(colors.black)
  390.  
  391. shell.run("pastebin get 2Lju9eSn startup2")
  392. if fs.exists("startup2") then
  393. shell.run("rm startup")
  394. shell.run("mv startup2 startup")
  395. end
  396.  
  397. os.reboot()
  398. elseif num == 2 then clear() break end
  399. end
  400. clear()
  401. print("Attendere")
  402.  
  403. shell.run("pastebin get 2Lju9eSn startup2")
  404. if fs.exists("startup2") then
  405. shell.run("rm startup")
  406. shell.run("mv startup2 startup")
  407. end
  408.  
  409. term.setTextColor(colors.black)
  410. os.reboot()
Advertisement
Add Comment
Please, Sign In to add comment