This repository has been archived by the owner on Sep 17, 2018. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
init.lua
111 lines (103 loc) · 2.86 KB
/
init.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
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
local function howl(ttl, player)
if not player then
return
end
ttl = ttl - 15
if ttl < 0 then
return
end
minetest.sound_play("rdococ", {object = player, loop = false})
minetest.after(15, howl, ttl, player)
end
--
-- nodes
--
minetest.register_node("rdococ:rdococ", {
description = "rdococ",
tiles = {
"rdococ_head.png",
},
paramtype = "light",
light_source = default.LIGHT_MAX,
paramtype2 = "facedir",
groups = {cracky = 2},
is_ground_content = false,
legacy_facedir_simple = true,
sounds = default.node_sound_defaults(),
stack_max = 1,
on_use = function(itemstack, user, pointed_thing)
howl(300, user)
itemstack:take_item()
return itemstack
end,
})
minetest.register_node("rdococ:rdococ_tail_thing", {
description = "rdococ Tail Thing",
tiles = {
"rdococ_tail.png",
},
paramtype = "light",
light_source = default.LIGHT_MAX,
paramtype2 = "facedir",
groups = {cracky = 2},
is_ground_content = false,
stack_max = 5,
sounds = default.node_sound_defaults(),
on_use = function(itemstack, user, pointed_thing)
minetest.sound_play("rdococ", {object = user, loop = false})
itemstack:take_item()
return itemstack
end,
})
--
-- mapgen
--
local gen = minetest.setting_getbool("pbj_pup_generate")
if gen == nil or gen then
local function place(pos, facedir, length)
if facedir > 3 then
facedir = 0
end
local tailvec = minetest.facedir_to_dir(facedir)
local p = {x = pos.x, y = pos.y, z = pos.z}
minetest.set_node(p, {name = "pbj_pup:pbj_pup", param2 = facedir})
for i = 1, length do
p.x = p.x + tailvec.x
p.z = p.z + tailvec.z
minetest.set_node(p, {name = "pbj_pup:pbj_pup_candies", param2 = facedir})
end
end
local function generate(minp, maxp, seed)
local height_min = -31000
local height_max = -32
if maxp.y < height_min or minp.y > height_max then
return
end
local y_min = math.max(minp.y, height_min)
local y_max = math.min(maxp.y, height_max)
local volume = (maxp.x - minp.x + 1) * (y_max - y_min + 1) * (maxp.z - minp.z + 1)
local pr = PseudoRandom(seed + 9324342)
local max_num = math.floor(volume / (16 * 16 * 16))
for i = 1, max_num do
if pr:next(0, 1000) == 0 then
local x0 = pr:next(minp.x, maxp.x)
local y0 = pr:next(minp.y, maxp.y)
local z0 = pr:next(minp.z, maxp.z)
local p0 = {x = x0, y = y0, z = z0}
place(p0, pr:next(0, 3), pr:next(3, 15))
end
end
end
minetest.register_on_generated(generate)
end
--
-- compat
--
if minetest.setting_getbool("pbj_pup_alias_nyancat") then
minetest.register_alias("default:nyancat", "pbj_pup:pbj_pup")
minetest.register_alias("default:nyancat_rainbow","pbj_pup:pbj_pup_candies")
minetest.register_alias("nyancat", "pbj_pup:pbj_pup")
minetest.register_alias("nyancat_rainbow", "pbj_pup:pbj_pup_candies")
minetest.register_alias("nyancat:nyancat", "pbj_pup:pbj_pup")
minetest.register_alias("nyancat:nyancat_rainbow", "pbj_pup:pbj_pup_candies")
end