Skip to content

Commit 3aedfac

Browse files
committedJul 27, 2013
Weather support
1 parent e65d8ad commit 3aedfac

23 files changed

+552
-91
lines changed
 

‎builtin/falling.lua

+18-16
Original file line numberDiff line numberDiff line change
@@ -14,11 +14,11 @@ minetest.register_entity("__builtin:falling_node", {
1414
visual_size = {x=0.667, y=0.667},
1515
},
1616

17-
nodename = "",
17+
node = {},
1818

19-
set_node = function(self, nodename)
20-
self.nodename = nodename
21-
local stack = ItemStack(nodename)
19+
set_node = function(self, node)
20+
self.node = node
21+
local stack = ItemStack(node.name)
2222
local itemtable = stack:to_table()
2323
local itemname = nil
2424
if itemtable then
@@ -32,20 +32,19 @@ minetest.register_entity("__builtin:falling_node", {
3232
end
3333
prop = {
3434
is_visible = true,
35-
textures = {nodename},
35+
textures = {node.name},
3636
}
3737
self.object:set_properties(prop)
3838
end,
3939

4040
get_staticdata = function(self)
41-
return self.nodename
41+
return self.node.name
4242
end,
4343

4444
on_activate = function(self, staticdata)
45-
self.nodename = staticdata
4645
self.object:set_armor_groups({immortal=1})
4746
--self.object:setacceleration({x=0, y=-10, z=0})
48-
self:set_node(self.nodename)
47+
self:set_node({name=staticdata})
4948
end,
5049

5150
on_step = function(self, dtime)
@@ -57,8 +56,10 @@ minetest.register_entity("__builtin:falling_node", {
5756
local bcn = minetest.get_node(bcp)
5857
-- Note: walkable is in the node definition, not in item groups
5958
if minetest.registered_nodes[bcn.name] and
60-
minetest.registered_nodes[bcn.name].walkable then
61-
if minetest.registered_nodes[bcn.name].buildable_to then
59+
minetest.registered_nodes[bcn.name].walkable or
60+
(minetest.get_node_group(self.node.name, "float") ~= 0 and minetest.registered_nodes[bcn.name].liquidtype ~= "none")
61+
then
62+
if minetest.registered_nodes[bcn.name].buildable_to and (minetest.get_node_group(self.node.name, "float") == 0 or minetest.registered_nodes[bcn.name].liquidtype == "none") then
6263
minetest.remove_node(bcp)
6364
return
6465
end
@@ -83,7 +84,7 @@ minetest.register_entity("__builtin:falling_node", {
8384
end
8485
end
8586
-- Create node and remove entity
86-
minetest.add_node(np, {name=self.nodename})
87+
minetest.add_node(np, self.node)
8788
self.object:remove()
8889
nodeupdate(np)
8990
else
@@ -92,9 +93,9 @@ minetest.register_entity("__builtin:falling_node", {
9293
end
9394
})
9495

95-
function spawn_falling_node(p, nodename)
96+
function spawn_falling_node(p, node)
9697
obj = minetest.add_entity(p, "__builtin:falling_node")
97-
obj:get_luaentity():set_node(nodename)
98+
obj:get_luaentity():set_node(node)
9899
end
99100

100101
function drop_attached_node(p)
@@ -150,13 +151,14 @@ function nodeupdate_single(p, delay)
150151
n_bottom = minetest.get_node(p_bottom)
151152
-- Note: walkable is in the node definition, not in item groups
152153
if minetest.registered_nodes[n_bottom.name] and
154+
(minetest.get_node_group(n.name, "float") == 0 or minetest.registered_nodes[n_bottom.name].liquidtype == "none") and
153155
(not minetest.registered_nodes[n_bottom.name].walkable or
154156
minetest.registered_nodes[n_bottom.name].buildable_to) then
155157
if delay then
156158
minetest.after(0.1, nodeupdate_single, {x=p.x, y=p.y, z=p.z}, false)
157159
else
158160
minetest.remove_node(p)
159-
spawn_falling_node(p, n.name)
161+
spawn_falling_node(p, n)
160162
nodeupdate(p)
161163
end
162164
end
@@ -170,7 +172,7 @@ function nodeupdate_single(p, delay)
170172
end
171173
end
172174

173-
function nodeupdate(p)
175+
function nodeupdate(p, delay)
174176
-- Round p to prevent falling entities to get stuck
175177
p.x = math.floor(p.x+0.5)
176178
p.y = math.floor(p.y+0.5)
@@ -179,7 +181,7 @@ function nodeupdate(p)
179181
for x = -1,1 do
180182
for y = -1,1 do
181183
for z = -1,1 do
182-
nodeupdate_single({x=p.x+x, y=p.y+y, z=p.z+z}, not (x==0 and y==0 and z==0))
184+
nodeupdate_single({x=p.x+x, y=p.y+y, z=p.z+z}, delay or not (x==0 and y==0 and z==0))
183185
end
184186
end
185187
end

‎doc/lua_api.txt

+19-1
Original file line numberDiff line numberDiff line change
@@ -322,6 +322,8 @@ param2 is reserved for the engine when any of these are used:
322322
facedir modulo 4 = axisdir
323323
0 = y+ 1 = z+ 2 = z- 3 = x+ 4 = x- 5 = y-
324324
facedir's two less significant bits are rotation around the axis
325+
paramtype2 == "leveled"
326+
^ The drawn node level is read from param2, like flowingliquid
325327

326328
Nodes can also contain extra data. See "Node Metadata".
327329

@@ -353,7 +355,7 @@ Node selection boxes are defined using "node boxes"
353355

354356
The "nodebox" node drawtype allows defining visual of nodes consisting of
355357
arbitrary number of boxes. It allows defining stuff like stairs. Only the
356-
"fixed" box type is supported for these.
358+
"fixed" and "leveled" box type is supported for these.
357359
^ Please note that this is still experimental, and may be incompatibly
358360
changed in the future.
359361

@@ -381,6 +383,8 @@ A box is defined as:
381383
A box of a regular node would look like:
382384
{-0.5, -0.5, -0.5, 0.5, 0.5, 0.5},
383385

386+
type = "leveled" is same as "fixed", but y2 will be automaticaly setted to level from param2
387+
384388
Ore types
385389
---------------
386390
These tell in what manner the ore is generated.
@@ -1258,6 +1262,18 @@ minetest.find_path(pos1,pos2,searchdistance,max_jump,max_drop,algorithm)
12581262
^ algorithm: A*_noprefetch(default), A*, Dijkstra
12591263
minetest.spawn_tree (pos, {treedef})
12601264
^ spawns L-System tree at given pos with definition in treedef table
1265+
minetest.transforming_liquid_add(pos)
1266+
^ add node to liquid update queue
1267+
minetest.get_node_max_level(pos)
1268+
^ get max available level for leveled node
1269+
minetest.get_node_level(pos)
1270+
^ get level of leveled node (water, snow)
1271+
minetest.add_node_level(pos, level)
1272+
^ increase level of leveled node by level, default level = 1, if totallevel > maxlevel returns rest (total-max). can be negative for decreasing
1273+
minetest.get_heat(pos)
1274+
^ heat at pos
1275+
minetest.get_humidity(pos)
1276+
^ humidity at pos
12611277

12621278
Inventory:
12631279
minetest.get_inventory(location) -> InvRef
@@ -1965,6 +1981,8 @@ Node definition (register_node)
19651981
liquid_alternative_source = "", -- Source version of flowing liquid
19661982
liquid_viscosity = 0, -- Higher viscosity = slower flow (max. 7)
19671983
liquid_renewable = true, -- Can new liquid source be created by placing
1984+
freezemelt = "", -- water for snow/ice, ice/snow for water
1985+
leveled = 0, -- Block contain level in param2. value - default level, used for snow. Dont forget use "leveled" type nodebox
19681986
liquid_range = 8, -- number of flowing nodes arround source (max. 8)
19691987
drowning = true, -- Player will drown in these
19701988
two or more sources nearly?

‎minetest.conf.example

+5-1
Original file line numberDiff line numberDiff line change
@@ -107,6 +107,8 @@
107107
#liquid_fast_flood = 1
108108
# Underground water and lava springs, its infnity sources if liquid_finite enabled
109109
#underground_springs = 1
110+
# Enable weather (cold-hot, water freeze-melt). use only with liquid_finite=1
111+
#weather = false
110112
# Enable nice leaves; disable for speed
111113
#new_style_leaves = true
112114
# Enable smooth lighting with simple ambient occlusion;
@@ -268,7 +270,9 @@
268270
# Interval of sending time of day to clients
269271
#time_send_interval = 5
270272
# Length of day/night cycle. 72=20min, 360=4min, 1=24hour, 0=day/night/whatever stays unchanged
271-
#time_speed = 96
273+
#time_speed = 72
274+
# Length of year in days for seasons change. With default time_speed 365 days = 5 real days for year. 30 days = 10 real hours
275+
#year_days = 30
272276
#server_unload_unused_data_timeout = 29
273277
# Interval of saving important changes in the world
274278
#server_map_save_interval = 5.3

0 commit comments

Comments
 (0)
Please sign in to comment.