Remove more unnecessary globals

This commit is contained in:
Lars 2022-03-16 13:03:33 -07:00
parent fcaa079a84
commit d62d405a5f
3 changed files with 16 additions and 11 deletions

@ -298,7 +298,7 @@ if math.random(1,100) <= crit+((skill*10)-10) then
end end
entpos = self.object:get_pos() local entpos = self.object:get_pos()
minetest.add_particle ({ minetest.add_particle ({
pos = entpos, velocity = 0, acceleration = {x=0, y=5, z=0}, pos = entpos, velocity = 0, acceleration = {x=0, y=5, z=0},
expirationtime = 0.75, size = 12, collisiondetection = false, expirationtime = 0.75, size = 12, collisiondetection = false,

@ -1,3 +1,5 @@
local proj_dir
minetest.register_tool("rangedweapons:forcegun", { minetest.register_tool("rangedweapons:forcegun", {
description = "" ..core.colorize("#35cdff","Force gun\n") ..core.colorize("#FFFFFF", "Completelly harmless... by itself...\n")..core.colorize("#FFFFFF", "It's projectile will push either the entity it hits directly, or everyone near the node it collides with far away.\n") ..core.colorize("#FFFFFF", "Perfect for rocket-jumping or YEETing enemies away.\n")..core.colorize("#FFFFFF", "Power usage: 40\n")..core.colorize("#FFFFFF", "Gun type:Power Special-gun\n") ..core.colorize("#FFFFFF", "Bullet velocity: 60"), description = "" ..core.colorize("#35cdff","Force gun\n") ..core.colorize("#FFFFFF", "Completelly harmless... by itself...\n")..core.colorize("#FFFFFF", "It's projectile will push either the entity it hits directly, or everyone near the node it collides with far away.\n") ..core.colorize("#FFFFFF", "Perfect for rocket-jumping or YEETing enemies away.\n")..core.colorize("#FFFFFF", "Power usage: 40\n")..core.colorize("#FFFFFF", "Gun type:Power Special-gun\n") ..core.colorize("#FFFFFF", "Bullet velocity: 60"),
range = 0, range = 0,
@ -18,7 +20,7 @@ if inv:contains_item("main", "rangedweapons:power_particle 40") then
minetest.sound_play("rangedweapons_rocket", {object=obj}) minetest.sound_play("rangedweapons_rocket", {object=obj})
obj:set_velocity({x=dir.x * 60, y=dir.y * 60, z=dir.z * 60}) obj:set_velocity({x=dir.x * 60, y=dir.y * 60, z=dir.z * 60})
obj:setyaw(yaw - math.pi/2) obj:set_yaw(yaw - math.pi/2)
proj_dir = dir proj_dir = dir
local ent = obj:get_luaentity() local ent = obj:get_luaentity()
if ent then if ent then
@ -91,14 +93,14 @@ if moveresult.collisions[1].type == "node" then
local objs = minetest.get_objects_inside_radius({x = pos.x, y = pos.y, z = pos.z}, 7) local objs = minetest.get_objects_inside_radius({x = pos.x, y = pos.y, z = pos.z}, 7)
for k, obj in pairs(objs) do for k, obj in pairs(objs) do
local posd_x = 1
local posd_y = 1
local posd_z = 1
if obj:get_pos() then if obj:get_pos() then
posd_x = pos.x - obj:get_pos().x posd_x = pos.x - obj:get_pos().x
posd_y = pos.y - obj:get_pos().y posd_y = pos.y - obj:get_pos().y
posd_z = pos.z - obj:get_pos().z posd_z = pos.z - obj:get_pos().z
else
posd_x = 1
posd_y = 1
posd_z = 1
end end

@ -262,9 +262,10 @@ then
minetest.chat_send_player(player:get_player_name(), "" ..core.colorize("#ff0000","throwable weapons are prohibited in this area!")) minetest.chat_send_player(player:get_player_name(), "" ..core.colorize("#ff0000","throwable weapons are prohibited in this area!"))
else else
ThrowCaps = itemstack:get_definition().RW_throw_capabilities local ThrowCaps = itemstack:get_definition().RW_throw_capabilities
playerMeta = player:get_meta() local playerMeta = player:get_meta()
local throw_cooldown = 0
if ThrowCaps ~= nil then if ThrowCaps ~= nil then
throw_cooldown = ThrowCaps.throw_cooldown or 0 throw_cooldown = ThrowCaps.throw_cooldown or 0
end end
@ -297,6 +298,7 @@ local throw_sparks = 0
local throw_bomb_ignite = 0 local throw_bomb_ignite = 0
local throw_size = 0 local throw_size = 0
local throw_glow = 0 local throw_glow = 0
local OnCollision = function()end
if ThrowCaps ~= nil then if ThrowCaps ~= nil then
throw_damage = ThrowCaps.throw_damage or {fleshy=1} throw_damage = ThrowCaps.throw_damage or {fleshy=1}
@ -554,8 +556,8 @@ minetest.sound_play("rangedweapons_empty", {pos = player:get_pos()})
minetest.chat_send_player(player:get_player_name(), "" ..core.colorize("#ff0000","Guns are prohibited in this area!")) minetest.chat_send_player(player:get_player_name(), "" ..core.colorize("#ff0000","Guns are prohibited in this area!"))
else else
local power_cooldown = 0 local power_cooldown = 0
local power_consumption = 0
PowerCaps = itemstack:get_definition().RW_powergun_capabilities local PowerCaps = itemstack:get_definition().RW_powergun_capabilities
if PowerCaps ~= nil then if PowerCaps ~= nil then
power_cooldown = PowerCaps.power_cooldown or 0 power_cooldown = PowerCaps.power_cooldown or 0
@ -595,6 +597,7 @@ local power_sparks = 0
local power_bomb_ignite = 0 local power_bomb_ignite = 0
local power_size = 0 local power_size = 0
local power_glow = 20 local power_glow = 20
local power_projectiles = 1
if PowerCaps ~= nil then if PowerCaps ~= nil then
power_damage = PowerCaps.power_damage or {fleshy=1} power_damage = PowerCaps.power_damage or {fleshy=1}
@ -968,7 +971,7 @@ scope_hud =
end) end)
local timer = 0 local timer = 0
minetest.register_globalstep(function(dtime, player) minetest.register_globalstep(function(dtime)
timer = timer + dtime; timer = timer + dtime;
if timer >= 1.0 then if timer >= 1.0 then
for _, player in pairs(minetest.get_connected_players()) do for _, player in pairs(minetest.get_connected_players()) do