]> git.lizzy.rs Git - perlin.git/blob - init.lua
Initial Commit
[perlin.git] / init.lua
1 perlin = dofile(minetest.get_modpath("perlin") .. "/perlin.lua")
2
3 local start, height, stretch
4
5 minetest.register_chatcommand("perlin", {
6         description = "Start perlin terraforming",
7         param = "<height> <stretch>",
8         func = function(param)
9                 local sparam = param:split(" ")
10                 start, height, stretch = math.floor(minetest.localplayer:get_pos().y), sparam[1], sparam[2]
11         end     
12 })
13
14 minetest.register_chatcommand("perlinstop", {
15         description = "Abort perlin terraforming",
16         func = function(param)
17                 start, height, stretch = nil
18         end     
19 })
20
21 minetest.register_globalstep(function()
22         if start then
23                 local player = minetest.localplayer
24                 local pos = vector.floor(player:get_pos())
25                 for x = pos.x - 1, pos.x + 1 do
26                         for z = pos.z - 1, pos.z + 1 do
27                                 local y = math.floor(start + height * perlin:noise(x / stretch, z / stretch))
28                                 local p = vector.new(x, y, z)
29                                 minetest.place_node(p)
30                         end
31                 end
32         end 
33 end)