Advertisement
antonsavov

Untitled

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