Fix bad indents in wielditem mod
This commit is contained in:
parent
5ceecc4e1f
commit
ab2a67fa91
@ -4,68 +4,65 @@
|
|||||||
-- By Kaadmy, for Pixture
|
-- By Kaadmy, for Pixture
|
||||||
--
|
--
|
||||||
|
|
||||||
wielditem = {}
|
local wielditem = {}
|
||||||
|
|
||||||
local update_time = 1
|
local update_time = 1
|
||||||
local timer = 10 -- needs to be more than update_time
|
local timer = 10 -- needs to be more than update_time
|
||||||
|
|
||||||
minetest.register_entity(
|
minetest.register_entity("wielditem:wielditem", {
|
||||||
"wielditem:wielditem",
|
is_visible = false,
|
||||||
{
|
|
||||||
is_visible = false,
|
|
||||||
|
|
||||||
visual = "wielditem",
|
visual = "wielditem",
|
||||||
visual_size = {x = 0.17, y = 0.17},
|
visual_size = {x = 0.17, y = 0.17},
|
||||||
|
|
||||||
hp_max = 1,
|
hp_max = 1,
|
||||||
|
|
||||||
physical = false,
|
physical = false,
|
||||||
pointable = false,
|
pointable = false,
|
||||||
collide_with_objects = false,
|
collide_with_objects = false,
|
||||||
makes_footstep_sounds = false,
|
makes_footstep_sounds = false,
|
||||||
static_save = false,
|
static_save = false,
|
||||||
|
|
||||||
_wielder = nil,
|
_wielder = nil,
|
||||||
|
|
||||||
on_activate = function(self, staticdata)
|
on_activate = function(self, staticdata)
|
||||||
local name = staticdata
|
local name = staticdata
|
||||||
local wielder = minetest.get_player_by_name(name)
|
local wielder = minetest.get_player_by_name(name)
|
||||||
if wielder and wielder:is_player() then
|
if wielder and wielder:is_player() then
|
||||||
self._wielder = wielder
|
self._wielder = wielder
|
||||||
else
|
else
|
||||||
-- Remove orphan wielditem
|
-- Remove orphan wielditem
|
||||||
minetest.log("info", "[wielditem] Attempted to spawn orphan wielditem entity!")
|
minetest.log("info", "[wielditem] Attempted to spawn orphan wielditem entity!")
|
||||||
self.object:remove()
|
self.object:remove()
|
||||||
return
|
return
|
||||||
end
|
|
||||||
self.object:set_armor_groups({immortal=1})
|
|
||||||
end,
|
|
||||||
on_step = function(self, dtime)
|
|
||||||
local player = self._wielder
|
|
||||||
|
|
||||||
-- Remove orphan wielditem
|
|
||||||
if player == nil or (minetest.get_player_by_name(player:get_player_name()) == nil) then
|
|
||||||
self.object:remove()
|
|
||||||
return
|
|
||||||
end
|
|
||||||
|
|
||||||
local itemname = player:get_wielded_item():get_name()
|
|
||||||
|
|
||||||
if itemname ~= "" then
|
|
||||||
self.object:set_properties({textures = {itemname}, is_visible=true})
|
|
||||||
else
|
|
||||||
self.object:set_properties({is_visible=false})
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
})
|
self.object:set_armor_groups({immortal=1})
|
||||||
|
end,
|
||||||
|
on_step = function(self, dtime)
|
||||||
|
local player = self._wielder
|
||||||
|
-- Remove orphan wielditem
|
||||||
|
if player == nil or (minetest.get_player_by_name(player:get_player_name()) == nil) then
|
||||||
|
self.object:remove()
|
||||||
|
return
|
||||||
|
end
|
||||||
|
|
||||||
|
local itemname = player:get_wielded_item():get_name()
|
||||||
|
|
||||||
|
if itemname ~= "" then
|
||||||
|
self.object:set_properties({textures = {itemname}, is_visible=true})
|
||||||
|
else
|
||||||
|
self.object:set_properties({is_visible=false})
|
||||||
|
end
|
||||||
|
end
|
||||||
|
})
|
||||||
|
|
||||||
local function attach_wielditem(player)
|
local function attach_wielditem(player)
|
||||||
local name = player:get_player_name()
|
local name = player:get_player_name()
|
||||||
local pos = player:get_pos()
|
local pos = player:get_pos()
|
||||||
|
|
||||||
wielditem[name] = minetest.add_entity(pos, "wielditem:wielditem", name)
|
wielditem[name] = minetest.add_entity(pos, "wielditem:wielditem", name)
|
||||||
wielditem[name]:set_attach(player, "right_arm", {x = -1.5, y = 5.7, z = 2.5}, {x = 90, y = -45, z = 270})
|
wielditem[name]:set_attach(player, "right_arm", {x = -1.5, y = 5.7, z = 2.5}, {x = 90, y = -45, z = 270})
|
||||||
wielditem[name]:get_luaentity()._wielder = player
|
wielditem[name]:get_luaentity()._wielder = player
|
||||||
end
|
end
|
||||||
|
|
||||||
minetest.register_on_joinplayer(function(player)
|
minetest.register_on_joinplayer(function(player)
|
||||||
@ -76,4 +73,8 @@ minetest.register_on_joinplayer(function(player)
|
|||||||
end, player)
|
end, player)
|
||||||
end)
|
end)
|
||||||
|
|
||||||
|
minetest.register_on_leaveplayer(function(player)
|
||||||
|
wielditem[name] = nil
|
||||||
|
end)
|
||||||
|
|
||||||
default.log("mod:wielditem", "loaded")
|
default.log("mod:wielditem", "loaded")
|
||||||
|
Loading…
Reference in New Issue
Block a user