Remove extra features from playerplus. Adding cactus ABM. Perhaps it will be faster?
This commit is contained in:
parent
ce25d7c04b
commit
e3d3d75374
|
@ -828,10 +828,10 @@ minetest.register_node("default:diamondblock", {
|
||||||
minetest.register_node("default:cactus", {
|
minetest.register_node("default:cactus", {
|
||||||
description = "Cactus",
|
description = "Cactus",
|
||||||
drawtype = "nodebox",
|
drawtype = "nodebox",
|
||||||
tiles = {"default_cactus_top.png", "default_cactus_bottom.png", "default_cactus_side.png","default_cactus_side.png","default_cactus_side.png","default_cactus_side.png"},
|
tiles = {"default_cactus_top.png", "default_cactus_bottom.png", "default_cactus_side.png"},
|
||||||
groups = {snappy = 1, choppy = 3, flammable = 2},
|
paramtype2 = "facedir",
|
||||||
|
groups = {choppy = 3, flammable = 2, attached_node = 1},
|
||||||
sounds = default.node_sound_wood_defaults(),
|
sounds = default.node_sound_wood_defaults(),
|
||||||
paramtype = "light",
|
|
||||||
node_box = {
|
node_box = {
|
||||||
type = "fixed",
|
type = "fixed",
|
||||||
fixed = {
|
fixed = {
|
||||||
|
@ -848,8 +848,18 @@ minetest.register_node("default:cactus", {
|
||||||
{-7/16, -8/16, -7/16, 7/16, 8/16, 7/16},
|
{-7/16, -8/16, -7/16, 7/16, 8/16, 7/16},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
})
|
||||||
|
|
||||||
|
minetest.register_abm({
|
||||||
|
nodenames = {"default:cactus"},
|
||||||
|
interval = 1,
|
||||||
|
chance = 1,
|
||||||
|
action = function(pos, node, active_object_count, active_object_count_wider)
|
||||||
|
local players = minetest.get_objects_inside_radius(pos, 1)
|
||||||
|
for i, player in ipairs(players) do
|
||||||
|
player:set_hp(player:get_hp() - 2)
|
||||||
|
end
|
||||||
|
end,
|
||||||
})
|
})
|
||||||
|
|
||||||
minetest.register_node("default:sugarcane", {
|
minetest.register_node("default:sugarcane", {
|
||||||
|
|
|
@ -10,10 +10,12 @@ local node_ok = function(pos, fallback)
|
||||||
return fallback
|
return fallback
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
local time = 0
|
local time = 0
|
||||||
-- check speed
|
-- check interval
|
||||||
local check = 0.5
|
local check = 0.5
|
||||||
|
if not minetest.is_singleplayer() then
|
||||||
|
local check = 1
|
||||||
|
end
|
||||||
|
|
||||||
minetest.register_globalstep(function(dtime)
|
minetest.register_globalstep(function(dtime)
|
||||||
time = time + dtime
|
time = time + dtime
|
||||||
|
@ -23,7 +25,7 @@ minetest.register_globalstep(function(dtime)
|
||||||
-- reset time for next check
|
-- reset time for next check
|
||||||
time = 0
|
time = 0
|
||||||
-- define locals outside loop
|
-- define locals outside loop
|
||||||
local name, pos, ndef, def, nslow, nfast
|
local name, pos, ndef, nslow
|
||||||
|
|
||||||
-- loop through players
|
-- loop through players
|
||||||
for _,player in ipairs(minetest.get_connected_players()) do
|
for _,player in ipairs(minetest.get_connected_players()) do
|
||||||
|
@ -47,15 +49,6 @@ minetest.register_globalstep(function(dtime)
|
||||||
|
|
||||||
pos.y = pos.y - 0.2 -- reset pos
|
pos.y = pos.y - 0.2 -- reset pos
|
||||||
|
|
||||||
-- [ Physics ]
|
|
||||||
|
|
||||||
-- are we standing on any nodes that speed player up?
|
|
||||||
nfast = nil
|
|
||||||
if playerplus[name].nod_stand == "default:ice"
|
|
||||||
or playerplus[name].nod_stand == "default:packedice" then
|
|
||||||
nfast = true
|
|
||||||
end
|
|
||||||
|
|
||||||
-- are we standing on any nodes that slow player down?
|
-- are we standing on any nodes that slow player down?
|
||||||
nslow = nil
|
nslow = nil
|
||||||
if playerplus[name].nod_stand == "default:snow"
|
if playerplus[name].nod_stand == "default:snow"
|
||||||
|
@ -63,19 +56,11 @@ minetest.register_globalstep(function(dtime)
|
||||||
or playerplus[name].nod_stand == "default:bedrock"
|
or playerplus[name].nod_stand == "default:bedrock"
|
||||||
or playerplus[name].nod_stand == "default:slimeblock"
|
or playerplus[name].nod_stand == "default:slimeblock"
|
||||||
or playerplus[name].nod_stand == "mobs:cobweb"
|
or playerplus[name].nod_stand == "mobs:cobweb"
|
||||||
or playerplus[name].nod_feet == "mobs:cobweb" then
|
or playerplus[name].nod_feet == "mobs:cobweb"
|
||||||
|
or playerplus[name].nod_head == "mobs:cobweb" then
|
||||||
nslow = true
|
nslow = true
|
||||||
end
|
end
|
||||||
|
|
||||||
-- apply speed changes
|
|
||||||
if nfast and not playerplus[name].nfast then
|
|
||||||
playerphysics.add_physics_factor(player, "speed", "playerplusspeed", 1.5)
|
|
||||||
playerplus[name].nfast = true
|
|
||||||
|
|
||||||
elseif not nfast and playerplus[name].nfast then
|
|
||||||
playerphysics.remove_physics_factor(player, "speed", "playerplusspeed")
|
|
||||||
playerplus[name].nfast = nil
|
|
||||||
end
|
|
||||||
-- apply slowdown changes
|
-- apply slowdown changes
|
||||||
if nslow and not playerplus[name].nslow then
|
if nslow and not playerplus[name].nslow then
|
||||||
playerphysics.add_physics_factor(player, "speed", "playerplusslow", 0.7)
|
playerphysics.add_physics_factor(player, "speed", "playerplusslow", 0.7)
|
||||||
|
@ -85,40 +70,9 @@ minetest.register_globalstep(function(dtime)
|
||||||
playerphysics.remove_physics_factor(player, "speed", "playerplusslow")
|
playerphysics.remove_physics_factor(player, "speed", "playerplusslow")
|
||||||
playerplus[name].nslow = nil
|
playerplus[name].nslow = nil
|
||||||
end
|
end
|
||||||
|
|
||||||
-- [ HP ]
|
|
||||||
|
|
||||||
-- Is player suffocating inside a normal node without no_clip privs?
|
|
||||||
local ndef = minetest.registered_nodes[playerplus[name].nod_head]
|
|
||||||
|
|
||||||
if ndef.walkable == true
|
|
||||||
and ndef.drowning == 0
|
|
||||||
and ndef.damage_per_second <= 0
|
|
||||||
and ndef.groups.disable_suffocation ~= 1
|
|
||||||
and ndef.drawtype == "normal"
|
|
||||||
and not minetest.check_player_privs(name, {noclip = true}) then
|
|
||||||
|
|
||||||
if player:get_hp() > 0 then
|
|
||||||
player:set_hp(player:get_hp() - 2)
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
-- am I near a cactus?
|
|
||||||
local near = minetest.find_node_near(pos, 1, "default:cactus")
|
|
||||||
|
|
||||||
if near then
|
|
||||||
-- am I touching the cactus? if so it hurts
|
|
||||||
for _,object in pairs(minetest.get_objects_inside_radius(near, 1.1)) do
|
|
||||||
|
|
||||||
if object:get_hp() > 0 then
|
|
||||||
object:set_hp(object:get_hp() - 2)
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
end)
|
end)
|
||||||
|
|
||||||
|
|
||||||
-- set to blank on join (for 3rd party mods)
|
-- set to blank on join (for 3rd party mods)
|
||||||
minetest.register_on_joinplayer(function(player)
|
minetest.register_on_joinplayer(function(player)
|
||||||
local name = player:get_player_name()
|
local name = player:get_player_name()
|
||||||
|
|
|
@ -112,7 +112,7 @@ end)
|
||||||
|
|
||||||
-- Items for the new player
|
-- Items for the new player
|
||||||
minetest.register_on_newplayer(function (player)
|
minetest.register_on_newplayer(function (player)
|
||||||
if creative_mode_cache then
|
if not creative_mode_cache then
|
||||||
player:get_inventory():add_item('main', 'default:sword_steel')
|
player:get_inventory():add_item('main', 'default:sword_steel')
|
||||||
player:get_inventory():add_item('main', 'default:torch 8')
|
player:get_inventory():add_item('main', 'default:torch 8')
|
||||||
player:get_inventory():add_item('main', 'default:wood 64')
|
player:get_inventory():add_item('main', 'default:wood 64')
|
||||||
|
|
Loading…
Reference in New Issue