[ create a new paste ] login | about

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

iPadtutorial909 - Lua, pasted on Jul 15:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
--# Main
-- 2D minecraft
p = vec2(400)
sun = vec2()


--Features:
--[[
Sun
cloud
steve
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()
neather(pretty simple... you can add more if you want to...)
apple pickup sounds
blocks
building
cursor at touch
]]--

--Blocks:
--[[
grass
obsidian
neather back
]]--

--Items:
--[[
lava 
water
neather igniter
water
]]--

--Experamrntal
--[[
more blocks
]]--

--Update thoughts:
--[[ moving clouds
tools
mining
ather
monsters
better animations
animals
TNT
fire
flint and steel
weather(when weather first comes out it will just have rain)
stars
creative mode
sneaking
moon
more foods
mannualy building
]]--

--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)

next = 0

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

    rsw = math.random(100, 300)
    rsh = math.random(50, 100)
    
    lava = 3
    obsidian = 0
    neatherIgniters = 1
    water = 1
    neatherBack = 0
    
    appleSpawn = 0
   
  version = "0.4.1 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
        sound(SOUND_PICKUP, 2626)
        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

function craftNeatherback()
    water = 0
    neatherBack = 1
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

fill(255, 0, 0, 255)
ellipse(CurrentTouch.x, CurrentTouch.y, 30)
     --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)
       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
   if obsidian == 3 then
    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)
if neatherBack >0 then
    next = next + 3
    if next%40==0 then
        fill(230, 0, 255, 255)
    end
    if next%40==0 then
    fill(0, 255, 255, 255)
end
    rect(700, 110, 100, 100)
    if p.x >694 and p.x <804 then
        neather = false
        end
    end
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("CraftObsidian", 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
    if water >0 then
        fill(0, 255, 255, 255)
        rect(300, 500, 50, 50)
        fontSize(10)
        fill(255)
        text("NEATHERBACK", 340, 400)
        fill(127, 127, 127, 105)
        rect(300, 380, 70, 70)
        if CurrentTouch.x >294 and CurrentTouch.x <370 and CurrentTouch.y >374 and CurrentTouch.y <454 then
            craftNeatherback()
            crafting = false
        end
    end
end
fontSize(20)

--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()
    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: