Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- --- xXm0dzXx Default Programming API ---
- -- All my programs will have this :DD --
- ----------------------------------------
- if not term.isColor() then
- error("You need a advanced compootah to play dis game!")
- end
- local x,y = term.getSize()
- local function cPrint( txt ) --Version 2.0 of cPrint
- local function printC( text )
- x2,y2 = term.getCursorPos()
- term.setCursorPos(math.ceil((x / 2) - (text:len() / 2)), y2)
- write(text.. "\n")
- end
- if type(txt) == "string" then
- printC( txt )
- elseif type(txt) == "table" then
- for i=1,#txt do
- printC( txt[i] )
- end
- end
- end
- local drawingBoard = {
- ["A"] = colors.white,
- ["B"] = colors.orange,
- ["C"] = colors.magenta,
- ["D"] = colors.lightBlue,
- ["E"] = colors.yellow,
- ["F"] = colors.lime,
- ["G"] = colors.pink,
- ["H"] = colors.gray,
- ["I"] = colors.lightGray,
- ["J"] = colors.cyan,
- ["K"] = colors.purple,
- ["L"] = colors.blue,
- ["M"] = colors.brown,
- ["N"] = colors.green,
- ["O"] = colors.red,
- ["P"] = colors.black,
- }
- local function advWrite( pos1, pos2, str )
- for i=1,#str do
- local symb = drawingBoard[ string.sub( str, i, i) ]
- term.setCursorPos( pos1 + (i-1) , pos2 )
- if symb then
- term.setBackgroundColour( symb )
- write(" ")
- end
- end
- end
- local function setBG( col, colz )
- term.setBackgroundColour( col )
- term.clear()
- term.setCursorPos(1,1)
- term.setTextColour( colz )
- end
- local function getLines( path )
- local tLines = {}
- local file = fs.open( path, "r" )
- if file then
- line = file.readLine()
- while line do
- tLines[ #tLines+1 ] = line
- line = file.readLine()
- end
- file.close()
- end
- return tLines
- end
- -- End of API --
- local playedIntro = false
- local skipIntro = false
- local _sIntro = 0
- function introSleep( timah )
- if skipIntro ~= true then -- theres also == false and not skipIntro
- dahtim = os.startTimer(timah)
- event, key = os.pullEvent()
- if event == "key" then
- if key ~= 1 then
- skipIntro = true
- end
- end
- end
- end
- function slideUp()
- local x,y = term.getSize()
- term.scroll(1)
- term.setCursorPos( 1, y-1 )
- for i=1,x do
- write("-")
- end
- introSleep(0)
- for i=1,y do
- term.scroll(1)
- introSleep(0)
- end
- for i=1,y * 3 do
- term.scroll(1)
- for i=1, math.random(1, 3) do
- if math.random( 1, 3 ) == 3 then
- term.setCursorPos( math.random( 1, x ), y )
- term.setTextColour( colors.white )
- write("*")
- end
- end
- introSleep(0)
- end
- for i=1,y*2 do
- term.setBackgroundColour( colors.blue )
- term.scroll(1)
- if i <= y / 2 then
- for i=1, math.random(1, 3) do
- if math.random( 1, 5 ) == 3 then
- term.setCursorPos( math.random( 1, x ), y )
- term.setTextColour( colors.white )
- write("*")
- end
- end
- end
- introSleep(0)
- end
- for i=1,y*4-(y-3) do
- if i == y*3 then
- term.setBackgroundColour( colors.green )
- elseif i == y*3 + 1 then
- term.setBackgroundColour( colors.brown )
- elseif i >= y*3 + 2 then
- term.setBackgroundColour( colors.gray )
- else
- term.setBackgroundColour( colors.lightBlue )
- end
- term.scroll(1)
- if i == y*2-1 and not playedIntro then
- term.setTextColour( colors.white )
- term.setCursorPos(1, y)
- textutils.slowWrite("CCF11 Presents...")
- sleep(0.5)
- end
- if i >= y*2 and i <= y*3 - 14 then
- for i=1, math.random(3, 8) do
- if math.random( 1, 3 ) == 3 then
- local cloudLength = math.random(2,4)
- term.setCursorPos( math.random( 1, x-cloudLength ), y )
- term.setBackgroundColour( colors.white )
- write( string.rep(" ", cloudLength) )
- end
- end
- if skipIntro and not playedIntro then
- sleep(0)
- end
- end
- introSleep(0)
- end
- end
- function drawMenu()
- slideUp()
- playedIntro = true
- skipIntro = true
- term.setBackgroundColour( colors.lightBlue )
- term.setTextColour( colors.white )
- term.setCursorPos( 1, y/2 - 3 )
- cPrint("Mine-Ception 2.0")
- print()
- term.setBackgroundColour( colors.lightGray )
- cPrint(" Edit Profile ")
- print()
- term.setBackgroundColour( colors.lightGray )
- cPrint(" SinglePlayer ")
- print()
- cPrint(" Multi-Player ")
- print()
- end
- term.setBackgroundColour( colors.black )
- if not fs.exists(".m-ception") then
- fs.makeDir(".m-ception")
- file = fs.open(".m-ception/profile", "w")
- file.writeLine( colors.orange )
- file.writeLine( colors.white )
- file.writeLine(" ")
- file.writeLine( colors.cyan )
- file.writeLine( colors.white )
- file.writeLine(" ")
- file.close()
- end
- drawMenu()
- local _x = 1
- local _y = y-4
- function drawPlayer( x, y )
- term.setCursorPos( x, y-1 )
- file = fs.open(".m-ception/profile", "r")
- term.setBackgroundColour( tonumber( file.readLine() ) )
- term.setTextColour( tonumber( file.readLine() ) )
- write( file.readLine() )
- term.setCursorPos( x, y )
- term.setBackgroundColour( tonumber( file.readLine() ) )
- term.setTextColour( tonumber( file.readLine() ) )
- write( file.readLine() )
- file.close()
- end
- function mainMenu()
- _x = 1
- _y = y-4
- _cloudz = os.startTimer(3)
- _player = os.startTimer(math.random(0,2))
- _gravity = os.startTimer(0)
- playerDragTimer = nil
- local dragPlayer = false
- while true do
- drawPlayer( 3 + _x, _y )
- local event, key, p1, p2 = os.pullEvent()
- if event == "timer" then
- if key == _cloudz then
- drawMenu()
- _cloudz = os.startTimer(3)
- elseif key == _player then
- if not dragPlayer then
- term.setBackgroundColour( colors.lightBlue )
- term.setCursorPos( _x + 3, _y )
- write(" ")
- term.setCursorPos( _x + 3, _y-1 )
- write(" ")
- _x = _x + math.random(-1, 1)
- end
- _player = os.startTimer(math.random(0,2))
- elseif key == playerDragTimer then
- dragPlayer = false
- elseif key == _gravity then
- if not dragPlayer then
- if _y < y-4 then
- term.setCursorPos( _x + 3, _y )
- term.setBackgroundColour( colors.lightBlue )
- write(" ")
- term.setCursorPos( _x + 3, _y-1 )
- write(" ")
- _y = _y +1
- end
- end
- _gravity = os.startTimer(0)
- end
- elseif event == "mouse_click" then
- if key == 1 then
- if p1 == 3 + _x and p2 == _y -1 then
- dragPlayer = true
- else
- dragPlayer = false
- if p2 == y-11 then
- profileEditor( true )
- elseif p2 == y-9 then
- singlePlayer()
- elseif p2 == y-7 then
- end
- end
- end
- elseif event == "mouse_drag" then
- if dragPlayer then
- term.setCursorPos( _x + 3, _y )
- term.setBackgroundColour( colors.lightBlue )
- write(" ")
- term.setCursorPos( _x + 3, _y-1 )
- write(" ")
- _x = p1 - 3
- _y = p2
- playerDragTimer = os.startTimer( 0.5 )
- end
- end
- end
- end
- idonteven = nil
- function singlePlayer()
- fs.makeDir(".m-ception/saves")
- term.setBackgroundColour( colors.gray )
- for i=1,y do
- term.scroll(1)
- sleep(0)
- end
- term.setTextColour( colors.white )
- term.setCursorPos(1,2)
- cPrint("SinglePlayer")
- term.setBackgroundColour( colors.lightGray )
- print()
- cPrint(" World 1 ")
- print()
- cPrint(" World 2 ")
- print()
- cPrint(" World 3 ")
- print()
- cPrint(" World 4 ")
- print()
- cPrint(" World 5 ")
- term.setCursorPos(1, y-1)
- cPrint("Back To Main Menu")
- while true do
- local event, key, p1, p2 = os.pullEvent()
- if event == "mouse_click" then
- if key == 1 then
- if p2 == 2 then
- term.setCursorPos(1, 2)
- term.setBackgroundColour( colors.gray )
- cPrint("*Cough* Loner")
- idonteven = os.startTimer(0.3)
- elseif p2 == 4 then
- loadWorld("world_1")
- elseif p2 == 6 then
- loadWorld("world_2")
- elseif p2 == 8 then
- loadWorld("world_3")
- elseif p2 == 10 then
- loadWorld("world_4")
- elseif p2 == 12 then
- loadWorld("world_5")
- elseif p2 == y-1 then
- drawMenu()
- mainMenu()
- end
- end
- elseif event == "timer" and key == idonteven then
- term.setCursorPos(1, 2)
- term.setBackgroundColour( colors.gray )
- term.clearLine()
- cPrint("SinglePlayer")
- end
- end
- end
- local selection = 1
- function b( num )
- term.setCursorPos( 11, 1 + num )
- if num == selection then
- write("[x] ")
- else
- write("[ ] ")
- end
- end
- function saveChar( p1, p2, p3, p4, p5, p6 )
- fs.delete(".m-ception/profile")
- file = fs.open(".m-ception/profile", "w")
- file.writeLine( p1 )
- file.writeLine( p2 )
- file.writeLine( p3 )
- file.writeLine( p4 )
- file.writeLine( p5 )
- file.writeLine( p6 )
- file.close()
- end
- local s1 = 0
- local s2 = 0
- local s3 = 0
- local s4 = 0
- function profileEditor( scrol )
- if scrol then
- selection = 1
- term.setBackgroundColour( colors.gray )
- for i=1,y do
- term.scroll(1)
- sleep(0)
- end
- end
- for i=2, 8 do
- for j=y/2-3, y/2+2 do
- term.setCursorPos(i, j)
- term.setBackgroundColour( colors.lightBlue )
- if j == y/2+1 then
- term.setBackgroundColour( colors.green )
- elseif j == y/2+2 then
- term.setBackgroundColour( colors.brown )
- end
- write(" ")
- end
- end
- term.setCursorPos(2, y/2+4)
- term.setBackgroundColour( colors.lightGray )
- term.setTextColour( colors.white )
- write(" Leave ")
- drawPlayer( 5, y/2 )
- for i=11, x-1 do
- for j=2, y-1 do
- term.setCursorPos(i, j)
- term.setBackgroundColour( colors.lightGray )
- write(" ")
- end
- end
- term.setTextColor( colours.white )
- file = fs.open(".m-ception/profile", "r")
- local skinColor = ( tonumber( file.readLine() ) )
- local charColor1 = ( tonumber( file.readLine() ) )
- local skinChar = ( file.readLine() )
- local shirtColor = ( tonumber( file.readLine() ) )
- local charColor2 = ( tonumber( file.readLine() ) )
- local shirtChar = ( file.readLine() )
- file.close()
- b(1)
- print("Head Char | " ..skinChar)
- b(2)
- print("Skin Color | " ..skinColor)
- b(3)
- print("Shirt Color | " ..shirtColor)
- b(4)
- print("Shirt Char | " ..shirtChar)
- b(5)
- print("Head Char Color | " ..charColor1)
- b(6)
- print("Shirt Char Color | " ..charColor2)
- b(7)
- print("Randomize Color | ")
- local xx, yy = term.getCursorPos()
- term.setCursorPos( 11, yy )
- term.setBackgroundColour( colors.gray )
- write( string.rep( " ", x-11 ) )
- term.setCursorPos( 11, yy+1 )
- write( string.rep( " ", x-11 ) )
- term.setCursorPos( 11, yy+1 )
- write("Description")
- term.setBackgroundColour( colors.lightGray )
- term.setCursorPos( 11, yy+2 )
- print("Descriptions coming soon...")
- while true do
- event, key, p1, p2 = os.pullEvent()
- if event == "char" or event == "key" then
- if event == "char" and (selection == 1 or selection == 4) then
- if selection == 1 then
- skinChar = key
- elseif selection == 4 then
- shirtChar = key
- end
- saveChar( skinColor, charColor1, skinChar, shirtColor, charColor2, shirtChar )
- else
- if key == keys.up then
- if selection ~= 1 then
- selection = selection -1
- end
- elseif key == keys.down then
- if selection ~= 7 then
- selection = selection +1
- end
- elseif key == keys.enter then
- if selection == 7 then
- fs.delete(".m-ception/profile")
- file = fs.open(".m-ception/profile", "w")
- file.writeLine( 2^math.random(1,15) )
- file.writeLine( 2^math.random(1,15) )
- file.writeLine(skinChar)
- file.writeLine( 2^math.random(1,15) )
- file.writeLine( 2^math.random(1,15) )
- file.writeLine(shirtChar)
- file.close()
- end
- elseif key == keys.left then
- if selection == 2 then
- if s1 ~= 0 then
- s1 = s1 -1
- end
- saveChar( 2 ^ s1, charColor1, skinChar, shirtColor, charColor2, shirtChar )
- elseif selection == 5 then
- if s2 ~= 0 then
- s2 = s2 -1
- end
- saveChar( skinColor, 2 ^ s2, skinChar, shirtColor, charColor2, shirtChar )
- elseif selection == 3 then
- if s3 ~= 0 then
- s3 = s3 -1
- end
- saveChar( skinColor, charColor1, skinChar, 2 ^ s3, charColor2, shirtChar )
- elseif selection == 6 then
- if s4 ~= 0 then
- s4 = s4 -1
- end
- saveChar( skinColor, charColor1, skinChar, shirtColor, 2 ^ s4, shirtChar )
- end
- elseif key == keys.right then
- if selection == 2 then
- if s1 ~= 15 then
- s1 = s1 +1
- end
- saveChar( 2 ^ s1, charColor1, skinChar, shirtColor, charColor2, shirtChar )
- elseif selection == 5 then
- if s2 ~= 15 then
- s2 = s2 +1
- end
- saveChar( skinColor, 2 ^ s2, skinChar, shirtColor, charColor2, shirtChar )
- elseif selection == 3 then
- if s3 ~= 15 then
- s3 = s3 +1
- end
- saveChar( skinColor, charColor1, skinChar, 2 ^ s3, charColor2, shirtChar )
- elseif selection == 6 then
- if s4 ~= 15 then
- s4 = s4 +1
- end
- saveChar( skinColor, charColor1, skinChar, shirtColor, 2 ^ s4, shirtChar )
- end
- end
- end
- profileEditor()
- elseif event == "mouse_click" then
- if key == 1 then
- term.setCursorPos( 1,1 )
- if p2 == (y/2+4) - .5 then
- drawMenu()
- mainMenu()
- elseif p2 >= 2 and p2 <= 8 then
- selection = p2 -1
- profileEditor()
- end
- end
- end
- end
- end
- local loadedWorld = "world_1"
- --Modding API--
- gameListeners = {
- ["onTick"] = {},
- }
- blocks = {}
- mod = {}
- blocks.newBlock = function( id, blockname, blockColor, blockChar )
- blocks[id] = {}
- blocks[id].blockName = blockname
- blocks[id].blockColor = blockColor
- blocks[id].blockChar = blockChar
- end
- --Current listeners:
- -- onTick - Called every tick
- mod.addListener = function( trigger, target ) --Every time the trigger (event) is called, target() is ran.
- if gameListeners[ trigger ] == nil then
- return false
- end
- gameListeners[ trigger ][ #gameListeners[ trigger ] + 1 ] = target
- return true
- end
- --End Modding API--
- blocks.newBlock( 1, "Grass", colours.green, " " )
- blocks.newBlock( 2, "Dirt", colours.green, " " )
- blocks.newBlock( 3, "Stone", colours.gray, " " )
- blocks.newBlock( 4, "Cobblestone", colours.lightGray, " " )
- blocks.newBlock( 5, "Water", colours.cyan, " " )
- ticks = {}
- ticks.gravity = function()
- if getBlockAt(x, y-1) == false then
- pY = pY -1
- end
- end
- function getBlockAt( x, y )
- if theWorld[x] ~= nil then
- if theWorld[x][y] ~= nil then
- return theWorld[x][y]
- end
- end
- return false
- end
- function gameTick()
- while true do
- local ontickmethods = gameListeners[ "onTick" ]
- for i=1,#ontickmethods do
- ontickmethods[i]()
- end
- sleep(0)
- end
- end
- function loadWorld( worldName )
- loadedWorld = worldName
- mod.addListener( "onTick", ticks.gravity )
- if fs.exists( ".m-ception/mods" ) and fs.isDir( ".m-ception/mods" ) then
- tAll = fs.list( ".m-ception/mods" )
- for n, sItem in pairs( tAll ) do
- local sPath = fs.combine( ".m-ception/mods/", sItem )
- os.loadAPI( sPath )
- end
- else
- fs.delete( ".m-ception/mods")
- fs.makeDir( ".m-ception/mods" )
- end
- parallel.waitForAll( theGame, gameTick )
- end
- --- End the GUI coding, now for the actual game... (wow, so much lines of code just for a main menu without the multiplayer GUI) ---
- theWorld = {}
- skyColor = colours.lightBlue
- skyTime = 0
- pX = 0
- pY = 64
- function placeBlock( x, y, id )
- if tonumber( id ) ~= id then
- for i=1,#blocks do
- if blocks[i].blockName == id then
- id = i
- end
- end
- end
- end
- function theGame()
- while true do
- drawPlayer( x/2, y/2+1 )
- local event, key, p1, p2 = os.pullEvent()
- if event == "key" then
- if key == keys.left then
- pX = pX -1
- elseif key == keys.right then
- pX = pX +1
- end
- end
- end
- end
- --- End Game Coding, lets begin the game! --- got bored/tired beyond this point
- --[[mainMenu() --LET THE GAMES BEGIN
- Commented out, wasn't dramatic enough]]
- function BEGINDAHGAMEZ( PARAMAETERZZZZZZZZZZZZZZZZZZ )
- mainMenu()
- end
- BEGINDAHGAMEZ( "MUAHAHAHAHHAHAHHAHAHHAHHA" )
Advertisement
Add Comment
Please, Sign In to add comment