2019-01-28 23:13:21 -05:00
|
|
|
-- LUALOCALS < ---------------------------------------------------------
|
2020-01-10 06:26:07 -05:00
|
|
|
local minetest, nodecore, pairs
|
|
|
|
= minetest, nodecore, pairs
|
2019-01-28 23:13:21 -05:00
|
|
|
-- LUALOCALS > ---------------------------------------------------------
|
|
|
|
|
2019-01-27 22:34:53 -05:00
|
|
|
local function hotpotatoes(player)
|
|
|
|
local inv = player:get_inventory()
|
|
|
|
local hurt = 0
|
|
|
|
local throw = {}
|
|
|
|
for i = 1, inv:get_size("main") do
|
|
|
|
local s = inv:get_stack("main", i)
|
|
|
|
local n = not s:is_empty() and s:get_name()
|
|
|
|
n = n and minetest.registered_items[n]
|
2020-04-09 06:56:18 -04:00
|
|
|
n = n and n.groups and n.groups.damage_touch
|
2019-01-27 22:34:53 -05:00
|
|
|
if n and n > 0 then
|
|
|
|
hurt = hurt + n
|
|
|
|
inv:set_stack("main", i, "")
|
|
|
|
throw[#throw + 1] = s
|
|
|
|
end
|
|
|
|
end
|
|
|
|
if #throw > 0 then
|
|
|
|
local pname = player:get_player_name()
|
|
|
|
local pos = player:get_pos()
|
|
|
|
pos.y = pos.y + 1.2
|
|
|
|
local dir = player:get_look_dir()
|
|
|
|
dir.x = dir.x * 5
|
|
|
|
dir.y = dir.y * 5 + 3
|
|
|
|
dir.z = dir.z * 5
|
2019-08-31 09:26:53 -04:00
|
|
|
for _, v in pairs(throw) do
|
2019-01-27 22:34:53 -05:00
|
|
|
local obj = minetest.add_item(pos, v)
|
|
|
|
obj:set_velocity(dir)
|
|
|
|
obj:get_luaentity().dropped_by = pname
|
|
|
|
end
|
|
|
|
end
|
2020-02-20 07:16:19 -05:00
|
|
|
if hurt > 0 then nodecore.addphealth(player, -hurt, "hotpotato") end
|
2019-01-27 22:34:53 -05:00
|
|
|
end
|
|
|
|
|
|
|
|
minetest.register_globalstep(function()
|
2020-01-10 06:26:07 -05:00
|
|
|
if nodecore.stasis then return end
|
2019-08-31 09:26:53 -04:00
|
|
|
for _, v in pairs(minetest.get_connected_players()) do
|
2019-01-27 22:34:53 -05:00
|
|
|
hotpotatoes(v)
|
|
|
|
end
|
2019-01-28 23:13:21 -05:00
|
|
|
end)
|