]> git.lizzy.rs Git - killaura.git/blob - init.lua
Fixed crash
[killaura.git] / init.lua
1 minetest.register_globalstep(function(dtime)
2         local player = minetest.localplayer
3         if not player then return end
4         local control = player:get_control()
5         if minetest.settings:get_bool("killaura") or minetest.settings:get_bool("forcefield") and control.dig then
6                 local friendlist = (minetest.settings:get("friendlist") or ""):split(",")
7                 for _, obj in ipairs(minetest.get_objects_inside_radius(player:get_pos(), 5)) do
8                         local do_attack = true
9                         if obj:is_local_player() then
10                                 do_attack = false
11                         else
12                                 for _, friend in ipairs(friendlist) do
13                                         if obj:get_name() == friend or obj:get_nametag() == friend then
14                                                 do_attack = false
15                                                 break
16                                         end
17                                 end
18                         end
19                         if do_attack then
20                                 obj:punch()
21                         end
22                 end
23         end
24 end)
25
26 minetest.register_list_command("friend", "Configure Friend List (friends dont get attacked by Killaura or Forcefield)", "friendlist")
27
28 minetest.register_cheat("Killaura", "Combat", "killaura")
29 minetest.register_cheat("ForceField", "Combat", "forcefield")