-
Notifications
You must be signed in to change notification settings - Fork 0
/
new new old version.txt
242 lines (208 loc) · 6.98 KB
/
new new old version.txt
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
local snow = {} --the class
snow.playertable = {} --the player table
local snowfallradius = 90
local snowfallheight = 50
local snowchance = 0.99 --0.99 is best
--particles stuff
local radius = 15
local height = 10
local amountofsnow = 400
local snowvelocity = 0.5
local snowfallvelocity = {-1,-3}
local timer = 0
local timerexpire = 5
minetest.register_globalstep(function(dtime)
timer = timer + dtime
if timer > timerexpire then
timer = 0
for _,player in pairs(minetest.get_connected_players()) do
if player:get_player_name() then
local playerpos = player:getpos()
local exactplayerpos = {x=math.floor(playerpos.x+0.5),y=math.floor(playerpos.y+0.5),z=math.floor(playerpos.z+0.5)}
local oldpos = snow.playertable[player:get_player_name()]
--make snow
--if oldpos and (oldpos.x ~= exactplayerpos.x or oldpos.y ~= exactplayerpos.y or oldpos.z ~= exactplayerpos.z) then
--CHANGE SPAWNERS
--snow.check_nodes(playerpos, player:get_player_name())
snow.make_snow_fall(playerpos)
--end
snow.playertable[player:get_player_name()] = exactplayerpos
end
end
end
end)
minetest.register_on_joinplayer(function(player)
local playerpos = player:getpos()
local exactplayerpos = {x=math.floor(playerpos.x+0.5),y=math.floor(playerpos.y+0.5),z=math.floor(playerpos.z+0.5)}
snow.playertable[player:get_player_name()] = exactplayerpos
player:set_sky("grey", "plain", "", false)
minetest.add_particlespawner({
amount = amountofsnow,
-- Number of particles spawned over the time period `time`.
time = 0,
-- Lifespan of spawner in seconds.
-- If time is 0 spawner has infinite lifespan and spawns the `amount` on
-- a per-second basis.
minpos = {x=-radius, y=0, z=-radius},
maxpos = {x=radius, y=height, z=radius},
minvel = {x=-snowvelocity, y=snowfallvelocity[1], z=-snowvelocity},
maxvel = {x=snowvelocity, y=snowfallvelocity[2], z=snowvelocity},
minacc = {x=0, y=0, z=0},
maxacc = {x=0, y=0, z=0},
minexptime = 1,
maxexptime = 1,
minsize = 1,
maxsize = 1,
-- The particles' properties are random values between the min and max
-- values.
-- pos, velocity, acceleration, expirationtime, size
collisiondetection = true,
-- If true collide with `walkable` nodes and, depending on the
-- `object_collision` field, objects too.
collision_removal = true,
-- If true particles are removed when they collide.
-- Requires collisiondetection = true to have any effect.
object_collision = true,
-- If true particles collide with objects that are defined as
-- `physical = true,` and `collide_with_objects = true,`.
-- Requires collisiondetection = true to have any effect.
attached = player,
-- If defined, particle positions, velocities and accelerations are
-- relative to this object's position and yaw
vertical = true,
-- If true face player using y axis only
texture = "snowflake.png",
playername = player:get_player_name(),
-- Optional, if specified spawns particles only on the player's client
glow = 0
-- Optional, specify particle self-luminescence in darkness.
-- Values 0-14.
})
end)
snow.check_nodes = function(pos,name)
--[[
for x=-snowfallradius,snowfallradius do
for z=-snowfallradius,snowfallradius do
if math.random() > snowchance then
local superpos = {x=pos.x+x,y=pos.y+snowfallheight,z=pos.z+z}
local lighttest = minetest.get_node_light(superpos, 0.5)
if lighttest and lighttest >= 15 then
--minetest.set_node(superpos, {name="snow:snow"})
--minetest.spawn_falling_node(superpos)
end
end
end
end
]]
end
--this function actually puts snow and rain on the ground
local vm = {}
snow.make_snow_fall = function(pos)
local range = snowfallradius
local height = snowfallheight
local air = minetest.get_content_id("air")
local snowblock = minetest.get_content_id("snow:snow")
local water = minetest.get_content_id("default:water_source")
local ice = minetest.get_content_id("default:ice")
local min = {x=pos.x-range,y=pos.y-height,z=pos.z-range}
local max = {x=pos.x+range,y=pos.y+height,z=pos.z+range}
local vm = minetest.get_voxel_manip()
local emin, emax = vm:read_from_map(min,max)
local area = VoxelArea:new{MinEdge=emin, MaxEdge=emax}
local data = vm:get_data()
local lightdata = vm:get_light_data()
local content_id = minetest.get_name_from_content_id
print("tying")
for x=-range, range do
for y=-height, height do
for z=-range, range do
--if vector.distance(pos, vector.add(pos, {x=x, y=y, z=z})) <= range then
--deposit snow randomly
local test_deposit_chance = snowchance
--if heavy_percip == true then
-- test_deposit_chance = test_deposit_chance - 0.25 -- heavy percip
--end
if math.random() > test_deposit_chance then
--the actual node being indexed
local p_pos = area:index(pos.x+x,pos.y+y,pos.z+z)
local l = lightdata[p_pos]
if l ~= nil and l >= 15 then
local n = content_id(data[p_pos])
--the node above it (testing for place for snow and water)
local p_pos_above = area:index(pos.x+x,pos.y+y+1,pos.z+z)
local n_above
if p_pos_above and data[p_pos_above] then
n_above = content_id(data[p_pos_above])
end
local p_pos_below = area:index(pos.x+x,pos.y+y-1,pos.z+z)
local n_below
if p_pos_below and data[p_pos_below] then
n_below = content_id(data[p_pos_below])
end
if n ~= "air" and n ~= "snow:snow" and n_above == "air" and minetest.registered_nodes[n]["buildable_to"] == true then
data[p_pos] = snowblock
elseif n == "air" and n_below ~= "air" and minetest.get_item_group(n, "liquid") == 0 and n_below ~= "snow:snow" and minetest.registered_nodes[n_below]["buildable_to"] == false then
data[p_pos] = snowblock
elseif n == "air" and n_below == "default:water_source" then
data[p_pos_below] = ice
end
end
end
--end
end
end
end
vm:set_data(data)
--if param2er then
-- vm:set_param2_data(p2data)
--end
vm:write_to_map()
vm = nil
data = nil
lightdata = nil
end
--override snow
--[[
minetest.register_on_mods_loaded(function()
minetest.override_item("default:snow", {
on_construct = function(pos)
minetest.set_node(pos, {name = "snow:snow"})
end,
})
end)
]]--
minetest.register_lbm({
name = "snow:replacesnow",
nodenames = {"default:snow"},
action = function(pos, node)
minetest.set_node(pos, {name = "snow:snow"})
end,
})
-------
minetest.register_node("snow:snow", {
description = "Snow",
tiles = {"default_snow.png"},
inventory_image = "default_snowball.png",
wield_image = "default_snowball.png",
paramtype = "light",
buildable_to = true,
floodable = true,
drawtype = "nodebox",
node_box = {
type = "fixed",
fixed = {
{-0.5, -0.5, -0.5, 0.5, -0.25, 0.5},
},
},
collision_box = {
type = "fixed",
fixed = {
{-0.5, -0.5, -0.5, 0.5, -7 / 16, 0.5},
},
},
groups = {crumbly = 3, falling_node = 1, snowy = 1},
sounds = default.node_sound_snow_defaults(),
on_construct = function(pos)
minetest.set_node(pos, {name = "default:snow"})
end,
})