Advertisement
Guest User

rng

a guest
Sep 7th, 2016
120
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 0.87 KB | None | 0 0
  1. local dx, dy = 3, 3
  2. local scr_x, scr_y = term.getSize()
  3.  
  4. local range = {1,20}
  5.  
  6. local dice = paintutils.loadImage("dice.nfp")
  7. local tc = term.current().setVisible
  8. function render(x,y,number)
  9.   tc(false)
  10.   for a = 1, scr_y do
  11.     term.setCursorPos(1,a)
  12.     if a > scr_y/2 then
  13.       term.setBackgroundColor(colors.brown)
  14.     else
  15.       term.setBackgroundColor(colors.yellow)
  16.     end
  17.     term.clearLine()
  18.   end
  19.   paintutils.drawImage(dice,x-dx,y-(dy-1))
  20.   term.setCursorPos(x,y)
  21.   term.setTextColor(colors.black)
  22.   term.setBackgroundColor(colors.lightBlue)
  23.   term.write(tostring(number))
  24.   tc(true)
  25. end
  26.  
  27. --os.queueEvent("key", keys.space)
  28. render(scr_x/2,-6,"")
  29.  
  30. while true do
  31.   local evt, key = os.pullEvent("key")
  32.   if key == keys.space then
  33.     for a = -2, (scr_y/2)+1 do
  34.       render(scr_x/2,a,math.random(range[1],range[2]))
  35.       sleep(0)
  36.     end
  37.   end
  38. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement