Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local VERSION = '0.1.0 - rewards and messages match the actual game'
- print("Starting 20.000 Blocks Tutorial")
- commands.scoreboard("objectives","add","tut_state","dummy")
- DEBUG_MODE = false
- local ox,oy,oz = commands.getBlockPosition()
- NUMBER_OF_TUT_ZONES = 3
- WALL_THICKNESS = 2 -- the thickness of the walls between the tutorial zones
- REFRESH_ZONE = {
- x=12317,
- y=55,
- z=-1796,
- w=17,
- l=59,
- h=12
- }
- INCOMING_ZONE = {
- x=12370,
- y=69,
- z=-1716,
- w=3,
- l=3,
- h=3
- }
- OUTGOING_POINT = {
- x=12314,
- y=56,
- z=-1774,
- a=90,
- b=0
- }
- START_POINT_OFFSET = { --this is the offset of starting point for each tutorial zone from the zone's origin
- x=64,
- y=1,
- z=14
- }
- WELCOME_AREA = {
- x=12477,
- y=87,
- z=-1826,
- r1=0,
- r2=0
- }
- PLAY_AREA = {
- x=12113,
- y=57,
- z=-1777,
- r1=90,
- r2=0
- }
- TUT_WAIT_AREA = {
- x=12381,
- y=69,
- z=-1716,
- r1=115,
- r2=0
- }
- TUT_TIMEOUT_SECONDS = 600
- NUMBER_OF_VOCAB = 10
- VOCAB_LOCATION = {
- x=-60,
- y=57,
- z=-107
- }
- VOCAB_WIDTH = 27
- VOCAB_HEIGHT = 19
- TUTORIAL_VOCABS = {1,2,3,4,9,10,11,12,37,38,39,40,25,26,27,28}
- 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 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
- PICKAXE_USES = 40
- pickaxe = 'stone_pickaxe 1 '..131-PICKAXE_USES..' {CanDestroy:["'..BLOCKS.BUILDING_HOUSE.block..'"],display:{Name:"Resource Remover",Lore:[Use the pickaxe to remove up to '..PICKAXE_USES..' resource blocks]}}'
- STARTING_ITEMS = {
- houseBlock(10), gardenBlock(10),pickaxe
- }
- 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] = gardenBlock(3)
- REWARDS[14] = gardenBlock(3)
- REWARDS[15] = gardenBlock(3)
- REWARDS[16] = gardenBlock(3)
- --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(4)
- REWARDS[38] = houseBlock(4)
- REWARDS[39] = houseBlock(4)
- REWARDS[40] = houseBlock(4)
- --]]
- 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'
- }
- --]]
- VOCABS_DATA = {
- -- urban houses
- {id=1, column=1, row=1,nameEN="SINGLE-FAMILY-HOUSE",nameDE="EINFAMILIENHAUS", typeEN="HOUSES",typeDE="HÄUSER",height=10, slots=2, green=false, greenSlots=0, rewardUrban=false, rewardCount=4},
- {id=2, column=1, row=2,nameEN="SINGLE-FAMILY-HOUSE",nameDE="EINFAMILIENHAUS", typeEN="HOUSES",typeDE="HÄUSER",height=10, slots=2, green=false, greenSlots=0, rewardUrban=false, rewardCount=4},
- {id=3, column=1, row=3,nameEN="SINGLE-FAMILY-HOUSE",nameDE="EINFAMILIENHAUS", typeEN="HOUSES",typeDE="HÄUSER",height=10, slots=2, green=false, greenSlots=0, rewardUrban=false, rewardCount=4},
- {id=4, column=1, row=4,nameEN="SINGLE-FAMILY-HOUSE",nameDE="EINFAMILIENHAUS", typeEN="HOUSES",typeDE="HÄUSER",height=10, slots=2, green=false, greenSlots=0, rewardUrban=false, rewardCount=4},
- -- urban businesses
- {id=5, column=2, row=1,nameEN="GYM",nameDE="FITNESSSTUDIO", typeEN="BUSINESSES",typeDE="GESCHÄFTE",height=20, slots=5, green=false, greenSlots=0, rewardUrban=false, rewardCount=8},
- {id=6, column=2, row=2,nameEN="OFFICE-BUILDING",nameDE="BÜROGEBÄUDE", typeEN="BUSINESSES",typeDE="GESCHÄFTE",height=20, slots=5, green=false, greenSlots=0, rewardUrban=false, rewardCount=8},
- {id=7, column=2, row=3,nameEN="HOTEL",nameDE="HOTEL", typeEN="BUSINESSES",typeDE="GESCHÄFTE",height=20, slots=5, green=false, greenSlots=0, rewardUrban=false, rewardCount=8},
- {id=8, column=2, row=4 ,nameEN="BANK",nameDE="BANK", typeEN="BUSINESSES",typeDE="GESCHÄFTE",height=20, slots=5, green=false, greenSlots=0, rewardUrban=false, rewardCount=8},
- -- urban tech&science spaces
- {id=9, column=3, row=1,nameEN="LIBRARY",nameDE="BIBLIOTHEK", typeEN="TECH & SCIENCE SPACES",typeDE="WISSENSCHAFTSGEBÄUDE",height=16, slots=1, green=false, greenSlots=0, rewardUrban=false, rewardCount=10},
- {id=10, column=3, row=2,nameEN="FABLAB",nameDE="INNOVATIONSZENTRUM", typeEN="TECH & SCIENCE SPACES",typeDE="WISSENSCHAFTSGEBÄUDE",height=16, slots=1, green=false, greenSlots=0, rewardUrban=false, rewardCount=10},
- -- green tech&science spaces
- {id=11, column=3, row=3,nameEN="AQUAPONIC-GREENHOUSE",nameDE="AQUAPONIK-GEWÄCHSHAUS", typeEN="TECH & SCIENCE SPACES",typeDE="WISSENSCHAFTSGEBÄUDE",height=16, slots=1, green=true, greenSlots=1, rewardUrban=true, rewardCount=10},
- {id=12, column=3, row=4,nameEN="SCIENCE-BRIDGE",nameDE="WISSENSCHAFTSBRÜCKE", typeEN="TECH & SCIENCE SPACES",typeDE="WISSENSCHAFTSGEBÄUDE",height=16, slots=1, green=true, greenSlots=1, rewardUrban=true, rewardCount=10},
- -- urban house extensions
- {id=13, column=4, row=1,nameEN="HOUSE-EXTENSION",nameDE="HAUSERWEITERUNG", typeEN="EXTENSIONS",typeDE="ERWEITERUNGEN",height=10, slots=1, green=false, greenSlots=0, rewardUrban=false, rewardCount=6},
- {id=14, column=4, row=2,nameEN="HOUSE-EXTENSION",nameDE="HAUSERWEITERUNG", typeEN="EXTENSIONS",typeDE="ERWEITERUNGEN",height=10, slots=1, green=false, greenSlots=0, rewardUrban=false, rewardCount=6},
- {id=15, column=4, row=3,nameEN="HOUSE-EXTENSION",nameDE="HAUSERWEITERUNG", typeEN="EXTENSIONS",typeDE="ERWEITERUNGEN",height=10, slots=1, green=false, greenSlots=0, rewardUrban=false, rewardCount=6},
- {id=16, column=4, row=4,nameEN="HOUSE-EXTENSION",nameDE="HAUSERWEITERUNG", typeEN="EXTENSIONS",typeDE="ERWEITERUNGEN",height=10, slots=1, green=false, greenSlots=0, rewardUrban=false, rewardCount=6},
- --risers
- {id=17, column=5, row=1,nameEN="DOUBLE-FLOOR-RISER",nameDE="VERSCHIEBUNG-ZWEI-HOCH", typeEN="RISERS",typeDE="VERTIKALE VERSCHIEBUNGEN",height=0, slots=0, green=false, greenSlots=0, rewardUrban=true, rewardCount=8},
- {id=18, column=5, row=2,nameEN="SINGLE-FLOOR-RISER",nameDE="VERSCHIEBUNG-EINEN-HOCH", typeEN="RISERS",typeDE="VERTIKALE VERSCHIEBUNGEN",height=0, slots=0, green=false, greenSlots=0, rewardUrban=true, rewardCount=6},
- --plazas
- {id=19, column=5, row=3,nameEN="CITY-PLAZA",nameDE="STÄDTISCHER PLATZ", typeEN="PLAZAS",typeDE="PLÄTZE",height=0, slots=0, green=false, greenSlots=0, rewardUrban=false, rewardCount=2},
- {id=20, column=5, row=4,nameEN="PARK-PLAZA",nameDE="GRÜNER PLATZ", typeEN="PLAZAS",typeDE="PLÄTZE",height=0, slots=0, green=true, greenSlots=1, rewardUrban=true, rewardCount=2},
- --green businesses
- {id=21, column=6, row=1,nameEN="GREEN-GYM",nameDE="GRÜNES FITNESSSTUDIO", typeEN="BUSINESSES",typeDE="GESCHÄFTE",height=20, slots=5, green=true, greenSlots=5, rewardUrban=true, rewardCount=8},
- {id=22, column=6, row=2,nameEN="GREEN-OFFICE-BUILDING",nameDE="GRÜNES BÜROGEBÄUDE", typeEN="BUSINESSES",typeDE="GESCHÄFTE",height=20, slots=5, green=true, greenSlots=5, rewardUrban=true, rewardCount=8},
- {id=23, column=6, row=3,nameEN="GREEN-HOTEL",nameDE="GRÜNES HOTEL", typeEN="BUSINESSES",typeDE="GESCHÄFTE",height=20, slots=5, green=true, greenSlots=5, rewardUrban=true, rewardCount=8},
- {id=24, column=6, row=4,nameEN="GREEN-BANK",nameDE="GRÜNES BANK", typeEN="BUSINESSES",typeDE="GESCHÄFTE",height=20, slots=5, green=true, greenSlots=5, rewardUrban=true, rewardCount=8},
- ---green private garden extensions
- {id=25, column=7, row=1,nameEN="HOUSE-GARDEN",nameDE="PRIVATGARTEN", typeEN="EXTENSIONS",typeDE="ERWEITERUNGEN",height=0, slots=0, green=true, greenSlots=1, rewardUrban=true, rewardCount=6},
- {id=26, column=7, row=2,nameEN="HOUSE-GARDEN",nameDE="PRIVATGARTEN", typeEN="EXTENSIONS",typeDE="ERWEITERUNGEN",height=0, slots=0, green=true, greenSlots=1, rewardUrban=true, rewardCount=6},
- {id=27, column=7, row=3,nameEN="HOUSE-GARDEN",nameDE="PRIVATGARTEN", typeEN="EXTENSIONS",typeDE="ERWEITERUNGEN",height=0, slots=0, green=true, greenSlots=1, rewardUrban=true, rewardCount=6},
- {id=28, column=7, row=4,nameEN="HOUSE-GARDEN",nameDE="PRIVATGARTEN", typeEN="EXTENSIONS",typeDE="ERWEITERUNGEN",height=0, slots=0, green=true, greenSlots=1, rewardUrban=true, rewardCount=6},
- ---green gathering spaces
- {id=29, column=8, row=1,nameEN="OPEN-АIR-CINEMA",nameDE="FREILUFTKINO", typeEN="GATHERING SPACES",typeDE="TREFFPUNKTE",height=8, slots=3, green=true, greenSlots=3, rewardUrban=true, rewardCount=9},
- {id=30, column=8, row=2,nameEN="OPEN-AIR-SWIMMING-POOL",nameDE="FREIBAD", typeEN="GATHERING SPACES",typeDE="TREFFPUNKTE",height=8, slots=3, green=true, greenSlots=3, rewardUrban=true, rewardCount=9},
- {id=31, column=8, row=3,nameEN="GREEN-CAFE",nameDE="GRÜNES CAFÉ", typeEN="GATHERING SPACES",typeDE="TREFFPUNKTE",height=8, slots=3, green=true, greenSlots=3, rewardUrban=true, rewardCount=9},
- {id=32, column=8, row=4,nameEN="PALM-TREE-HOUSE",nameDE="PALMENGARTEN", typeEN="GATHERING SPACES",typeDE="TREFFPUNKTE",height=8, slots=3, green=true, greenSlots=3, rewardUrban=true, rewardCount=9},
- ----urban gathering spaces
- {id=33, column=9, row=1,nameEN="CINEMA",nameDE="KINO", typeEN="GATHERING SPACES",typeDE="TREFFPUNKTE",height=8, slots=3, green=false, greenSlots=0, rewardUrban=false, rewardCount=9},
- {id=34, column=9, row=2,nameEN="CONFERENCE-HALL",nameDE="KONFERENZHALLE", typeEN="GATHERING SPACES",typeDE="TREFFPUNKTE",height=8, slots=3, green=false, greenSlots=0, rewardUrban=false, rewardCount=9},
- {id=35, column=9, row=3,nameEN="CAFÉ",nameDE="CAFÉ", typeEN="GATHERING SPACES",typeDE="TREFFPUNKTE",height=8, slots=3, green=false, greenSlots=0, rewardUrban=false, rewardCount=9},
- {id=36, column=9, row=4,nameEN="ART-GALLERY",nameDE="KUNSTGALERIE", typeEN="GATHERING SPACES",typeDE="TREFFPUNKTE",height=8, slots=3, green=false, greenSlots=0, rewardUrban=false, rewardCount=9},
- ---green-roof houses
- {id=37, column=10, row=1,nameEN="GREEN-ROOF-HOUSE",nameDE="GRÜNES EINFAMILIENHAUS", typeEN="HOUSES",typeDE="HÄUSER",height=10, slots=2, green=true, greenSlots=2, rewardUrban=true, rewardCount=4},
- {id=38, column=10, row=2,nameEN="GREEN-ROOF-HOUSE",nameDE="GRÜNES EINFAMILIENHAUS", typeEN="HOUSES",typeDE="HÄUSER",height=10, slots=2, green=true, greenSlots=2, rewardUrban=true, rewardCount=4},
- {id=39, column=10, row=3,nameEN="GREEN-ROOF-HOUSE",nameDE="GRÜNES EINFAMILIENHAUS", typeEN="HOUSES",typeDE="HÄUSER",height=10, slots=2, green=true, greenSlots=2, rewardUrban=true, rewardCount=4},
- {id=40, column=10, row=4,nameEN="GREEN-ROOF-HOUSE",nameDE="GRÜNES EINFAMILIENHAUS", typeEN="HOUSES",typeDE="HÄUSER",height=10, slots=2, green=true, greenSlots=2, rewardUrban=true, rewardCount=4},
- }
- --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
- --vocab constructor. Enforces some data structure
- function newVocabZone(x,y,z,w,id, reward,nameEN, nameDE, typeEN, typeDE, height, slots,green,greenSlots, rewardUrban, rewardCount)
- local nvz = {}
- nvz.x ,nvz.y ,nvz.z ,nvz.w = x,y,z,w
- nvz.cx = nvz.x - nvz.w - 2
- nvz.cy = nvz.y
- nvz.cz = nvz.z
- nvz.nameEN = nameEN
- nvz.reward = reward
- --- new stuff
- nvz.id = id
- nvz.nameDE = nameDE
- nvz.typeEN = typeEN
- nvz.typeDE = typeDE
- nvz.height = height
- nvz.slots = slots
- nvz.green = green
- nvz.greenSlots = greenSlots
- nvz.rewardUrban = rewardUrban
- nvz.rewardCount = rewardCount
- return nvz
- end
- --a multi builder which uses the vocab constructor to create sets of vocab
- local function makeVocabZones(quant,w)
- local x,y,z = VOCAB_LOCATION.x, VOCAB_LOCATION.y, VOCAB_LOCATION.z
- local result = {}
- local id = 1
- for i=0,quant-1 do
- for k=0,3 do
- local zpos = i-4
- local ypos = k
- --print("vocab at X")
- --print(x-(2*w)-6)
- --print("and Z")
- --print(z+((w+1)*zpos))
- local nextVocab = newVocabZone(
- x-(2*w)-6,y+(ypos*(VOCAB_HEIGHT+3)),
- z+((w+1)*zpos),
- w,
- id,
- REWARDS[id] or DEFAULT_REWARD,
- VOCABS_DATA[id].nameEN or DEFAULT_NAME,
- VOCABS_DATA[id].nameDE or DEFAULT_NAME,
- VOCABS_DATA[id].typeEN,
- VOCABS_DATA[id].typeDE,
- VOCABS_DATA[id].height,
- VOCABS_DATA[id].slots,
- VOCABS_DATA[id].green,
- VOCABS_DATA[id].greenSlots,
- VOCABS_DATA[id].rewardUrban,
- VOCABS_DATA[id].rewardCount
- )
- table.insert(result,nextVocab)
- id = id +1
- end
- end
- return result
- 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
- local function printall(text,zone)
- local text = text..": "
- for i,_ in pairs(zone) do
- if i == "waitingForCheck" then
- text = text..i..", "
- end
- end
- --print(text)
- 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.endtime = nil
- ntz.waitingForCheck = {}
- ntz.player = nil
- ntz.clean = false
- ntz.vocab = vocabZones
- printall("New zone",ntz)
- sleep(1)
- 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
- --gives the same list of items to a list of players
- local function giveItems(playerlist,itemlist)
- local given = 0
- for i,player in ipairs(playerlist) do
- --commands.async.clear(player.name)
- for j,item in ipairs(itemlist) do
- commands.async.give("@a[name="..player.name.."]",item)
- given = given +1
- end
- --giveHomecomer(player.name)
- end
- return given
- 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+START_POINT_OFFSET.x,zone.y+START_POINT_OFFSET.y,zone.z+START_POINT_OFFSET.z,90,0)
- if result then
- local player = getNameFromMessage(msg[1])
- commands.spawnpoint(player.name,TUT_WAIT_AREA.x,TUT_WAIT_AREA.y,TUT_WAIT_AREA.z,TUT_WAIT_AREA.r1,TUT_WAIT_AREA.r2)
- local result,msg = commands.scoreboard("players","set",player.name,"tut_state",1)
- zone.player = player
- commands.clear(player.name)
- giveItems({player},STARTING_ITEMS) --give starting items
- zone.endtime = os.clock()+TUT_TIMEOUT_SECONDS
- end
- end
- --check for victory and tp players out
- local function checkVictoryAndExit(zone)
- --commands.tell(zone.player.name,"Doing Victory section")
- local victory_length = 2
- local endzone_selector = "@p[name="..zone.player.name..",x="..zone.x..",y="..(zone.y+6)..",z="..(zone.z+math.floor(REFRESH_ZONE.w/2))..",dx="..victory_length..",dy="..REFRESH_ZONE.h..",dz="..REFRESH_ZONE.w.."]"
- local result,msg = commands.tp(endzone_selector,OUTGOING_POINT.x,OUTGOING_POINT.y,OUTGOING_POINT.z,OUTGOING_POINT.a,OUTGOING_POINT.b)
- if result then
- zone.clean = false
- commands.spawnpoint(zone.player.name,PLAY_AREA.x,PLAY_AREA.y,PLAY_AREA.z,PLAY_AREA.r1,PLAY_AREA.r2)
- commands.scoreboard("players","set",zone.player.name,"tut_state",2)
- commands.tell(zone.player.name,"You completed the Tutorial")
- commands.clear(zone.player.name)
- zone.player = nil
- elseif os.clock() > zone.endtime then
- zone.clean = false
- commands.tell(zone.player.name,"The tutorial timed out")
- local zone_select = "@p[name="..zone.player.name..",x="..zone.x..",y="..zone.y..",z="..zone.z..",dx="..REFRESH_ZONE.l..",dy="..REFRESH_ZONE.h..",dz="..REFRESH_ZONE.w.."]"
- commands.tp(zone_select,TUT_WAIT_AREA.x,TUT_WAIT_AREA.y,TUT_WAIT_AREA.z,TUT_WAIT_AREA.r1,TUT_WAIT_AREA.r2)
- commands.clear(zone.player)
- zone.player = nil
- end
- 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
- --returns a list of player objects containing all players who are standing on the given block, and who also are in the given selection
- local function getAllOnBlockType(block,selector)
- local result, message = commands.exec("execute @a["..selector.."] ~ ~ ~ detect ~ ~-1 ~ "..block.." -1 tp @p[r=1] ~ ~ ~")
- local names = {}
- if result == true then
- for i,result in ipairs(message) do
- local wordpattern = "[^, ]+"
- local numberpattern = "[%-% ]%d+[%.]%d+"
- local words,numbers = {},{}
- for word in string.gmatch(result, wordpattern) do table.insert(words,word) end
- for number in string.gmatch(result, numberpattern) do table.insert(numbers,number) end
- if numbers[1] and numbers[2] and numbers[3] then
- local coords = {
- x = math.floor(numbers[1]),
- y = math.floor(numbers[2]),
- z = math.floor(numbers[3])
- }
- local name = words[2]
- table.insert(names,newPlayerData(name,coords.x,coords.y,coords.z))
- --print("Found a player - getOnBlock")
- else
- --print("Error: Coordinate Numbers were missing")
- end
- end
- end
- return names
- end
- --makes sure that incoming check requests dont exist already
- function addToChecklist(player,zone)
- for _, detector in ipairs(zone.waitingForCheck) do
- if detector.x == player.x and detector.y == player.y and detector.z == player.z then
- printall("before return false",zone)
- return false
- end
- end
- printall("before table add",zone)
- table.insert(zone.waitingForCheck,player)
- return true
- end
- --removed all barrier blocks from a buildzone which are used to carve space in vocabs
- function cleanBarriers(buildzone)
- for h=0,50 do
- commands.async.fill(buildzone.x,buildzone.y+h,buildzone.z,buildzone.x+REFRESH_ZONE.w,buildzone.y+h,buildzone.z+REFRESH_ZONE.l,"minecraft:air",0,"replace","minecraft:barrier")
- end
- end
- --The main chunk of code which deals with stepping on detector blocks and reading the vocab. Modified for tutorial
- function doVocabGameplay(zone)
- local selector = "x="..zone.x..",y="..(zone.y-5)..",z="..zone.z..",dx="..REFRESH_ZONE.l..",dy="..REFRESH_ZONE.h..",dz="..REFRESH_ZONE.w
- local victory = false
- --get all players on diamond, add them to the list of things to check
- local detectLocations = getAllOnBlockType(BLOCKS.DETECT.block,selector)
- for _, player in ipairs(detectLocations) do
- addToChecklist(player,zone)
- end
- --if zone and zone.waitingForCheck then print("found waiting for check") else print("found nothing") end
- --DEAL WITH THE DETECTOR AT THE TOP OF THE LIST IF THERE IS ONE
- if #zone.waitingForCheck > 0 then
- --DO PARTICLE EFFECTS IF A DETECTING BLOCK THAT IS DETECTING
- for i,loc in ipairs(zone.waitingForCheck) do
- searchParticle(loc.x,loc.y+1,loc.z)
- end
- local totalResult = false
- local checked = table.remove(zone.waitingForCheck,1)
- local x,y,z,name = checked.x,checked.y,checked.z,checked.name
- for i,vocab in pairs(zone.vocab) do
- local vx,vy,vz,vx1,vy1,vz1 = vocab.x, vocab.y, vocab.z, vocab.x+vocab.w, vocab.y+VOCAB_HEIGHT, vocab.z+vocab.w
- local dx,dy,dz = x-math.floor(vocab.w/2),y-1,z-math.floor(vocab.w/2)
- --print("Comparing "..vx..","..vy..","..vz.." with "..dx..","..dy..","..dz)
- local result,message = commands.testforblocks(vx,vy,vz,vx1,vy1,vz1,dx,dy,dz,"masked")
- --print(message[1])
- if result then
- --clone in the correct vocab
- local cloneres,clonemes = commands.clone(vocab.cx,vocab.cy,vocab.cz,vocab.cx+vocab.w,vocab.cy+VOCAB_HEIGHT,vocab.cz+vocab.w,x-math.floor(vocab.w/2),y-1,z-math.floor(vocab.w/2),"masked")
- if DEBUG_MODE then
- print(clonemes[1])
- end
- commands.async.give(name,vocab.reward)
- -- announce vocab success in English
- local rewardType = 'nature'
- local rewardTypeDE = 'grüne'
- if vocab.rewardUrban then
- rewardType = 'urban'
- rewardTypeDE = 'urbane'
- end
- commands.async.tellraw(name,'["",{"text":"You built a '..vocab.nameEN.. ' ('..vocab.typeEN..'), which is '..vocab.height..'m tall and gives '..vocab.slots..' density pts, '..vocab.greenSlots..' green pts and '..vocab.rewardCount..'x '..rewardType..' resource!","color":"white"}]')
- -- announce vocab success in German
- commands.async.tellraw(name,'["",{"text":"Du hast ein '..vocab.typeDE..' | '..vocab.nameDE.. ' gebaut, das '..vocab.height..' Meter hoch ist und dir '..vocab.slots..' Punkte für die Dichte einbringt, jedoch '..vocab.greenSlots..' Punkte für Grünflächen und '..vocab.rewardCount..' '..rewardTypeDE..' Ressourcen!","color":"gold"}]')
- --clear out barrier blocks
- cleanBarriers(zone)
- totalResult = true
- break
- end
- end
- if totalResult then
- --yey win, do a happy time
- successParticle(x,y,z)
- else
- --no vocab found so do a fail particle
- --announce in English
- commands.async.tellraw(name,'["",{"text":"The shape you have built does not match any shape in the catalogue, try a different one.","color":"red"}]')
- -- announce in German
- commands.async.tellraw(name,'["",{"text":"Die Kombination, die du gebaut hast passt leider zu keinem Gebäude, versuche es mit einer anderen Form.","color":"gold"}]')
- failParticle(x,y-1,z)
- end
- end
- return victory
- end
- --do all logic for tutzones
- local function updateTutZones(tuts)
- --all empty zones check for players and get if available
- for index,zone in ipairs(tuts.zones) do
- if zone.player == nil then
- printall("fill zone "..index,zone)
- checkAndFill(zone)
- end
- end
- --all zones with player, check vocab update
- for index,zone in ipairs(tuts.zones) do
- if zone.player then
- printall("gameplay "..index,zone)
- doVocabGameplay(zone)
- end
- end
- --all zones with players check for victory and tp players out
- for index,zone in ipairs(tuts.zones) do
- if zone.player then
- printall("exit "..index,zone)
- checkVictoryAndExit(zone)
- end
- end
- --all empty zones which need cleaning are cleaned up
- for index,zone in ipairs(tuts.zones) do
- if zone.clean == false then
- printall("clean "..index,zone)
- cleanZone(zone)
- end
- end
- end
- --setup a new tuts object
- local function setup()
- local tuts = {}
- tuts.zones = {}
- --generate vocab rewards
- for i=1,#VOCABS_DATA do
- if VOCABS_DATA[i].rewardUrban then
- REWARDS[i] = houseBlock(VOCABS_DATA[i].rewardCount)
- else
- REWARDS[i] = gardenBlock(VOCABS_DATA[i].rewardCount)
- end
- end
- tuts.vocabs = makeVocabZones(VOCAB_LOCATION.x,VOCAB_LOCATION.y,VOCAB_LOCATION.z,NUMBER_OF_VOCAB,VOCAB_WIDTH)
- --print(type(tuts.vocabs),#tuts.vocabs)
- local rz = REFRESH_ZONE
- --local vocab_subset = {}
- --for i=1, 40 in ipairs(TUTORIAL_VOCABS) do
- -- table.insert(vocab_subset,tuts.vocabs[value])
- --end
- for index = 1, NUMBER_OF_TUT_ZONES do
- local newZone = newTutZone(rz.x,rz.y,rz.z+(index*(rz.w+1+WALL_THICKNESS)),tuts.vocabs)
- 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
- local symbols = {
- "(X) ",
- "(-) "
- }
- local spin = 1
- --BEGIN RUNTIME CODE
- local blink = true
- local tuts = setup()
- while true do
- if not DEBUG_MODE then
- term.clear()
- print("Controlling Tutorial "..symbols[spin])
- spin = spin +1
- if spin > #symbols then spin = 1 end
- end
- updateTutZones(tuts)
- commands.async.weather("clear",10000)
- local resetbutton = redstone.getInput("left")
- if resetbutton then
- print("reset!")
- resetAllTutorials()
- end
- sleep(0.5)
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement