From bb8c7447c9b544d0fd4bed7a46b4ce49d3ae5903 Mon Sep 17 00:00:00 2001 From: Wuzzy Date: Thu, 30 Mar 2017 05:28:47 +0200 Subject: [PATCH] Import new version of wieldview mod (Jan 8 2017) --- .../minetest-3d_armor/wieldview/LICENSE.txt | 5 ++ .../minetest-3d_armor/wieldview/README.txt | 15 ++++ .../minetest-3d_armor/wieldview/depends.txt | 1 + .../wieldview/description.txt | 1 + .../minetest-3d_armor/wieldview/init.lua | 76 +++++++++++++++++++ .../minetest-3d_armor/wieldview/transform.lua | 24 ++++++ 6 files changed, 122 insertions(+) create mode 100644 mods/ITEMS/minetest-3d_armor/wieldview/LICENSE.txt create mode 100644 mods/ITEMS/minetest-3d_armor/wieldview/README.txt create mode 100644 mods/ITEMS/minetest-3d_armor/wieldview/depends.txt create mode 100644 mods/ITEMS/minetest-3d_armor/wieldview/description.txt create mode 100644 mods/ITEMS/minetest-3d_armor/wieldview/init.lua create mode 100644 mods/ITEMS/minetest-3d_armor/wieldview/transform.lua diff --git a/mods/ITEMS/minetest-3d_armor/wieldview/LICENSE.txt b/mods/ITEMS/minetest-3d_armor/wieldview/LICENSE.txt new file mode 100644 index 000000000..4e8d524b8 --- /dev/null +++ b/mods/ITEMS/minetest-3d_armor/wieldview/LICENSE.txt @@ -0,0 +1,5 @@ +[mod] visible wielded items [wieldview] +======================================= + +License Source Code: Copyright (C) 2013-2017 Stuart Jones - LGPL v2.1 + diff --git a/mods/ITEMS/minetest-3d_armor/wieldview/README.txt b/mods/ITEMS/minetest-3d_armor/wieldview/README.txt new file mode 100644 index 000000000..e6be7490a --- /dev/null +++ b/mods/ITEMS/minetest-3d_armor/wieldview/README.txt @@ -0,0 +1,15 @@ +[mod] visible wielded items [wieldview] +======================================= + +Depends on: 3d_armor + +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 + diff --git a/mods/ITEMS/minetest-3d_armor/wieldview/depends.txt b/mods/ITEMS/minetest-3d_armor/wieldview/depends.txt new file mode 100644 index 000000000..b6cac2191 --- /dev/null +++ b/mods/ITEMS/minetest-3d_armor/wieldview/depends.txt @@ -0,0 +1 @@ +3d_armor diff --git a/mods/ITEMS/minetest-3d_armor/wieldview/description.txt b/mods/ITEMS/minetest-3d_armor/wieldview/description.txt new file mode 100644 index 000000000..0d51ad954 --- /dev/null +++ b/mods/ITEMS/minetest-3d_armor/wieldview/description.txt @@ -0,0 +1 @@ +Makes hand wielded items visible to other players. diff --git a/mods/ITEMS/minetest-3d_armor/wieldview/init.lua b/mods/ITEMS/minetest-3d_armor/wieldview/init.lua new file mode 100644 index 000000000..7a5a61994 --- /dev/null +++ b/mods/ITEMS/minetest-3d_armor/wieldview/init.lua @@ -0,0 +1,76 @@ +local time = 0 +local update_time = tonumber(minetest.setting_get("wieldview_update_time")) +if not update_time then + update_time = 2 + minetest.setting_set("wieldview_update_time", tostring(update_time)) +end +local node_tiles = minetest.setting_getbool("wieldview_node_tiles") +if not node_tiles then + node_tiles = false + minetest.setting_set("wieldview_node_tiles", "false") +end + +wieldview = { + wielded_item = {}, + transform = {}, +} + +dofile(minetest.get_modpath(minetest.get_current_modname()).."/transform.lua") + +wieldview.get_item_texture = function(self, item) + local texture = "3d_armor_trans.png" + if item ~= "" then + if minetest.registered_items[item] then + if minetest.registered_items[item].inventory_image ~= "" then + texture = minetest.registered_items[item].inventory_image + elseif node_tiles == true and minetest.registered_items[item].tiles + and type(minetest.registered_items[item].tiles[1]) == "string" + and minetest.registered_items[item].tiles[1] ~= "" then + texture = minetest.inventorycube(minetest.registered_items[item].tiles[1]) + end + end + if wieldview.transform[item] then + texture = texture.."^[transform"..wieldview.transform[item] + end + end + return texture +end + +wieldview.update_wielded_item = function(self, player) + if not player then + return + end + local name = player:get_player_name() + local stack = player:get_wielded_item() + local item = stack:get_name() + if not item then + return + end + if self.wielded_item[name] then + if self.wielded_item[name] == item then + return + end + armor.textures[name].wielditem = self:get_item_texture(item) + armor:update_player_visuals(player) + end + self.wielded_item[name] = item +end + +minetest.register_on_joinplayer(function(player) + local name = player:get_player_name() + wieldview.wielded_item[name] = "" + minetest.after(0, function(player) + wieldview:update_wielded_item(player) + end, player) +end) + +minetest.register_globalstep(function(dtime) + time = time + dtime + if time > update_time then + for _,player in ipairs(minetest.get_connected_players()) do + wieldview:update_wielded_item(player) + end + time = 0 + end +end) + diff --git a/mods/ITEMS/minetest-3d_armor/wieldview/transform.lua b/mods/ITEMS/minetest-3d_armor/wieldview/transform.lua new file mode 100644 index 000000000..4d5133e8b --- /dev/null +++ b/mods/ITEMS/minetest-3d_armor/wieldview/transform.lua @@ -0,0 +1,24 @@ +-- Wielded Item Transformations - http://dev.minetest.net/texture + +wieldview.transform = { + ["default:torch"]="R270", + ["default:sapling"]="R270", + ["flowers:dandelion_white"]="R270", + ["flowers:dandelion_yellow"]="R270", + ["flowers:geranium"]="R270", + ["flowers:rose"]="R270", + ["flowers:tulip"]="R270", + ["flowers:viola"]="R270", + ["bucket:bucket_empty"]="R270", + ["bucket:bucket_water"]="R270", + ["bucket:bucket_lava"]="R270", + ["screwdriver:screwdriver"]="R270", + ["screwdriver:screwdriver1"]="R270", + ["screwdriver:screwdriver2"]="R270", + ["screwdriver:screwdriver3"]="R270", + ["screwdriver:screwdriver4"]="R270", + ["vessels:glass_bottle"]="R270", + ["vessels:drinking_glass"]="R270", + ["vessels:steel_bottle"]="R270", +} +