version 0.21
This commit is contained in:
parent
bd1233aaf1
commit
c8d70b992c
1717 changed files with 68882 additions and 0 deletions
29
mods/intweak/README.txt
Normal file
29
mods/intweak/README.txt
Normal file
|
@ -0,0 +1,29 @@
|
|||
Minetest mod "Inventory Tweak"
|
||||
=======================
|
||||
version: 1.0
|
||||
|
||||
License of source code: WTFPL
|
||||
-----------------------------
|
||||
Written 2013 by BlockMen
|
||||
|
||||
This program is free software. It comes without any warranty, to
|
||||
the extent permitted by applicable law. You can redistribute it
|
||||
and/or modify it under the terms of the Do What The Fuck You Want
|
||||
To Public License, Version 2, as published by Sam Hocevar. See
|
||||
http://sam.zoy.org/wtfpl/COPYING for more details.
|
||||
|
||||
License of sounds:
|
||||
------------------
|
||||
intweak_break_tool.ogg by EdgardEdition (CC BY 3.0), http://www.freesound.org/people/EdgardEdition
|
||||
|
||||
|
||||
--USING the mod--
|
||||
------------------
|
||||
|
||||
This mod inplements to new functions to the players inventory. The first is the breaking sound of any tool,
|
||||
that is played when a tool breakes after the specific number of uses.
|
||||
|
||||
The second new function is Auto-refill. This function replaces broken tools or emptied stacks with others from your inventory.
|
||||
|
||||
|
||||
You can disable the auto-refill by changing first line of init.lua to "local auto_refill = false"
|
1
mods/intweak/depends.txt
Normal file
1
mods/intweak/depends.txt
Normal file
|
@ -0,0 +1 @@
|
|||
default
|
45
mods/intweak/init.lua
Normal file
45
mods/intweak/init.lua
Normal file
|
@ -0,0 +1,45 @@
|
|||
local auto_refill = false -- set to false if you dont want get refilled your stack automatic
|
||||
|
||||
function refill(player, stck_name, index)
|
||||
local inv = player:get_inventory()
|
||||
for i,stack in ipairs(inv:get_list("main")) do
|
||||
if stack:get_name() == stck_name then
|
||||
inv:set_stack("main", index, stack)
|
||||
stack:clear()
|
||||
inv:set_stack("main", i, stack)
|
||||
minetest.log("action", "intweak-mod: refilled stack of" .. player:get_player_name() )
|
||||
return
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
if auto_refill == true then
|
||||
minetest.register_on_placenode(function(pos, newnode, placer, oldnode)
|
||||
if not placer then return end
|
||||
local index = placer:get_wield_index()
|
||||
local cnt = placer:get_wielded_item():get_count()-1
|
||||
if cnt == 0 then minetest.after(0.01, refill, placer, newnode.name, index) end
|
||||
end)
|
||||
end
|
||||
|
||||
local typ = ""
|
||||
local tname = ""
|
||||
minetest.register_on_punchnode(function(pos, node, puncher)
|
||||
if not puncher then return end
|
||||
tname = puncher:get_wielded_item():get_name()
|
||||
typ = minetest.registered_items[tname].type
|
||||
if typ == "tool" and puncher:get_wielded_item():get_wear() == 65535 then
|
||||
minetest.sound_play("intweak_tool_break", {gain = 1.5, max_hear_distance = 5})
|
||||
if auto_refill == true then minetest.after(0.01, refill, puncher, tname, puncher:get_wield_index()) end
|
||||
end
|
||||
end)
|
||||
|
||||
minetest.register_on_dignode(function(pos, oldnode, digger)
|
||||
if not digger then return end
|
||||
local num = digger:get_wielded_item():get_wear()
|
||||
local index = digger:get_wield_index()
|
||||
if num == 0 and typ == "tool" then
|
||||
minetest.sound_play("intweak_tool_break", {gain = 1.5, max_hear_distance = 5})
|
||||
if auto_refill == true then minetest.after(0.01, refill, digger, tname, index) end
|
||||
end
|
||||
end)
|
BIN
mods/intweak/sounds/intweak_tool_break.ogg
Normal file
BIN
mods/intweak/sounds/intweak_tool_break.ogg
Normal file
Binary file not shown.
Loading…
Add table
Add a link
Reference in a new issue