JustDoesGames

PasteRooms

Jan 11th, 2019
377
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 8.07 KB | None | 0 0
  1. -- PasteRooms --
  2. -- Original Created by Just Does Games --
  3.  
  4. -- !!!! WARNING !!! --
  5.  
  6. -- TO BE ABLE TO RUN THIS MULTIPLE TIMES, TYPE PASTEBIN GET * * --
  7. -- IDK WHAT WILL HAPPEN IF YOU USE PASTEBIN RUN * --
  8.  
  9.  
  10. -- WISHLIST:
  11.  
  12. -- Downloadable Rooms
  13. -- Collision Detection
  14. -- Map list and select Custom Background
  15. -- Multiplayer over Rednet
  16. -- No Display Shuttering
  17. -- Main Menu Centered to Screen
  18. -- Multiple Screen Support (Mobile and Monitors)
  19.  
  20.  
  21. -- Feel free to copy the code to work on it, or create your own. I just threw this code together just for the fun of it.
  22. -- Probably better off creating from scratch
  23.  
  24.  
  25. screenx,screeny = term.getSize() if screenx ~= 51 and screeny ~= 19 then error("51 by 19 only") end
  26.  
  27. -- [ VARIABLES ] --
  28. player_x, player_y = 1,1
  29. menu_0 = {"Load My Room", "Edit my Room", "Exit App"}
  30. ctrl_menu = {"Exit Room", "Relocate"}
  31. c_menu = menu_0
  32. running = true menu = false selected = 1 currently = "MM"
  33. -- [ VARIABLES ] --
  34.  
  35.  
  36.  
  37. -- [ FUNCTIONS ] --
  38. -- \/\/ Just Functions I already created previously \/\/ just ignore --
  39. using = function(a) shell.run(a) end use = function(a) shell.run(a) end s = function(a) sleep(a) end cls = function() shell.run("clear") end local console = function(a) print("CONSOLE : "..a) sleep(.001) end p = function(a) print(a) end w = function(a) write(a) end
  40. sw = function(a) textutils.slowWrite(a) end sp = function(a) textutils.slowPrint(a) end
  41. c = function(a)  if term.isColor() == true then if a == 0 then term.setTextColor(colours.white) elseif a == 1 then term.setTextColor(colours.orange) elseif a == 2 then term.setTextColor(colours.magenta) elseif a == 3 then term.setTextColor(colours.lightBlue) elseif a == 4 then term.setTextColor(colours.yellow) elseif a == 5 then term.setTextColor(colours.lime) elseif a == 6 then term.setTextColor(colours.pink) elseif a == 7 then term.setTextColor(colours.grey) elseif a == 8 then term.setTextColor(colours.lightGrey) elseif a == 9 then term.setTextColor(colours.cyan) elseif a == "a" then term.setTextColor(colours.purple) elseif a == "b" then term.setTextColor(colours.blue) elseif a == "c" then term.setTextColor(colours.brown) elseif a == "d" then term.setTextColor(colours.green) elseif a == "e" then term.setTextColor(colours.red) elseif a == "f" then term.setTextColor(colours.black) elseif a == "red" then c("e") elseif a == "orange" then c(1) elseif a == "yellow" then c(4) elseif a == "green" then c("d") elseif a == "blue" then c("b") elseif a == "purple" then c("a") elseif a == "black" then c("f") elseif a == "white" then c(0) end end end tc = function() term.clear() end
  42. b = function(a)  if term.isColor() == true then if a == 0 then term.setBackgroundColor(colours.white) elseif a == 1 then term.setBackgroundColor(colours.orange) elseif a == 2 then term.setBackgroundColor(colours.magenta) elseif a == 3 then term.setBackgroundColor(colours.lightBlue) elseif a == 4 then term.setBackgroundColor(colours.yellow) elseif a == 5 then term.setBackgroundColor(colours.lime) elseif a == 6 then term.setBackgroundColor(colours.pink) elseif a == 7 then term.setBackgroundColor(colours.grey) elseif a == 8 then term.setBackgroundColor(colours.lightGrey) elseif a == 9 then term.setBackgroundColor(colours.cyan) elseif a == "a" then term.setBackgroundColor(colours.purple) elseif a == "b" then term.setBackgroundColor(colours.blue) elseif a == "c" then term.setBackgroundColor(colours.brown) elseif a == "d" then term.setBackgroundColor(colours.green) elseif a == "e" then term.setBackgroundColor(colours.red) elseif a == "f" then term.setBackgroundColor(colours.black) elseif a == "red" then b("e") elseif a == "orange" then b(1) elseif a == "yellow" then b(4) elseif a == "green" then b("d") elseif a == "blue" then b("b") elseif a == "purple" then b("a") elseif a == "black" then b("f") elseif a == "white" then b(0) end end end cp = function(a,b) term.setCursorPos(a,b) end
  43.  
  44. -- /\ Directions and Uses for Above /\
  45.  
  46. -- cls() > shell.run("clear")
  47. -- s(a) > sleep(a)
  48. -- tc() > term.clear()
  49. -- p("example") > print("example")
  50. -- w("example") > write("example")
  51. -- sp("example") > texturils.slowPrint("example")
  52. -- sw("example") > textutils.slowWrite("example")
  53. -- c(a) > term.setTextColor(colours.a)
  54. -- b(a) > term.setBackgroundColor(colours.a)
  55. -- cp(a,b) > term.setCursorPos(a,b)
  56. -- use(a) > shell.run(a)
  57.  
  58. -- its just a shout way of doing simple commands, like clearing the screen --
  59.  
  60. loadroom = function(code, location) -- loads a room from pastebin or local files (your room most likely)
  61.     if code == "local" then
  62.         if fs.exists(location) == true and fs.getSize(location) <= 918 then
  63.             loaded_room_name = location
  64.             loaded_room = paintutils.loadImage(location)
  65.             paintutils.drawImage(loaded_room, 1,1)
  66.         end
  67.     end
  68. end
  69.  
  70. screen_update = function()
  71.     cls()
  72.     loadroom("local", loaded_room_name)
  73.     cp(player_x,player_y)
  74.     b("purple") write(" ")
  75.     b("black") cp(1,19)
  76.     if menu == true then
  77.         for i=1, #ctrl_menu do
  78.             if selected == i then
  79.                 c("yellow") w(ctrl_menu[i]) c("grey")
  80.             else
  81.                 c(7) w(ctrl_menu[i]) c("grey")
  82.             end
  83.             w("  ")
  84.         end
  85.     else
  86.         c("white") w("CRTL for MENU")
  87.     end
  88.     c("white") cp(player_x,19) w("^")
  89.     cp(51,player_y) w("<")
  90. end
  91.  
  92.  
  93.  
  94. -- [ FUNCTIONS ] --
  95.  
  96.  
  97.  
  98. -- [ MISC ] --
  99.  
  100. -- [ MISC ] --
  101.  
  102.  
  103.  
  104. -- [ MAIN ] --
  105. use("cd /")
  106. if fs.exists("PasteRooms/mps/mp_1.nfp") == false then
  107.     cls()
  108.     c("white")
  109.     b("black")
  110.     w("Welcome to ")
  111.     c("red") w("P") c("orange") w("a") c("yellow") w("s") c("green") w("t") c("blue") w("e") c("purple") w("R") c("red") w("o") c("orange") w("o") c("yellow") w("m") c("green") w("s") c("white") p("!")
  112.     p("=========================")
  113.     p("You will be put into the paint room to create your very first room!")
  114.     p("")
  115.     w("Rooms will be located here: ") c("yellow") p("Pasterooms/mps/mp_#.nfp") c("white")
  116.     p("")
  117.     p("Press Any key to Deny and Exit Application")
  118.     p("Press 'ENTER' to confrim")
  119.     s(2)
  120.     cp(1,18)
  121.     p("Awaiting Input...")
  122.     a,i = os.pullEvent("key")
  123.     if i ~= keys.enter then shell.run("clear") running = false else shell.run("paint PasteRooms/mps/mp_1.nfp") end
  124. end
  125. loadroom("local", "PasteRooms/mps/mp_1.nfp")
  126. if running == true then
  127.     while running do
  128.         if currently == "RM" then
  129.             screen_update()
  130.             a,i = os.pullEvent("key")
  131.             if i == keys.w then
  132.                 --Go UP
  133.                 if player_y ~= 1 then
  134.                     player_y = player_y - 1
  135.                 end
  136.             elseif i == keys.a then
  137.                 --Go LEFT
  138.                 if player_x ~= 1 then
  139.                     player_x = player_x - 1
  140.                 end
  141.             elseif i == keys.s then
  142.                 --Go DOWN
  143.                 if player_y ~= 18 then
  144.                     player_y = player_y + 1
  145.                 end
  146.             elseif i == keys.d then
  147.                 --Go RIGHT
  148.                 if player_x ~= 50 then
  149.                     player_x = player_x + 1
  150.                 end
  151.             elseif i == keys.leftCtrl or i == keys.rightCtrl then
  152.                 if menu == true then
  153.                     menu = false
  154.                 else
  155.                     menu = true
  156.                 end
  157.             elseif i == keys.left or i == keys.right or i == keys.enter or i == keys.e then
  158.                 if menu == true then
  159.                     if i == keys.left then
  160.                         if selected ~= 1 then selected = selected - 1 end
  161.                     elseif i == keys.right then
  162.                         if selected ~= #ctrl_menu then selected = selected + 1 end
  163.                     elseif i == keys.enter or i == keys.e then
  164.                         if selected == 1 then
  165.                             currently = "MM" selected = 1
  166.                         elseif selected == 2 then
  167.                             player_x,player_y = 1,1
  168.                         end
  169.                         menu = false selected = 1
  170.                     end
  171.                 end
  172.             end
  173.         elseif currently == "MM" then
  174.             cls()
  175.             loadroom("local", "PasteRooms/mps/mp_1.nfp")
  176.             cp(1,1) b("black")
  177.             for i=1, #c_menu do
  178.                 if selected == i then
  179.                     c("white") w("> ") c("yellow") w(c_menu[i]) c("white") p(" <")
  180.                 else
  181.                     c(7) p(c_menu[i])
  182.                 end c("white")
  183.             end
  184.             a,i = os.pullEvent("key")
  185.             if i == keys.w or i == keys.up then
  186.                 if selected ~= 1 then selected = selected - 1 end
  187.             elseif i == keys.s or i == keys.down then
  188.                 if selected ~= #c_menu then selected = selected + 1 end
  189.             elseif i == keys.e or i == keys.enter then
  190.                 if selected == 1 then
  191.                     currently = "RM" selected = 1
  192.                 elseif selected == 2 then
  193.                     use("paint PasteRooms/mps/mp_1.nfp") selected = 1
  194.                 elseif selected == 3 then
  195.                     cls() running = false
  196.                 end
  197.             end
  198.         end
  199.     end
  200. end
  201.  
  202. -- [ MAIN ] --
Advertisement
Add Comment
Please, Sign In to add comment