Advertisement
TIMAS_Bro

kazik

Oct 24th, 2023 (edited)
701
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. local file = fs.open("lgame/lgame","r")
  2. if file then
  3.     file.close()
  4. os.loadAPI('/lg/lg')
  5. lg.setup('term')
  6. os.loadAPI("uap")
  7. local lgamec = require("../lgame/lgame")
  8. lgamec.setup("term")
  9. lg.fillScreen(colors.black)
  10. local im1 = fs.open("/kazik/1.nfp","r")
  11. if im1 then
  12.   im1.close()
  13. else
  14.   lg.drawText(1,6,colors.white,colors.black,"Downloading sprites...")
  15.   shell.run("pastebin","get","Ewsn8TYn","/kazik/archive")
  16.   lg.drawText(1,6,colors.white,colors.black,"Downloading sprites... DONE")
  17.   lg.drawText(1,7,colors.white,colors.black,"Unpacking...")
  18.   local arch = fs.open("archive/archive","r")
  19.   if not arch then
  20.      lg.drawText(1,7,colors.red,colors.black,"DOWNLOAD ARCHIVE FROM UPDATER!")
  21.      os.sleep(4)
  22.      os.reboot()
  23.   end
  24.   shell.run("archive/archive unpack","/kazik/archive","/kazik/")
  25.   lg.drawText(1,7,colors.white,colors.black,"Unpacking... DONE")
  26.   os.sleep(2)
  27.   shell.run("delete","/kazik/archive")
  28.   os.sleep(1)
  29.   lg.fillScreen(colors.black)
  30.  
  31. end
  32. local lg = require("../lgame/lgame")
  33. lg.setup("term")
  34. function entryAnim(digit,x)
  35.   for i=1,4 do
  36.     game:moveSprite("ui",2,1)
  37.     game:moveSprite(digit,x,i,false)
  38.       if digit == "digit1" then
  39.     game:moveSprite("digit2",12,4,false)
  40.     game:moveSprite("digit3",19,4,false)    
  41.   elseif digit == "digit2" then
  42.     game:moveSprite("digit1",5,4,false)
  43.     game:moveSprite("digit3",19,4,false)
  44.   else
  45.     game:moveSprite("digit2",12,4,false)
  46.     game:moveSprite("digit1",5,4,false)
  47.   end
  48.     game:moveSprite("pane",3,1,false)  
  49.     os.sleep(0.1)
  50.     lg.drawBT("roll",4,11,13,15,colors.white,colors.gray,"  ROLL!")
  51.   end
  52.  
  53. end
  54. function redrawDigit(digit,image)
  55. game:changeImage(digit,"kazik/"..image)
  56. game:moveSprite("ui",2,1)
  57. dx = {digit1 = 5, digit2 = 12, digit3 = 19}
  58. entryAnim(digit, dx[digit])
  59.   if digit == "digit1" then
  60.     game:moveSprite("digit2",12,4,false)
  61.     game:moveSprite("digit3",19,4,false)    
  62.   elseif digit == "digit2" then
  63.     game:moveSprite("digit1",5,4,false)
  64.     game:moveSprite("digit3",19,4,false)
  65.   else
  66.     game:moveSprite("digit2",12,4,false)
  67.     game:moveSprite("digit1",5,4,false)
  68.   end
  69. game:moveSprite("pane",3,1,false)
  70. lg.drawBT("roll",4,11,13,15,colors.white,colors.gray,"  ROLL!")
  71. end
  72. game = lg.createScene(1,1,lg.getSize().x,lg.getSize().y,true)
  73. game:fillScreen(colors.black)
  74. game:drawSprite("ui",2,1,"kazik/ui.nfp")
  75. game:drawSprite("digit1",5,4,"kazik/7.nfp")
  76. game:drawSprite("digit2",12,4,"kazik/7.nfp")
  77. game:drawSprite("digit3",19,4,"kazik/7.nfp")
  78. game:drawSprite("pane",3,1,"kazik/pane.nfp")
  79. lg.drawBT("roll",4,11,13,15,colors.white,colors.red,"  ROLL!")
  80. myTable = {"7.nfp","emerald.nfp","1.nfp","1.nfp","1.nfp","emerald.nfp"}
  81. winnings = {n7 = "32AR",nemerald = "16AR",n1 = "8AR"}
  82. while true do
  83.   local event, button, x, y = os.pullEvent( "mouse_click" )
  84.   if lg.isButton(x,y) == "roll" then
  85.     local r1 = myTable[math.random(#myTable)]
  86.     local r2 = myTable[math.random(#myTable)]
  87.     local r3 = myTable[math.random(#myTable)]
  88.     os.sleep(0.3)
  89.     redrawDigit("digit1",r1)
  90.     os.sleep(0.3)
  91.     redrawDigit("digit2",r2)
  92.     os.sleep(0.3)
  93.     redrawDigit("digit3",r3)
  94.     game:moveSprite("ui",2,1)
  95.     game:moveSprite("digit2",12,4,false)
  96.     game:moveSprite("digit3",19,4,false)
  97.     game:moveSprite("digit1",5,4,false)
  98.     game:moveSprite("pane",3,1,false)  
  99.     lg.drawBT("roll",4,11,13,15,colors.white,colors.red,"  ROLL!")
  100.     if (string.find(r1,r2) and string.find(r1,r3)) then
  101.         lg.drawText(6,lg.getSize().y-3,colors.orange,colors.white,"YOU WIN!")
  102.     else
  103.       lg.drawText(6,lg.getSize().y-3,colors.red,colors.white,"YOU LOOSE!")
  104.     end
  105.   end
  106. end
  107. lg.exit()
  108. else
  109.     term.clear()
  110.     term.setCursorPos(1,2)
  111.     term.write("Install lgame from updater!")
  112.     uap.upd()
  113. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement