Advertisement
antonsavov

Untitled

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