Advertisement
xXm0dzXx

NeXiMoN Tilesets Preview

Nov 3rd, 2012
227
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.49 KB | None | 0 0
  1. local charX = 0
  2. local charY = 0
  3. local currentMap = ""; -- DO NOT CHANGE
  4. local maps = {
  5. ["map_0"] = {
  6. " XXX",
  7. " XBX",
  8. "XXXXXXXBX",
  9. "XZBBBBBBX",
  10. "XXXXXXXBX",
  11. " XBX",
  12. " XXX",
  13. }
  14. }
  15.  
  16. local colorSet = {
  17. ["X"] = colors.lightGray,
  18. ["B"] = colors.black,
  19. ["Z"] = colors.cyan,
  20. }
  21.  
  22. local spawnX = 0
  23. local spawnY = 0
  24.  
  25. local blockInfo = {
  26. }
  27.  
  28. function isPortalSurface( posX, posY )
  29. if blockInfo[ posX.. "/" ..posY ] then
  30. return true
  31. end
  32. return false
  33. end
  34.  
  35. function isPortal( posX, posY )
  36. if portalBlueX == posX and portalBlueY == posY then
  37. return 0
  38. elseif portalRedY == posY and portalRedX == posX then
  39. return 1
  40. end
  41. return false
  42. end
  43.  
  44. function loadmap( map )
  45. term.setBackgroundColour( colors.gray )
  46. term.clear()
  47. local theMap = maps[map]
  48. for i=1,#theMap do
  49. for iv=1,#(theMap[i]) do
  50. local pixel = string.sub( theMap[i], iv, iv )
  51. if colorSet[pixel] then
  52. paintutils.drawPixel( 3+iv, 3+i, colorSet[pixel] )
  53. if map ~= currentMap then --If first time loading then...
  54. if pixel == "Z" then
  55. charX = 3+iv
  56. charY = 3+i
  57. elseif pixel == "X" then
  58. blockInfo[3+iv.. "/" ..3+i] = true
  59. end
  60. end
  61. end
  62. end
  63. end
  64.  
  65. if map ~= currentMap then
  66. currentMap = map
  67. end
  68. end
  69.  
  70. local portalBlueX = 0
  71. local portalBlueY = 0
  72.  
  73. local portalRedX = 0
  74. local portalRedY = 0
  75.  
  76. function redraw()
  77. loadmap( "map_0" )
  78. paintutils.drawPixel( portalBlueX, portalBlueY, colors.blue )
  79. paintutils.drawPixel( portalRedX, portalRedY, colors.red )
  80. term.setBackgroundColour( colors.black )
  81. term.setTextColour( colors.lime )
  82. term.setCursorPos( charX, charY )
  83. write("A")
  84. end
  85.  
  86. while true do
  87. redraw()
  88. local event, key, keyX, keyY = os.pullEvent()
  89. if event == "key" then
  90. oldCharX = charX
  91. oldCharY = charY
  92. if key == keys.left then
  93. charX = charX -1
  94. elseif key == keys.right then
  95. charX = charX +1
  96. elseif key == keys.up then
  97. charY = charY -1
  98. elseif key == keys.down then
  99. charY = charY +1
  100. end
  101.  
  102. if isPortalSurface( charX, charY ) then
  103. charX = oldCharX
  104. charY = oldCharY
  105. end
  106. elseif event == "mouse_click" then
  107. if isPortalSurface( keyX, keyY ) then
  108. if key == 1 then
  109. portalBlueX = keyX
  110. portalBlueY = keyY
  111. elseif key == 2 then
  112. portalRedX = keyX
  113. portalRedY = keyY
  114. end
  115. end
  116. elseif event == "char" then
  117. if key == "r" or key == "R" then
  118. portalBlueX = 0
  119. portalBlueY = 0
  120.  
  121. portalRedX = 0
  122. portalRedY = 0
  123. end
  124. end
  125. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement