Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local VERSION = '0.0.1 - initut(tm)'
- print("Starting 20,000 Blocks Tutorial")
- DEBUG_MODE = true
- local ox,oy,oz = commands.getBlockPosition()
- NUMBER_OF_TUT_ZONES = 3
- REFRESH_ZONE = {
- x=12250,
- y=55,
- z=-1755,
- w=16,
- l=60,
- h=11
- }
- INCOMING_ZONE = {
- x=12227,
- y=55,
- z=-1730,
- w=7,
- l=7,
- h=5
- }
- OUTGOING_POINT = {
- x=12324,
- y=57,
- z=-1731
- }
- NUMBER_OF_VOCAB = 10
- VOCAB_LOCATION = {
- x=-47,
- y=57,
- z=-94
- }
- VOCAB_WIDTH = 27
- VOCAB_HEIGHT = 19
- TUTORIAL_VOCABS = {1,2}
- BLOCKS = {
- CAMP_FLOOR = {block='minecraft:sandstone',data=0},
- CONSTRUCTION = {block='minecraft:diamond_ore',data=0},
- RING = {block='minecraft:diamond_ore',data=0},
- DETECT = {block='minecraft:red_sandstone',data=0},
- DETECT_DEAD = {block='minecraft:obsidian',data=0},
- VOCAB_DETECT = {block="minecraft:quartz_block",data=0},
- VOCAB_REPLACE = {block="minecraft:coal_block",data=0},
- VICTORY_MARKER = {block="minecraft:emerald_block",data=0},
- PLUG = {block="minecraft:lapis_ore",data=0},
- PHVFLOOR = {block="minecraft:stone_slab",data=3},
- BUILDING_HOUSE = {block="minecraft:wool",data=0},
- BUILDING_GARDEN = {block="minecraft:wool",data=13},
- BUILDING_WATER = {block="minecraft:wool",data=1},
- }
- --call these to return a proper minecraft item string including adventure mode properties
- function houseBlock(quant)
- 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..'"]}'
- return text
- end
- function waterBlock(quant)
- 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..'"]}'
- return text
- end
- function gardenBlock(quant)
- 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..'"]}'
- return text
- end
- STARTING_ITEMS = {
- houseBlock(5), gardenBlock(5)
- }
- REWARDS = {}
- --plain singlehouse rewards (costs 4 house, -2+1 activators)
- REWARDS[1] = gardenBlock(4)
- REWARDS[2] = gardenBlock(4)
- REWARDS[3] = gardenBlock(4)
- REWARDS[4] = gardenBlock(4)
- --extension rise rewards (costs 6 house, -2+1 activators)
- REWARDS[5] = gardenBlock(7)
- REWARDS[6] = gardenBlock(7)
- REWARDS[7] = gardenBlock(7)
- REWARDS[8] = gardenBlock(7)
- --house bridge rewards (costs 6 house, -3+2 activators)
- REWARDS[9] = gardenBlock(10)
- REWARDS[10] = gardenBlock(10)
- --garden bridge (unused)
- REWARDS[11] = gardenBlock(7)
- REWARDS[12] = gardenBlock(7)
- --extention row house rewards (costs 4 house, 1 activators)
- REWARDS[13] = houseBlock(6)
- REWARDS[14] = houseBlock(6)
- REWARDS[15] = houseBlock(6)
- REWARDS[16] = houseBlock(6)
- --riser 1
- REWARDS[17] = houseBlock(1)
- --riser 2
- REWARDS[18] = houseBlock(1)
- --filler garden
- REWARDS[19] = houseBlock(1)
- --filler house plaza
- REWARDS[20] = gardenBlock(3)
- --extention-farm (like extension rise) (costs 6 garden, -2 activators)
- REWARDS[21] = houseBlock(3)
- REWARDS[22] = houseBlock(3)
- REWARDS[23] = houseBlock(3)
- REWARDS[24] = houseBlock(3)
- --extension-garden (like extension row house)rewards (costs 3 garden, 1 activators)
- REWARDS[25] = "minecraft:emerald"
- REWARDS[26] = "minecraft:emerald"
- REWARDS[27] = "minecraft:emerald"
- REWARDS[28] = "minecraft:emerald"
- --L-shaped small business agriculture (costs 6 garden, -3+2 activators)
- REWARDS[29] = "minecraft:emerald 2"
- REWARDS[30] = "minecraft:emerald 2"
- REWARDS[31] = "minecraft:emerald 2"
- REWARDS[32] = "minecraft:emerald 2"
- --L-shaped small business urban (costs 6 housing, -3+2 activators)
- REWARDS[33] = gardenBlock(6)
- REWARDS[34] = gardenBlock(6)
- REWARDS[35] = gardenBlock(6)
- REWARDS[36] = gardenBlock(6)
- --allotments (costs 4 garden, -2 activators)
- REWARDS[37] = houseBlock(2)
- REWARDS[38] = houseBlock(2)
- REWARDS[39] = houseBlock(2)
- REWARDS[40] = houseBlock(2)
- DEFAULT_NAME = 'default-vocab'
- VOCAB_NAMES = {
- 'freestand-house',
- 'freestand-house',
- 'freestand-house',
- 'freestand-house',
- 'dbl-ext-house',
- 'dbl-ext-house',
- 'dbl-ext-house',
- 'dbl-ext-house',
- 'bridge-house',
- 'bridge-house',
- 'bridge-garden',
- 'bridge-garden',
- 'ext-house',
- 'ext-house',
- 'ext-house',
- 'ext-house',
- 'riser-1',
- 'riser-2',
- 'city-garden',
- 'city-plaza',
- 'dbl-ext-garden',
- 'dbl-ext-garden',
- 'dbl-ext-garden',
- 'dbl-ext-garden',
- 'ext-garden',
- 'ext-garden',
- 'ext-garden',
- 'ext-garden',
- 'corner-garden',
- 'corner-garden',
- 'corner-garden',
- 'corner-garden',
- 'corner-house',
- 'corner-house',
- 'corner-house',
- 'corner-house',
- 'freestand-garden',
- 'freestand-garden',
- 'freestand-garden',
- 'freestand-garden',
- 'zoo',
- 'bookstore',
- 'greenhouse',
- 'fablab'
- }
- --PARTICLE FUNCTIONS
- function searchParticle(x,y,z)
- commands.async.particle("fireworksSpark",x,y,z,0.01,3,0.01,0.01,100)
- end
- function successParticle(x,y,z)
- commands.async.particle("happyVillager",x,y,z,2,2,2,1,1000)
- commands.async.playsound("random.levelup","@a",x,y,z,1,1.2)
- end
- function failParticle(x,y,z)
- commands.async.particle("reddust",x,y,z,0.1,0.1,1.5,1,200)
- commands.async.particle("reddust",x,y,z,1.5,0.1,0.1,1,200)
- commands.async.playsound("random.bowhit","@a",x,y,z,1,0.8)
- end
- --constructor for player object so that data structure is consistant
- function newPlayerData(name,x,y,z)
- local p = {
- name = name,
- x=x,
- y=y,
- z=z
- }
- return p
- end
- --return a list of all players in the game world as player objects
- local function getNameFromMessage(message)
- local names = {}
- local wordpattern = "[^, ]+"
- local numberpattern = "[%-% ]%d+[%.]%d+"
- local words,numbers = {},{}
- for word in string.gmatch(message, wordpattern) do
- table.insert(words,word)
- end
- for number in string.gmatch(message, numberpattern) do
- table.insert(numbers,number)
- end
- local coords = {
- x = math.floor(numbers[1]),
- y = math.floor(numbers[2]),
- z = math.floor(numbers[3])
- }
- local name = words[2]
- return newPlayerData(name,coords.x,coords.y,coords.z)
- end
- --constructor for a tutorial zone
- function newTutZone(x,y,z,vocabZones)
- local ntz = {}
- ntz.x ,ntz.y ,ntz.z = x,y,z
- ntz.player = nil
- ntz.clean = false
- ntz.vocab = vocabZones
- return ntz
- end
- local function resetZone(zone)
- end
- --reset all tutorials. Teleports current players back to the incoming zone. clears all tutorial zones of blocks and resets them.
- local function resetAllTutorials()
- end
- --check for players and fill if needed
- local function checkAndFill(zone)
- local iz = INCOMING_ZONE
- 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)
- if result then
- zone.player = getNameFromMessage(msg[1])
- end
- end
- --player check vocab update
- local function doVocabGameplay(zone)
- commands.tell(zone.player.name,"Doing Vocab Gameplay")
- end
- --check for victory and tp players out
- local function checkVictoryAndExit(zone)
- commands.tell(zone.player.name,"Doing Victory section")
- commands.tp(zone.player.name,OUTGOING_POINT.x,OUTGOING_POINT.y,OUTGOING_POINT.z)
- zone.clean = false
- zone.player = nil
- end
- -- zone clean up
- local function cleanZone(zone)
- local rz = REFRESH_ZONE
- 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")
- commands.say("cleaned zone")
- zone.clean = true
- end
- --do all logic for tutzones
- local function updateTutZones(tuts)
- print("tick",os.time())
- --all empty zones check for players and get if available
- for index,zone in ipairs(tuts.zones) do
- if zone.player == nil then
- checkAndFill(zone)
- end
- end
- sleep(1)
- --all zones with player check vocab update
- for index,zone in ipairs(tuts.zones) do
- if zone.player then
- doVocabGameplay(zone)
- end
- end
- sleep(10)
- --all zones with players check for victory and tp players out
- for index,zone in ipairs(tuts.zones) do
- if zone.player then
- checkVictoryAndExit(zone)
- end
- end
- sleep(1)
- --all empty zones which need cleaning are cleaned up
- for index,zone in ipairs(tuts.zones) do
- if zone.clean == false then
- cleanZone(zone)
- end
- end
- sleep(1)
- end
- --setup a new tuts object
- local function setup()
- local tuts = {}
- tuts.zones = {}
- local rz = REFRESH_ZONE
- for index = 1, NUMBER_OF_TUT_ZONES do
- local newZone = newTutZone(rz.x,rz.y,rz.z+(index*(rz.w+2)),{})
- table.insert(tuts.zones,newZone)
- end
- --check for vocab zone at vocab location
- --build all vocab locations
- --store vocab in tuts object
- return tuts
- end
- sleep(5)
- --BEGIN RUNTIME CODE
- local blink = true
- local tuts = setup()
- while true do
- updateTutZones(tuts)
- commands.async.weather("clear",10000)
- local resetbutton = redstone.getInput("left")
- if resetbutton then
- print("reset!")
- resetAllTutorials()
- end
- sleep(2)
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement