Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- -- the computers coordinates
- x = -111
- y = 75
- z = 61
- flag = 0
- rand = math.random(1,20)
- -- this is important for knowing where to place the minigame.
- function shell()
- commands.exec("/fill ~-1 ~1 ~11 ~-23 ~4 ~-10 bedrock")
- commands.exec("/fill ~-3 ~2 ~10 ~-22 ~3 ~-9 air")
- end
- function delshell()
- commands.exec("/fill ~-1 ~1 ~11 ~-23 ~4 ~-10 air")
- end
- function gen()
- --count = 0
- tnarr = {}
- -- stone 1 = 1pt
- -- iron 2 = 2pts
- -- gold 3 = 5pts
- -- lapis 4 = 10pts
- -- emerald 5 = 50pts
- -- diamond 6 = 50pts
- for k=0,1,1 do -- y coordinates
- tnarr[k] = {}
- for j=0,19,1 do -- z coordinates
- tnarr[k][j] = {}
- for i=0,19,1 do -- x coordinates
- tnarr[k][j][i] = 0
- if rand < 12 then
- commands.exec("/setblock " .. x - 2 - i .. " " .. y + k .. " " .. z - j .. " stone")
- tnarr[k][j][i] = 1
- elseif rand > 11 and rand < 15 then
- commands.exec("/setblock " .. x - 2 - i .. " " .. y + k .. " " .. z - j .. " iron_block")
- tnarr[k][j][i] = 2
- elseif rand > 14 and rand < 17 then
- commands.exec("/setblock " .. x - 2 - i .. " " .. y + k .. " " .. z - j .. " gold_block")
- tnarr[k][j][i] = 3
- elseif rand > 16 and rand < 19 then
- commands.exec("/setblock " .. x - 2 - i .. " " .. y + k .. " " .. z - j .. " lapis_block")
- tnarr[k][j][i] = 4
- elseif rand == 19 then
- commands.exec("/setblock " .. x - 2 - i .. " " .. y + k .. " " .. z - j .. " emerald_block")
- tnarr[k][j][i] = 5
- else
- commands.exec("/setblock " .. x - 2 - i .. " " .. y + k .. " " .. z - j .. " diamond_block")
- tnarr[k][j][i] = 6
- end
- rand = math.random(1,20)
- --count = count + 1
- end
- end
- end
- --print(count .. " count")
- end
- function playertp(mflag)
- if mflag == 0 then
- commands.exec("/tp @p " .. x-1 .. " " .. y .. " " .. z-8)
- parallel.waitForAny(function() time(60) end,killm)
- elseif mflag == 1 then
- commands.exec("/tp @p " .. x+2 .. " " .. y .. " " .. z-8)
- commands.exec("/w @p Counting up your score, please wait.")
- scoring()
- end
- end
- function time(time) -- number of seconds the game lasts
- --time = 6
- while time > 0 do
- sleep(1)
- time = time - 1
- if time == 5 then
- commands.exec("/w @p Minigame ends in 5...")
- elseif time < 5 and time > 0 then
- commands.exec("/w @p " .. time .. "...")
- end
- end
- commands.exec("/w @p Time's up!")
- playertp(1)
- end
- function killm() -- prevents drops and monsters in area
- while 1 do
- commands.exec("/kill @e[type=item,x=" .. x-10 .. ",y=" .. y .. ",z=" .. z-10 .. ",r=20]")
- commands.exec("/tp @e[type=Skeleton,x=" .. x-10 .. ",y=" .. y .. ",z=" .. z-10 .. ",r=20]")
- commands.exec("/tp @e[type=Zombie,x=" .. x-10 .. ",y=" .. y .. ",z=" .. z-10 .. ",r=20]")
- end
- end
- function scoring()
- score = 0
- st = 0
- ir = 0
- go = 0
- la = 0
- em = 0
- di = 0
- for n=0,1,1 do
- for m=0,19,1 do
- for l=0,19,1 do
- if commands.exec("/testforblock " .. x - 2 - l .. " " .. y + n .. " " .. z - m .. " air") then
- print(tnarr[n][m][l])
- if tnarr[n][m][l] == 1 then
- score = score + 1
- st = st + 1
- elseif tnarr[n][m][l] == 2 then
- score = score + 2
- ir = ir + 1
- elseif tnarr[n][m][l] == 3 then
- score = score + 5
- go = go + 1
- elseif tnarr[n][m][l] == 4 then
- score = score + 10
- la = la + 1
- elseif tnarr[n][m][l] == 5 then
- score = score + 50
- em = em + 1
- elseif tnarr[n][m][l] == 6 then
- score = score + 50
- di = di + 1
- end
- bmined = st + ir + go + la + em + di
- end
- end
- end
- end
- commands.exec("/w @p You scored " .. score .. " points!")
- commands.exec("/w @p You mined " .. bmined .. " blocks!")
- commands.exec("/w @p Stone: " .. st .. " Iron: " .. ir .. " Gold: " .. go .. " Lapis: " .. la .. " Emerald: " .. em .. " Diamond: " .. di)
- end
- function clear()
- commands.exec("/fill ".. x-2 .. " " .. y .. " " .. z .. " " .. x-21 .. " " .. y+1 .. " " .. z-19 .." air")
- end
- shell() --for shell generation when computer moved
- --testforblock should be true after testing.
- --if commands.exec("/testforblock ") == false and flag == 0 then
- -- flag = 1
- --commands.exec("/w @p Please wait for minigame to generate.")
- -- gen() -- creates a 20x20 mine
- -- commands.exec("/w @p Minigame begins in 3...")
- -- sleep(1)
- -- commands.exec("/w @p 2...")
- -- sleep(1)
- -- commands.exec("/w @p 1...")
- -- sleep(1)
- -- commands.exec("/w @p Start!")
- -- playertp(0)
- -- flag = 0
- --end
- --sleep(5)
- --clear() -- hope it doesnt delete the world
- --delshell()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement