Advertisement
Guest User

Untitled

a guest
Jan 22nd, 2017
226
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 9.16 KB | None | 0 0
  1. local VERSION = '0.0.1 - initut(tm)'
  2.  
  3. print("Starting 20,000 Blocks Tutorial")
  4.  
  5. DEBUG_MODE = true
  6. local ox,oy,oz = commands.getBlockPosition()
  7.  
  8. NUMBER_OF_TUT_ZONES = 3
  9. REFRESH_ZONE = {
  10. x=12250,
  11. y=55,
  12. z=-1755,
  13. w=16,
  14. l=60,
  15. h=11
  16. }
  17. INCOMING_ZONE = {
  18. x=12227,
  19. y=55,
  20. z=-1730,
  21. w=7,
  22. l=7,
  23. h=5
  24. }
  25. OUTGOING_POINT = {
  26. x=12324,
  27. y=57,
  28. z=-1731
  29. }
  30.  
  31. NUMBER_OF_VOCAB = 10
  32. VOCAB_LOCATION = {
  33. x=-47,
  34. y=57,
  35. z=-94
  36. }
  37. VOCAB_WIDTH = 27
  38. VOCAB_HEIGHT = 19
  39. TUTORIAL_VOCABS = {1,2}
  40.  
  41.  
  42. BLOCKS = {
  43. CAMP_FLOOR = {block='minecraft:sandstone',data=0},
  44. CONSTRUCTION = {block='minecraft:diamond_ore',data=0},
  45. RING = {block='minecraft:diamond_ore',data=0},
  46. DETECT = {block='minecraft:red_sandstone',data=0},
  47. DETECT_DEAD = {block='minecraft:obsidian',data=0},
  48. VOCAB_DETECT = {block="minecraft:quartz_block",data=0},
  49. VOCAB_REPLACE = {block="minecraft:coal_block",data=0},
  50. VICTORY_MARKER = {block="minecraft:emerald_block",data=0},
  51. PLUG = {block="minecraft:lapis_ore",data=0},
  52. PHVFLOOR = {block="minecraft:stone_slab",data=3},
  53. BUILDING_HOUSE = {block="minecraft:wool",data=0},
  54. BUILDING_GARDEN = {block="minecraft:wool",data=13},
  55. BUILDING_WATER = {block="minecraft:wool",data=1},
  56. }
  57.  
  58.  
  59. --call these to return a proper minecraft item string including adventure mode properties
  60. function houseBlock(quant)
  61. text = BLOCKS.BUILDING_HOUSE.block..' '..quant..' '..BLOCKS.BUILDING_HOUSE.data..' {display:{Name:"House Construction Block",Lore:[Place this against a Diamond to build a house]},CanPlaceOn:["'..BLOCKS.BUILDING_HOUSE.block..'","'..BLOCKS.PLUG.block..'","'..BLOCKS.DETECT.block..'"]}'
  62. return text
  63. end
  64.  
  65. function waterBlock(quant)
  66. text = BLOCKS.BUILDING_WATER.block..' '..quant..' '..BLOCKS.BUILDING_WATER.data..' {display:{Name:"Water Construction Block",Lore:[Place this against a Diamond to build a pond or pool]},CanPlaceOn:["'..BLOCKS.BUILDING_HOUSE.block..'","'..BLOCKS.PLUG.block..'","'..BLOCKS.DETECT.block..'"]}'
  67. return text
  68. end
  69.  
  70. function gardenBlock(quant)
  71. text = BLOCKS.BUILDING_GARDEN.block..' '..quant..' '..BLOCKS.BUILDING_GARDEN.data..' {display:{Name:"Garden Construction Block",Lore:[Place this against a Diamond to build a pond or pool]},CanPlaceOn:["'..BLOCKS.BUILDING_HOUSE.block..'","'..BLOCKS.PLUG.block..'","'..BLOCKS.DETECT.block..'"]}'
  72. return text
  73. end
  74.  
  75. STARTING_ITEMS = {
  76. houseBlock(5), gardenBlock(5)
  77. }
  78.  
  79. REWARDS = {}
  80. --plain singlehouse rewards (costs 4 house, -2+1 activators)
  81. REWARDS[1] = gardenBlock(4)
  82. REWARDS[2] = gardenBlock(4)
  83. REWARDS[3] = gardenBlock(4)
  84. REWARDS[4] = gardenBlock(4)
  85. --extension rise rewards (costs 6 house, -2+1 activators)
  86. REWARDS[5] = gardenBlock(7)
  87. REWARDS[6] = gardenBlock(7)
  88. REWARDS[7] = gardenBlock(7)
  89. REWARDS[8] = gardenBlock(7)
  90. --house bridge rewards (costs 6 house, -3+2 activators)
  91. REWARDS[9] = gardenBlock(10)
  92. REWARDS[10] = gardenBlock(10)
  93. --garden bridge (unused)
  94. REWARDS[11] = gardenBlock(7)
  95. REWARDS[12] = gardenBlock(7)
  96. --extention row house rewards (costs 4 house, 1 activators)
  97. REWARDS[13] = houseBlock(6)
  98. REWARDS[14] = houseBlock(6)
  99. REWARDS[15] = houseBlock(6)
  100. REWARDS[16] = houseBlock(6)
  101. --riser 1
  102. REWARDS[17] = houseBlock(1)
  103. --riser 2
  104. REWARDS[18] = houseBlock(1)
  105. --filler garden
  106. REWARDS[19] = houseBlock(1)
  107. --filler house plaza
  108. REWARDS[20] = gardenBlock(3)
  109. --extention-farm (like extension rise) (costs 6 garden, -2 activators)
  110. REWARDS[21] = houseBlock(3)
  111. REWARDS[22] = houseBlock(3)
  112. REWARDS[23] = houseBlock(3)
  113. REWARDS[24] = houseBlock(3)
  114. --extension-garden (like extension row house)rewards (costs 3 garden, 1 activators)
  115. REWARDS[25] = "minecraft:emerald"
  116. REWARDS[26] = "minecraft:emerald"
  117. REWARDS[27] = "minecraft:emerald"
  118. REWARDS[28] = "minecraft:emerald"
  119. --L-shaped small business agriculture (costs 6 garden, -3+2 activators)
  120. REWARDS[29] = "minecraft:emerald 2"
  121. REWARDS[30] = "minecraft:emerald 2"
  122. REWARDS[31] = "minecraft:emerald 2"
  123. REWARDS[32] = "minecraft:emerald 2"
  124. --L-shaped small business urban (costs 6 housing, -3+2 activators)
  125. REWARDS[33] = gardenBlock(6)
  126. REWARDS[34] = gardenBlock(6)
  127. REWARDS[35] = gardenBlock(6)
  128. REWARDS[36] = gardenBlock(6)
  129. --allotments (costs 4 garden, -2 activators)
  130. REWARDS[37] = houseBlock(2)
  131. REWARDS[38] = houseBlock(2)
  132. REWARDS[39] = houseBlock(2)
  133. REWARDS[40] = houseBlock(2)
  134.  
  135. DEFAULT_NAME = 'default-vocab'
  136. VOCAB_NAMES = {
  137. 'freestand-house',
  138. 'freestand-house',
  139. 'freestand-house',
  140. 'freestand-house',
  141. 'dbl-ext-house',
  142. 'dbl-ext-house',
  143. 'dbl-ext-house',
  144. 'dbl-ext-house',
  145. 'bridge-house',
  146. 'bridge-house',
  147. 'bridge-garden',
  148. 'bridge-garden',
  149. 'ext-house',
  150. 'ext-house',
  151. 'ext-house',
  152. 'ext-house',
  153. 'riser-1',
  154. 'riser-2',
  155. 'city-garden',
  156. 'city-plaza',
  157. 'dbl-ext-garden',
  158. 'dbl-ext-garden',
  159. 'dbl-ext-garden',
  160. 'dbl-ext-garden',
  161. 'ext-garden',
  162. 'ext-garden',
  163. 'ext-garden',
  164. 'ext-garden',
  165. 'corner-garden',
  166. 'corner-garden',
  167. 'corner-garden',
  168. 'corner-garden',
  169. 'corner-house',
  170. 'corner-house',
  171. 'corner-house',
  172. 'corner-house',
  173. 'freestand-garden',
  174. 'freestand-garden',
  175. 'freestand-garden',
  176. 'freestand-garden',
  177. 'zoo',
  178. 'bookstore',
  179. 'greenhouse',
  180. 'fablab'
  181. }
  182.  
  183. --PARTICLE FUNCTIONS
  184. function searchParticle(x,y,z)
  185. commands.async.particle("fireworksSpark",x,y,z,0.01,3,0.01,0.01,100)
  186. end
  187.  
  188. function successParticle(x,y,z)
  189. commands.async.particle("happyVillager",x,y,z,2,2,2,1,1000)
  190. commands.async.playsound("random.levelup","@a",x,y,z,1,1.2)
  191. end
  192.  
  193. function failParticle(x,y,z)
  194. commands.async.particle("reddust",x,y,z,0.1,0.1,1.5,1,200)
  195. commands.async.particle("reddust",x,y,z,1.5,0.1,0.1,1,200)
  196. commands.async.playsound("random.bowhit","@a",x,y,z,1,0.8)
  197. end
  198.  
  199. --constructor for player object so that data structure is consistant
  200. function newPlayerData(name,x,y,z)
  201. local p = {
  202. name = name,
  203. x=x,
  204. y=y,
  205. z=z
  206. }
  207. return p
  208. end
  209.  
  210. --return a list of all players in the game world as player objects
  211. local function getNameFromMessage(message)
  212. local names = {}
  213.  
  214. local wordpattern = "[^, ]+"
  215. local numberpattern = "[%-% ]%d+[%.]%d+"
  216. local words,numbers = {},{}
  217.  
  218. for word in string.gmatch(message, wordpattern) do
  219. table.insert(words,word)
  220. end
  221.  
  222. for number in string.gmatch(message, numberpattern) do
  223. table.insert(numbers,number)
  224. end
  225.  
  226. local coords = {
  227. x = math.floor(numbers[1]),
  228. y = math.floor(numbers[2]),
  229. z = math.floor(numbers[3])
  230. }
  231. local name = words[2]
  232. return newPlayerData(name,coords.x,coords.y,coords.z)
  233. end
  234.  
  235.  
  236.  
  237. --constructor for a tutorial zone
  238. function newTutZone(x,y,z,vocabZones)
  239. local ntz = {}
  240. ntz.x ,ntz.y ,ntz.z = x,y,z
  241. ntz.player = nil
  242. ntz.clean = false
  243. ntz.vocab = vocabZones
  244. return ntz
  245. end
  246.  
  247. local function resetZone(zone)
  248.  
  249. end
  250.  
  251. --reset all tutorials. Teleports current players back to the incoming zone. clears all tutorial zones of blocks and resets them.
  252. local function resetAllTutorials()
  253. end
  254.  
  255. --check for players and fill if needed
  256. local function checkAndFill(zone)
  257. local iz = INCOMING_ZONE
  258. local result,msg = commands.tp("@p[x="..iz.x..",y="..iz.y..",z="..iz.z..",dx="..iz.w..",dy="..iz.h..",dz="..iz.l.."]",zone.x+1,zone.y+1,zone.z+1)
  259. if result then
  260. zone.player = getNameFromMessage(msg[1])
  261. end
  262. end
  263.  
  264. --player check vocab update
  265. local function doVocabGameplay(zone)
  266. commands.tell(zone.player.name,"Doing Vocab Gameplay")
  267. end
  268.  
  269. --check for victory and tp players out
  270. local function checkVictoryAndExit(zone)
  271. commands.tell(zone.player.name,"Doing Victory section")
  272. commands.tp(zone.player.name,OUTGOING_POINT.x,OUTGOING_POINT.y,OUTGOING_POINT.z)
  273. zone.clean = false
  274. zone.player = nil
  275. end
  276.  
  277. -- zone clean up
  278. local function cleanZone(zone)
  279. local rz = REFRESH_ZONE
  280. commands.clone(rz.x,rz.y,rz.z,rz.x+rz.l,rz.y+rz.h,rz.z+rz.w,zone.x,zone.y,zone.z,"replace")
  281. commands.say("cleaned zone")
  282. zone.clean = true
  283. end
  284.  
  285. --do all logic for tutzones
  286. local function updateTutZones(tuts)
  287. print("tick",os.time())
  288. --all empty zones check for players and get if available
  289. for index,zone in ipairs(tuts.zones) do
  290. if zone.player == nil then
  291. checkAndFill(zone)
  292. end
  293. end
  294.  
  295. sleep(1)
  296.  
  297. --all zones with player check vocab update
  298. for index,zone in ipairs(tuts.zones) do
  299. if zone.player then
  300. doVocabGameplay(zone)
  301. end
  302. end
  303.  
  304. sleep(10)
  305.  
  306.  
  307. --all zones with players check for victory and tp players out
  308. for index,zone in ipairs(tuts.zones) do
  309. if zone.player then
  310. checkVictoryAndExit(zone)
  311. end
  312. end
  313.  
  314. sleep(1)
  315.  
  316. --all empty zones which need cleaning are cleaned up
  317. for index,zone in ipairs(tuts.zones) do
  318. if zone.clean == false then
  319. cleanZone(zone)
  320. end
  321. end
  322.  
  323. sleep(1)
  324.  
  325. end
  326.  
  327. --setup a new tuts object
  328. local function setup()
  329. local tuts = {}
  330. tuts.zones = {}
  331. local rz = REFRESH_ZONE
  332. for index = 1, NUMBER_OF_TUT_ZONES do
  333. local newZone = newTutZone(rz.x,rz.y,rz.z+(index*(rz.w+2)),{})
  334. table.insert(tuts.zones,newZone)
  335. end
  336.  
  337. --check for vocab zone at vocab location
  338. --build all vocab locations
  339. --store vocab in tuts object
  340.  
  341. return tuts
  342. end
  343.  
  344. sleep(5)
  345. --BEGIN RUNTIME CODE
  346. local blink = true
  347. local tuts = setup()
  348. while true do
  349. updateTutZones(tuts)
  350. commands.async.weather("clear",10000)
  351.  
  352. local resetbutton = redstone.getInput("left")
  353. if resetbutton then
  354. print("reset!")
  355. resetAllTutorials()
  356. end
  357. sleep(2)
  358. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement