Add doors and wield3d
This commit is contained in:
parent
a0bc05941d
commit
df4855f7e7
31 changed files with 753 additions and 0 deletions
7
mods/wield32/.gitignore
vendored
Normal file
7
mods/wield32/.gitignore
vendored
Normal file
|
@ -0,0 +1,7 @@
|
|||
## Generic ignorable patterns and files
|
||||
*~
|
||||
.*.swp
|
||||
*bak*
|
||||
tags
|
||||
*.vim
|
||||
|
4
mods/wield32/LICENSE.md
Normal file
4
mods/wield32/LICENSE.md
Normal file
|
@ -0,0 +1,4 @@
|
|||
[mod] 3d wielded items [wield3d]
|
||||
================================
|
||||
|
||||
Copyright (C) 2013 Stuart Jones - WTFPL
|
15
mods/wield32/README.md
Normal file
15
mods/wield32/README.md
Normal file
|
@ -0,0 +1,15 @@
|
|||
[mod] 3d wielded items [wield3d]
|
||||
================================
|
||||
|
||||
Mod Version: 0.3.0
|
||||
|
||||
Minetest Version: 0.4.12 or later
|
||||
|
||||
Decription: Visible 3d wielded items for Minetest
|
||||
|
||||
Depends: default
|
||||
|
||||
Makes hand wielded items visible to other players.
|
||||
|
||||
See wield3d.conf.example for config options (save as wield3d.conf)
|
||||
|
2
mods/wield32/depends.txt
Normal file
2
mods/wield32/depends.txt
Normal file
|
@ -0,0 +1,2 @@
|
|||
default
|
||||
|
132
mods/wield32/init.lua
Normal file
132
mods/wield32/init.lua
Normal file
|
@ -0,0 +1,132 @@
|
|||
WIELD3D_INIT_DELAY = 1
|
||||
WIELD3D_RETRY_TIME = 10
|
||||
WIELD3D_UPDATE_TIME = 1
|
||||
|
||||
local modpath = minetest.get_modpath(minetest.get_current_modname())
|
||||
local input = io.open(modpath.."/wield3d.conf", "r")
|
||||
if input then
|
||||
dofile(modpath.."/wield3d.conf")
|
||||
input:close()
|
||||
input = nil
|
||||
end
|
||||
dofile(modpath.."/location.lua")
|
||||
|
||||
local location = {
|
||||
"Arm_Right", -- default bone
|
||||
{x=0.2, y=6.5, z=3}, -- default position
|
||||
{x=-100, y=225, z=90}, -- default rotation
|
||||
}
|
||||
local player_wielding = {}
|
||||
local timer = 0
|
||||
|
||||
local function add_wield_entity(player)
|
||||
local name = player:get_player_name()
|
||||
local pos = player:getpos()
|
||||
local inv = player:get_inventory()
|
||||
if name and pos and inv then
|
||||
local offset = {x=pos.x, y=pos.y + 0.5, z=pos.z}
|
||||
local object = minetest.add_entity(offset, "wield3d:wield_entity")
|
||||
if object then
|
||||
object:set_properties({collisionbox={0,0,0, 0,0,0}})
|
||||
object:set_attach(player, location[1], location[2], location[3])
|
||||
local entity = object:get_luaentity()
|
||||
if entity then
|
||||
entity.player = player
|
||||
player_wielding[name] = 1
|
||||
else
|
||||
object:remove()
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
minetest.register_item("wield3d:hand", {
|
||||
type = "none",
|
||||
wield_image = "wield3d_trans.png",
|
||||
})
|
||||
|
||||
minetest.register_entity("wield3d:wield_entity", {
|
||||
physical = false,
|
||||
collisionbox = {-0.125,-0.125,-0.125, 0.125,0.125,0.125},
|
||||
visual = "wielditem",
|
||||
visual_size = {x=0.25, y=0.25},
|
||||
textures = {"wield3d:hand"},
|
||||
player = nil,
|
||||
item = nil,
|
||||
timer = 0,
|
||||
location = {location[1], location[2], location[3]},
|
||||
on_step = function(self, dtime)
|
||||
self.timer = self.timer + dtime
|
||||
if self.timer < WIELD3D_UPDATE_TIME then
|
||||
return
|
||||
end
|
||||
self.timer = 0
|
||||
local player = self.player
|
||||
if player then
|
||||
local name = player:get_player_name()
|
||||
local p1 = player:getpos()
|
||||
local p2 = self.object:getpos()
|
||||
if p1 and p2 then
|
||||
if vector.equals(p1, p2) then
|
||||
local stack = player:get_wielded_item()
|
||||
local item = stack:get_name() or ""
|
||||
if item == self.item then
|
||||
return
|
||||
end
|
||||
if minetest.get_modpath("wieldview") then
|
||||
local def = minetest.registered_items[item] or {}
|
||||
if def.inventory_image ~= "" then
|
||||
item = ""
|
||||
end
|
||||
end
|
||||
self.item = item
|
||||
if item == "" then
|
||||
item = "wield3d:hand"
|
||||
end
|
||||
local loc = wield3d_location[item] or location
|
||||
if loc[1] ~= self.location[1]
|
||||
or vector.equals(loc[2], self.location[2]) == false
|
||||
or vector.equals(loc[3], self.location[3]) == false then
|
||||
self.object:set_detach()
|
||||
self.object:set_attach(player, loc[1], loc[2], loc[3])
|
||||
self.location = {loc[1], loc[2], loc[3]}
|
||||
end
|
||||
self.object:set_properties({textures={item}})
|
||||
return
|
||||
end
|
||||
end
|
||||
player_wielding[name] = 0
|
||||
end
|
||||
self.object:remove()
|
||||
end,
|
||||
})
|
||||
|
||||
minetest.register_globalstep(function(dtime)
|
||||
timer = timer + dtime
|
||||
if timer > WIELD3D_RETRY_TIME then
|
||||
for name, state in pairs(player_wielding) do
|
||||
if state == 0 then
|
||||
local player = minetest.get_player_by_name(name)
|
||||
if player then
|
||||
add_wield_entity(player)
|
||||
else
|
||||
player_wielding[name] = nil
|
||||
end
|
||||
end
|
||||
end
|
||||
timer = 0
|
||||
end
|
||||
end)
|
||||
|
||||
minetest.register_on_leaveplayer(function(player)
|
||||
local name = player:get_player_name()
|
||||
if name then
|
||||
player_wielding[name] = nil
|
||||
end
|
||||
end)
|
||||
|
||||
minetest.register_on_joinplayer(function(player)
|
||||
player_wielding[player:get_player_name()] = 0
|
||||
minetest.after(WIELD3D_INIT_DELAY, add_wield_entity, player)
|
||||
end)
|
||||
|
32
mods/wield32/location.lua
Normal file
32
mods/wield32/location.lua
Normal file
|
@ -0,0 +1,32 @@
|
|||
-- Wielded Item Location Overrides - [item_name] = {bone, position, rotation}
|
||||
|
||||
local bone = "Arm_Right"
|
||||
|
||||
wield3d_location = {
|
||||
["default:torch"] = {bone, {x=0.2, y=6.5, z=3}, {x=-100, y=182, z=83}},
|
||||
["default:sapling"] = {bone, {x=0.2, y=6.5, z=3}, {x=-100, y=182, z=83}},
|
||||
["flowers:dandelion_white"] = {bone, {x=0.2, y=6.5, z=3}, {x=-100, y=182, z=83}},
|
||||
["flowers:dandelion_yellow"] = {bone, {x=0.2, y=6.5, z=3}, {x=-100, y=182, z=83}},
|
||||
["flowers:geranium"] = {bone, {x=0.2, y=6.5, z=3}, {x=-100, y=182, z=83}},
|
||||
["flowers:rose"] = {bone, {x=0.2, y=6.5, z=3}, {x=-100, y=182, z=83}},
|
||||
["flowers:tulip"] = {bone, {x=0.2, y=6.5, z=3}, {x=-100, y=182, z=83}},
|
||||
["flowers:viola"] = {bone, {x=0.2, y=6.5, z=3}, {x=-100, y=182, z=83}},
|
||||
["default:shovel_wood"] = {bone, {x=0, y=6.5, z=3}, {x=-90, y=137, z=83}},
|
||||
["default:shovel_stone"] = {bone, {x=0, y=6.5, z=3}, {x=-90, y=137, z=83}},
|
||||
["default:shovel_steel"] = {bone, {x=0, y=6.5, z=3}, {x=-90, y=137, z=83}},
|
||||
["default:shovel_bronze"] = {bone, {x=0, y=6.5, z=3}, {x=-90, y=137, z=83}},
|
||||
["default:shovel_mese"] = {bone, {x=0, y=6.5, z=3}, {x=-90, y=137, z=83}},
|
||||
["default:shovel_diamond"] = {bone, {x=0, y=6.5, z=3}, {x=-90, y=137, z=83}},
|
||||
["bucket:bucket_empty"] = {bone, {x=0, y=6.5, z=3}, {x=-90, y=137, z=83}},
|
||||
["bucket:bucket_water"] = {bone, {x=0, y=6.5, z=3}, {x=-90, y=137, z=83}},
|
||||
["bucket:bucket_lava"] = {bone, {x=0, y=6.5, z=3}, {x=-90, y=137, z=83}},
|
||||
["screwdriver:screwdriver"] = {bone, {x=0, y=6.5, z=3}, {x=-90, y=137, z=83}},
|
||||
["screwdriver:screwdriver1"] = {bone, {x=0, y=6.5, z=3}, {x=-90, y=137, z=83}},
|
||||
["screwdriver:screwdriver2"] = {bone, {x=0, y=6.5, z=3}, {x=-90, y=137, z=83}},
|
||||
["screwdriver:screwdriver3"] = {bone, {x=0, y=6.5, z=3}, {x=-90, y=137, z=83}},
|
||||
["screwdriver:screwdriver4"] = {bone, {x=0, y=6.5, z=3}, {x=-90, y=137, z=83}},
|
||||
["vessels:glass_bottle"] = {bone, {x=0, y=6.5, z=3}, {x=-90, y=137, z=83}},
|
||||
["vessels:drinking_glass"] = {bone, {x=0, y=6.5, z=3}, {x=-90, y=137, z=83}},
|
||||
["vessels:steel_bottle"] = {bone, {x=0, y=6.5, z=3}, {x=-90, y=137, z=83}},
|
||||
}
|
||||
|
BIN
mods/wield32/textures/wield3d_trans.png
Normal file
BIN
mods/wield32/textures/wield3d_trans.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 146 B |
11
mods/wield32/wield3d.conf.example
Normal file
11
mods/wield32/wield3d.conf.example
Normal file
|
@ -0,0 +1,11 @@
|
|||
-- Wield3d Configuration (defaults)
|
||||
|
||||
-- Increase this if you get non-attachment glitches when a player first joins.
|
||||
WIELD3D_INIT_DELAY = 1
|
||||
|
||||
-- Number of seconds before retry if initialization fails.
|
||||
WIELD3D_RETRY_TIME = 10
|
||||
|
||||
-- How often player wield items are updated.
|
||||
WIELD3D_UPDATE_TIME = 1
|
||||
|
Loading…
Add table
Add a link
Reference in a new issue