|
1 | 1 | local timer = 0 |
2 | 2 |
|
| 3 | +local function is_solid_node(pos) |
| 4 | + local ndef = core.registered_nodes[core.get_node(pos).name] |
| 5 | + return ndef |
| 6 | + and ndef.walkable == true |
| 7 | + and ndef.groups.disable_suffocation ~= 1 |
| 8 | + and ndef.drawtype == "normal" |
| 9 | +end |
| 10 | + |
3 | 11 | core.register_globalstep(function(dtime) |
4 | 12 |
|
5 | 13 | timer = timer + dtime |
6 | 14 | if timer < 1 then return end |
7 | 15 | timer = 0 |
8 | 16 |
|
9 | | - for _, player in pairs(core.get_connected_players()) do |
10 | | - |
| 17 | + for _, player in ipairs(core.get_connected_players()) do |
11 | 18 | local pos = player:get_pos() |
12 | | - pos.y = pos.y + 0.5 |
13 | | - local node = core.get_node(pos) |
14 | | - local ndef = core.registered_nodes[node.name] |
15 | 19 |
|
16 | | - if ndef and ndef.walkable == true |
17 | | - and ndef.damage_per_second == 0 |
18 | | - and ndef.groups.disable_suffocation ~= 1 |
19 | | - and ndef.drawtype == "normal" |
20 | | - and not core.check_player_privs(player:get_player_name(), { noclip = true }) |
21 | | - then |
| 20 | + pos.y = pos.y + 0.5 |
| 21 | + if is_solid_node(pos) then |
| 22 | + pos.y = pos.y + 1 -- Player's head |
| 23 | + if is_solid_node(pos) |
| 24 | + and player:get_hp() > 0 |
| 25 | + and not core.check_player_privs(player:get_player_name(), { noclip = true }) then |
22 | 26 |
|
23 | | - if player:get_hp() > 0 then |
24 | | - player:set_hp(player:get_hp() - 4, { suffocation = true }) |
| 27 | + player:set_hp(player:get_hp() - 1, { suffocation = true }) |
25 | 28 | end |
26 | 29 | end |
27 | 30 | end |
|
0 commit comments