1
0
mirror of https://github.com/sys4-fr/server-nalc.git synced 2025-06-28 14:16:06 +02:00

Copying code of cactus' check in sprint

- Sprint mod now check if the player is near a cactus. If yes, it hurts
  him. However, the duration between two checking is about 0.1 seconds.
This commit is contained in:
LeMagnesium
2014-12-07 18:01:17 +01:00
parent c1f5523d9e
commit 3c10469c03
3 changed files with 44 additions and 12 deletions

View File

@ -40,7 +40,23 @@ minetest.register_globalstep(function(dtime)
--Loop through all connected players
for playerName,playerInfo in pairs(players) do
local player = minetest.get_player_by_name(playerName)
local pos = player:getpos()
if player ~= nil then
-- From playerplus :
-- am I near a cactus?
pos.y = pos.y + 0.1
local near = minetest.find_node_near(pos, 1, "default:cactus")
if near then
pos = near
-- am I touching the cactus? if so it hurts
for _,player in ipairs(minetest.get_objects_inside_radius(pos, 1.0)) do
if player:get_hp() > 0 then
player:set_hp(player:get_hp()-1)
end
end
end
--Check if they are pressing the e key
players[playerName]["epressed"] = player:get_player_control()["aux1"]

View File

@ -40,7 +40,23 @@ minetest.register_globalstep(function(dtime)
--Loop through all connected players
for playerName,playerInfo in pairs(players) do
local player = minetest.get_player_by_name(playerName)
local pos = player:getpos()
if player ~= nil then
-- From playerplus :
-- am I near a cactus?
pos.y = pos.y + 0.1
local near = minetest.find_node_near(pos, 1, "default:cactus")
if near then
pos = near
-- am I touching the cactus? if so it hurts
for _,player in ipairs(minetest.get_objects_inside_radius(pos, 1.0)) do
if player:get_hp() > 0 then
player:set_hp(player:get_hp()-1)
end
end
end
--Check if they are moving or not
players[playerName]["moving"] = player:get_player_control()["up"]