Remove image stack wieldview
parent
5d33dc94db
commit
587f9be4d7
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
|
@ -390,7 +390,7 @@ minetest.register_tool("mcl_fishing:fishing_rod", {
|
|||
_doc_items_usagehelp = S("Rightclick to launch the bobber. When it sinks right-click again to reel in an item. Who knows what you're going to catch?"),
|
||||
groups = { tool=1, fishing_rod=1, enchantability=1 },
|
||||
inventory_image = "mcl_fishing_fishing_rod.png",
|
||||
wield_image = "mcl_fishing_fishing_rod.png^[transformR270",
|
||||
wield_image = "mcl_fishing_fishing_rod.png^[transformFY^[transformR90",
|
||||
wield_scale = { x = 1.5, y = 1.5, z = 1 },
|
||||
stack_max = 1,
|
||||
on_place = fish,
|
||||
|
|
Binary file not shown.
Before Width: | Height: | Size: 2.3 KiB After Width: | Height: | Size: 359 B |
|
@ -227,6 +227,8 @@ filled_wield_def.drawtype = "mesh"
|
|||
filled_wield_def.node_placement_prediction = ""
|
||||
filled_wield_def.range = minetest.registered_items[""].range
|
||||
filled_wield_def.on_place = mcl_util.call_on_rightclick
|
||||
filled_wield_def.groups.no_wieldview = 1
|
||||
filled_wield_def._wieldview_item = "mcl_maps:filled_map"
|
||||
|
||||
for _, texture in pairs(mcl_skins.list) do
|
||||
local def = table.copy(filled_wield_def)
|
||||
|
|
|
@ -321,7 +321,7 @@ minetest.register_tool("mcl_mobitems:carrot_on_a_stick", {
|
|||
_tt_help = S("Lets you ride a saddled pig"),
|
||||
_doc_items_longdesc = S("A carrot on a stick can be used on saddled pigs to ride them."),
|
||||
_doc_items_usagehelp = S("Place it on a saddled pig to mount it. You can now ride the pig like a horse. Pigs will also walk towards you when you just wield the carrot on a stick."),
|
||||
wield_image = "mcl_mobitems_carrot_on_a_stick.png",
|
||||
wield_image = "mcl_mobitems_carrot_on_a_stick.png^[transformFY^[transformR90",
|
||||
inventory_image = "mcl_mobitems_carrot_on_a_stick.png",
|
||||
groups = { transport = 1 },
|
||||
_mcl_toollike_wield = true,
|
||||
|
|
|
@ -103,10 +103,6 @@ function mcl_player.player_set_armor(player, texture)
|
|||
set_texture(player, 2, texture)
|
||||
end
|
||||
|
||||
function mcl_player.player_set_wielditem(player, texture)
|
||||
set_texture(player, 3, texture)
|
||||
end
|
||||
|
||||
function mcl_player.get_player_formspec_model(player, x, y, w, h, fsname)
|
||||
local name = player:get_player_name()
|
||||
local model = player_model[name]
|
||||
|
|
|
@ -359,15 +359,17 @@ minetest.register_globalstep(function(dtime)
|
|||
end
|
||||
|
||||
if wielded_def and wielded_def._mcl_toollike_wield then
|
||||
set_bone_position_conditional(player,"Wield_Item", vector.new(0,3.9,1.3), vector.new(90,0,0))
|
||||
set_bone_position_conditional(player,"Wield_Item", vector.new(0,4.7,3.1), vector.new(-90,225,90))
|
||||
elseif string.find(wielded:get_name(), "mcl_bows:bow") then
|
||||
set_bone_position_conditional(player,"Wield_Item", vector.new(.5,4.5,-1.6), vector.new(90,0,20))
|
||||
set_bone_position_conditional(player,"Wield_Item", vector.new(1,4,0), vector.new(90,130,115))
|
||||
elseif string.find(wielded:get_name(), "mcl_bows:crossbow_loaded") then
|
||||
set_bone_position_conditional(player,"Wield_Item", vector.new(-1.5,5.7,1.8), vector.new(64,90,0))
|
||||
set_bone_position_conditional(player,"Wield_Item", vector.new(0,5.2,1.2), vector.new(0,180,73))
|
||||
elseif string.find(wielded:get_name(), "mcl_bows:crossbow") then
|
||||
set_bone_position_conditional(player,"Wield_Item", vector.new(-1.5,5.7,1.8), vector.new(90,90,0))
|
||||
set_bone_position_conditional(player,"Wield_Item", vector.new(0,5.2,1.2), vector.new(0,180,45))
|
||||
elseif wielded_def.inventory_image == "" then
|
||||
set_bone_position_conditional(player,"Wield_Item", vector.new(0,6,2), vector.new(180,-45,0))
|
||||
else
|
||||
set_bone_position_conditional(player,"Wield_Item", vector.new(-1.5,4.9,1.8), vector.new(135,0,90))
|
||||
set_bone_position_conditional(player,"Wield_Item", vector.new(0,5.3,2), vector.new(90,0,0))
|
||||
end
|
||||
|
||||
-- controls right and left arms pitch when shooting a bow or blocking
|
||||
|
|
|
@ -3,19 +3,10 @@
|
|||
|
||||
Makes hand wielded items visible to other players.
|
||||
|
||||
default settings: [minetest.conf]
|
||||
|
||||
# Set number of seconds between visible wielded item updates.
|
||||
wieldview_update_time = 2
|
||||
|
||||
# Show nodes as tiles, disabled by default
|
||||
wieldview_node_tiles = false
|
||||
|
||||
|
||||
Info for modders
|
||||
################
|
||||
|
||||
Wield image transformation: To apply a simple transformation to the item in
|
||||
hand, add the group “wieldview_transform” to the item definition. The group
|
||||
rating equals one of the numbers used for the [transform texture modifier
|
||||
of the Lua API.
|
||||
Add an item to the "no_wieldview" group with a rating of 1 and it will not be shown by the wieldview.
|
||||
If an item has the "no_wieldview" group rating of 1, the item definition can specify the property "_wieldview_item".
|
||||
"_wieldview_item" should be set to an item name that will be shown by the wieldview instead of the item.
|
||||
|
|
|
@ -1,126 +1,49 @@
|
|||
local get_connected_players = minetest.get_connected_players
|
||||
local get_item_group = minetest.get_item_group
|
||||
|
||||
mcl_wieldview = {
|
||||
players = {}
|
||||
}
|
||||
|
||||
function mcl_wieldview.get_item_texture(itemname)
|
||||
if itemname == "" or minetest.get_item_group(itemname, "no_wieldview") ~= 0 then
|
||||
return
|
||||
end
|
||||
|
||||
local def = minetest.registered_items[itemname]
|
||||
if not def then
|
||||
return
|
||||
end
|
||||
|
||||
local inv_image = def.inventory_image
|
||||
if inv_image == "" then
|
||||
return
|
||||
end
|
||||
|
||||
local texture = inv_image
|
||||
|
||||
local transform = get_item_group(itemname, "wieldview_transform")
|
||||
if transform then
|
||||
-- This actually works with groups ratings because transform1, transform2, etc.
|
||||
-- have meaning and transform0 is used for identidy, so it can be ignored
|
||||
texture = texture .. "^[transform" .. transform
|
||||
end
|
||||
|
||||
return texture
|
||||
end
|
||||
|
||||
function mcl_wieldview.update_wielded_item(player)
|
||||
if not player then
|
||||
return
|
||||
end
|
||||
local itemstack = player:get_wielded_item()
|
||||
local itemname = itemstack:get_name()
|
||||
|
||||
local def = mcl_wieldview.players[player]
|
||||
|
||||
if def.item == itemname then
|
||||
return
|
||||
end
|
||||
|
||||
def.item = itemname
|
||||
def.texture = mcl_wieldview.get_item_texture(itemname) or "blank.png"
|
||||
|
||||
mcl_player.player_set_wielditem(player, def.texture)
|
||||
end
|
||||
|
||||
minetest.register_on_joinplayer(function(player)
|
||||
mcl_wieldview.players[player] = {item = "", texture = "blank.png"}
|
||||
|
||||
minetest.after(0, function()
|
||||
if not player:is_player() then
|
||||
return
|
||||
end
|
||||
|
||||
mcl_wieldview.update_wielded_item(player)
|
||||
|
||||
local itementity = minetest.add_entity(player:get_pos(), "mcl_wieldview:wieldnode")
|
||||
itementity:set_attach(player, "Hand_Right", vector.new(0, 1, 0), vector.new(90, 0, 45))
|
||||
itementity:get_luaentity().wielder = player
|
||||
end)
|
||||
end)
|
||||
|
||||
minetest.register_on_leaveplayer(function(player)
|
||||
mcl_wieldview.players[player] = nil
|
||||
end)
|
||||
|
||||
minetest.register_globalstep(function()
|
||||
local players = get_connected_players()
|
||||
for i = 1, #players do
|
||||
mcl_wieldview.update_wielded_item(players[i])
|
||||
if not player or not player:is_player() then
|
||||
return
|
||||
end
|
||||
local itementity = minetest.add_entity(player:get_pos(), "mcl_wieldview:wieldnode")
|
||||
if not itementity then return end
|
||||
itementity:set_attach(player, "Wield_Item", vector.new(0, 0, 0), vector.new(0, 0, 0))
|
||||
--itementity:set_attach(player, "Hand_Right", vector.new(0, 1, 0), vector.new(90, 45, 90))
|
||||
itementity:get_luaentity()._wielder = player
|
||||
end)
|
||||
|
||||
minetest.register_entity("mcl_wieldview:wieldnode", {
|
||||
initial_properties = {
|
||||
hp_max = 1,
|
||||
visual = "wielditem",
|
||||
physical = false,
|
||||
textures = {""},
|
||||
automatic_rotate = 1.5,
|
||||
is_visible = true,
|
||||
pointable = false,
|
||||
collide_with_objects = false,
|
||||
static_save = false,
|
||||
collisionbox = {-0.21, -0.21, -0.21, 0.21, 0.21, 0.21},
|
||||
selectionbox = {-0.21, -0.21, -0.21, 0.21, 0.21, 0.21},
|
||||
visual_size = {x = 0.21, y = 0.21},
|
||||
},
|
||||
|
||||
itemstring = "",
|
||||
|
||||
visual = "wielditem",
|
||||
physical = false,
|
||||
pointable = false,
|
||||
collide_with_objects = false,
|
||||
static_save = false,
|
||||
visual_size = {x = 0.21, y = 0.21},
|
||||
on_step = function(self)
|
||||
if self.wielder:is_player() then
|
||||
local def = mcl_wieldview.players[self.wielder]
|
||||
local itemstring = def.item
|
||||
|
||||
if self.itemstring ~= itemstring then
|
||||
local itemdef = minetest.registered_items[itemstring]
|
||||
self.object:set_properties({glow = itemdef and itemdef.light_source or 0})
|
||||
|
||||
-- wield item as cubic
|
||||
if def.texture == "blank.png" then
|
||||
self.object:set_properties({textures = {itemstring}})
|
||||
-- wield item as flat
|
||||
else
|
||||
self.object:set_properties({textures = {""}})
|
||||
end
|
||||
|
||||
if minetest.get_item_group(itemstring, "no_wieldview") ~= 0 then
|
||||
self.object:set_properties({textures = {""}})
|
||||
end
|
||||
|
||||
self.itemstring = itemstring
|
||||
end
|
||||
else
|
||||
if not self._wielder or not self._wielder:is_player() then
|
||||
self.object:remove()
|
||||
end
|
||||
local player = self._wielder
|
||||
|
||||
local item = player:get_wielded_item():get_name()
|
||||
|
||||
if item == self._item then return end
|
||||
|
||||
self._item = item
|
||||
|
||||
if get_item_group(item, "no_wieldview") ~= 0 then
|
||||
local def = player:get_wielded_item():get_definition()
|
||||
if def and def._wieldview_item then
|
||||
item = def._wieldview_item
|
||||
else
|
||||
item = ""
|
||||
end
|
||||
end
|
||||
|
||||
local item_def = minetest.registered_items[item]
|
||||
self.object:set_properties({
|
||||
glow = item_def and item_def.light_source or 0,
|
||||
wield_item = item,
|
||||
is_visible = item ~= ""
|
||||
})
|
||||
end,
|
||||
})
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
name = mcl_wieldview
|
||||
author = stujones11
|
||||
description = Makes hand wielded items visible to other players.
|
||||
depends = mcl_player
|
||||
depends = mcl_armor, mcl_playerplus
|
||||
|
|
Loading…
Reference in New Issue