[ create a new paste ] login | about

Link: http://codepad.org/tly5pKwy    [ raw code | output | fork ]

iPadtutorial909 - Lua, pasted on Jul 15:
--# Main
-- 2D minecraft
p = vec2(400)
sun = vec2()


--Features:
--[[
Sun
cloud
steve
grass blocks
controls
day and night cycle
smaller D-PAD
better Steve skin
borders at the edge of the blocks(it sends you back to the middle)
bigger worlds(still working on code for the camera to move with you :) )
survival mode
lives
sounds when you go off the edge
deaths
5% speed
hotbar(still needs a little work though, this means tools or mining coming soon!)
NameTags
pause menu(A little work still on it to pause.)
name tag color
sprinting
tint packs(tints everything 1 color)
apple(the red circle and it restores your lives back to 10 and in a later update when you touch it and eat it, it will be removed)
crafting(still a little buggy, after you craft once, dont tap where the crafting button used to be because the second time you come in, you cant exit but, for now its only the obsidian you  can craft)
neather(pretty simple... you can add more if you want to...)
]]--

--Experamrntal
--[[

]]--

--Update thoughts:
--[[ moving clouds
tools
ather
mining
monsters
invintory
crafting GUI and crafting tables(working on the crafting GUI, crafting tables coming soon! possibly 4.0 through 5.1)
more blocks
better animations
commands(can be toggled in the options menu)
animals
TNT
fire
flint and steel
weather(when weather first comes out it will just have rain)
stars
saving the data on your lives(im working on it! :)
creative mod
sneaking
moon
more foods
mannualy building
]]--

