-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathgenerate_chunks.lua
49 lines (40 loc) · 1.19 KB
/
generate_chunks.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
function get_block(x, y, z)
local frequency = 0.1
local amplitude = 10
local x_offset = math.sin(frequency * x) * amplitude
local z_offset = math.sin(frequency * z) * amplitude
--local z_offset = math.sqrt(z) * amplitude
--local x_offset = math.sqrt(x) * amplitude
local sufacey = 20 + x_offset + z_offset
if y<sufacey then
return 104
elseif y<17 then
return 3
else
return -1
end
end
function generate_chunks(x_offset, z_offset)
for y = 10, 50 do
for x = x_offset * 16, 16 + x_offset * 16 do
for z = z_offset * 16, 16 + z_offset * 16 do
local block = get_block(x,y,z)
if block > 0 then
Block:placeBlock(block, x, y, z, 0)
end
end
end
end
end
function generate(event)
if event.content == "/build" then
for x_offset = 0, 5 do
for z_offset = 0, 5 do
generate_chunks(x_offset, z_offset)
threadpool:wait(0.005)
end
end
Chat:sendSystemMsg("Construido", 0)
end
end
ScriptSupportEvent:registerEvent([=[Player.NewInputContent]=], generate)