-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathblock.lua
62 lines (56 loc) · 1.04 KB
/
block.lua
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
local block = {}
local blocks = game.blocks
block.type =
{
["stone"] =
{
name = "Stone",
id = 1,
image = { 0, 0 }
},
["log"] =
{
name = "Log",
id = 2,
image = { 1, 0 }
},
["planks"] =
{
name = "Wooden Planks",
id = 3,
image = { 0, 1 }
},
["leaves"] =
{
name = "Leaves",
id = 4,
image = { 1, 1 }
}
}
function block.find( xCoord, yCoord )
if blocks[xCoord] then
if blocks[xCoord][yCoord] then
return blocks[xCoord][yCoord]
end
end
return false
end
function block.create( xCoord, yCoord, type )
xCoord = math.floor( xCoord + 0.5 )
yCoord = math.floor( yCoord + 0.5 )
if block.find( xCoord, yCoord ) then return end
if not blocks[xCoord] then
blocks[xCoord] = {}
end
blocks[xCoord][yCoord] = { quad = type.quad }
end
function block.remove( xCoord, yCoord )
xCoord = math.floor( xCoord + 0.5 )
yCoord = math.floor( yCoord + 0.5 )
if blocks[xCoord] then
if blocks[xCoord][yCoord] then
blocks[xCoord][yCoord] = nil
end
end
end
return block