--Never to add:
--[[

Muti player is impossible to add... :( sorry for the incovenience but, seariously, im doing this in Lua 5.1...

3D UI INTERFACE
]]--

--Bug fixes:
--[[ no fixed
]]--

--Inspired by:
--©Mojang™

--This program built by:
--©Apple Smell Games™

--Credit:
--©Mojang AB™

--Full credit:
--Markus Alexej Persson (thotherwise known as Notch)

function setup()
    
  displayMode(FULLSCREEN)
parameter.text("Username", "Steve")
parameter.color("NameTagColor", 255)
parameter.integer("GameMode", 0, 1, 0)
parameter.boolean("BlueTintPack", false)

crafting = false
bulding = false
netherActive = false
neather = false

    rsw = math.random(100, 300)
    rsh = math.random(50, 100)
    rsx = math.random(0, 700)
   
    lava = 3
    obsidian = 0
    neatherIgniters = 1
    
    appleSpawn = 0
   
  version = "0.4.0 beta"
lives = 10
    supportedOrientations(LANDSCAPE_ANY)
    
end

function draw()
    
    background(0, 0, 0, 255)
 

 
  Play:draw()
--readProjectData("health")
end
function touched(t)
       if t.x >949 and t.x <1004 and t.y >494 and t.y <504 then
        p.x = p.x + 5
        end
        if t.x >0 and t.x <23 and t.y >494 and t.y <504 then
            p.x = p.x - 5
    end
    --Spring Left
    if t.x >0 and t.x <23 and t.y >294 and t.y <304 then
        p.x = p.x - 10
    end
    --Sprint Right
    if t.x >949 and t.x <1004 and t.y >294 and t.y <304 then
        p.x = p.x + 10
    end
    if p.x >=599 and p.x <=607 then
        lives = 10
    end
    --Sneak Right
    if t.x >949 and t.x <1004 and t.y >394 and t.y <404 then
        p.x = p.x + 0.5
    end
    --Sneak Left
    if t.x >0 and t.x <27 and t.y >394 and t.y <404 then
        p.x = p.x - 0.5
    end
end

function craftObsidian()
    obsidian = 3
    lava = 0
end
--# Play
Play = class()


function Play:draw()  
    
    
    background(0, 0, 0, 255)
    
    if BlueTintPack == true then
        tint(0, 16, 255, 255)
    else
        tint(255, 255, 255, 255)
    end

    if sun.y >= 750 then
    background(0, 0, 0, 255)
    sun.y = -200
end

if sun.y >=30 then
    background(119, 119, 225, 255)
end


     --Cloud

        fill(255, 255, 255, 65)
    rect(400, 650, rsw, 50)
    
    

--Grass bottom
if BlueTintPack == true then
    fill(58, 82, 176, 255)
else
    fill(116, 73, 31, 255)
end
for i = 1,10 do 
    rect(100 * i, 0, 100, 100)
    end

--Username tag
fill(NameTagColor)
text("" ..Username, p.x , 255)

    --Steve!
    sprite("Documents:Steve", p.x, 185, 100, 110)
    --Head
 -- fill(180, 154, 80, 255)
    --rect(p.x, 250, 70, 70)
    --Body
--    fill(0, 0, 255, 255)

if p.x >1000 then
p.x = 400
    --saveProjectData("health", 1)
    
    for i = 1,1 do
        sound(SOUND_HIT, 41660)
        lives = lives - 1
    end
end

--Build button
fill(30, 0, 255, 79)
rect(100, 500, 70, 70)
fill(255, 255, 255, 255)
text("Build", 135, 535)
--Build button touch quards
if CurrentTouch.x >=94 and CurrentTouch.x <=174 and CurrentTouch.y >494 and CurrentTouch.y <574 then
    building = true
end 

if building == true then
    background(111, 108, 108, 255)
   if obsidian == 3 then
    fill(127, 127, 127, 105)
    rect(200, 600, 100, 70)
    fill(255, 0, 0, 123)
    rect(600, 200, 100, 100)
    fill(255)
    text("Exit", 650, 250)
if CurrentTouch.x >594 and CurrentTouch.x <704 and CurrentTouch.y >194 and CurrentTouch.y <304 then
    building = false
end
    fill(255)
    text("Neather Portal", 250, 630)
    if CurrentTouch.x >194 and CurrentTouch.x <304 and CurrentTouch.y >594 and CurrentTouch.y <674 then
    obsidian = 0
    neatherIgniters = 0
 
        neatherActive = true
        building = false
        end
    end
end

if neatherActive == true then
fill(0, 0, 0, 255)
rect(95, 115, 100, 100)
fill(212, 0, 255, 255)
rect(95, 165, 100, 50)
if p.x >=95 and p.x <=105 then
    neather = true
    end
end

if neather == true then
    background(230, 21, 21, 255)

          sprite("Documents:Steve", p.x, 185, 100, 110)     
end

if p.x <100 then 
    p.x = 400
    
    for i = 1,1 do
        sound(SOUND_HIT, 41660)
        lives = lives - 1
    end
end
fill(127, 127, 127, 90)
rect(300, 300, 70, 70)
fill(255, 255, 255, 255)
text("Craft", 330, 330)


if CurrentTouch.x >294 and CurrentTouch.x <374 and CurrentTouch.y >294 and CurrentTouch.y <374 then
    crafting = true
end

if crafting == true then
      background(123, 104, 30, 255)
     fill(255, 0, 0, 123)
    rect(600, 200, 100, 100)
    fill(255)
    text("Exit", 650, 250)
if CurrentTouch.x >594 and CurrentTouch.x <704 and CurrentTouch.y >194 and CurrentTouch.y <304 then
    crafting = false
end
    if lava == 3 then
        fill(0, 0, 0, 255)
        rect(500, 500, 100, 100)
        fill(255, 255, 255, 255)
        text("OBSIDIAN", 500, 400)
        fill(127, 127, 127, 102)
        rect(600, 400, 70, 70)
        fill(255, 255, 255, 255)
        text("Craft", 630, 430)
        
       if CurrentTouch.x >594 and CurrentTouch.x <674 and CurrentTouch.y >394 and CurrentTouch.y <474 then
        
obsidian = 3
lava = 0
crafting = false


        end
    end 
end

--Inventory/hotbar
fill(127, 127, 127, 107)
rect(700, 600, 70, 70)
rect(800, 600, 70, 70)
rect(900, 600, 70, 70)

if neatherIgniters >0 then
    fill(255, 108, 0, 255)
    ellipse(820, 620, 30)
    fill(255, 0, 0, 255)
    rect(820, 625, 10, 10)
    fill(255)
text("" .. neatherIgniters, 855, 612)
end
if obsidian > 0 then
    fill(0, 0, 0, 255)
    rect(710, 610, 40, 40)
    fill(255, 255, 255, 255)
    fontSize(15)
    text("" ..obsidian, 755, 612)
end

for i = 1,lives do
    sprite("Planet Cute:Heart", 70 * i, 600, 50, 50)
end

--Sun
fill(243, 255, 0, 193)
rect(600, 0 + sun.y, 300, 300)

sun.y = sun.y + 0.3

appleSpawn = appleSpawn + 1
if appleSpawn >=500 then
    fill(255, 0, 0, 255)
    ellipse(600, 150, 40)
end

    --Grass top
    if BlueTintPack == true then
        fill(0, 76, 255, 255)
    else
    fill(0, 255, 0, 255)
end
    rect(100, 100, 1000, 30)
    
    --Controls
    sprite("Cargo Bot:Command Left", 15, 500)
    sprite("Cargo Bot:Command Right", 1000, 500)
    tint(196, 30, 30, 255)
    sprite("Cargo Bot:Command Left", 15, 300)
    sprite("Cargo Bot:Command Right", 1000, 300)
tint(0, 0, 255, 255)
sprite("Cargo Bot:Command Right", 1000, 400)
sprite("Cargo Bot:Command Left", 15, 400)

    if lives == 0 then
        restart()
        --clearProjectData()
    end
    fill(127, 127, 127, 113)
rect(830, 730, 50, 50)
fill(255, 255, 255, 255)
text("||", 850, 750)
if CurrentTouch.x >=824 and CurrentTouch.x <=874 and CurrentTouch.y >=724 and CurrentTouch.y <=784 then
    background(127, 127, 127, 0)
    fill(198, 193, 193, 255)
    text("Paused", 400, 600)
    fill(255, 255, 255, 255)
text("Touch to resume", 500, 500)
    end
end

function Play:touched(touch)

end


Output:
1
2
3
4
line 4: attempt to call global 'vec2' (a nil value)
stack traceback:
	t.lua:4: in main chunk
	[C]: ?


Create a new paste based on this one


Comments: