mirror of
https://github.com/sys4-fr/server-nalc.git
synced 2025-06-28 14:16:06 +02:00
initial commit
subgame + mods
This commit is contained in:
30
mods/intweak/README.txt
Executable file
30
mods/intweak/README.txt
Executable file
@ -0,0 +1,30 @@
|
||||
Minetest mod "Inventory Tweak"
|
||||
==============================
|
||||
version: 1.2.2
|
||||
|
||||
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 implements two new functions to the players inventory. First is a 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
Executable file
1
mods/intweak/depends.txt
Executable file
@ -0,0 +1 @@
|
||||
default
|
65
mods/intweak/init.lua
Executable file
65
mods/intweak/init.lua
Executable file
@ -0,0 +1,65 @@
|
||||
local auto_refill = true -- 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 minetest.setting_getbool("creative_mode") then
|
||||
return true
|
||||
else
|
||||
if cnt == 0 then
|
||||
minetest.after(0.01, refill, placer, newnode.name, index)
|
||||
end
|
||||
end
|
||||
end)
|
||||
end
|
||||
|
||||
|
||||
local ttyp = {}
|
||||
local tools = {}
|
||||
|
||||
minetest.register_on_punchnode(function(pos, node, puncher)
|
||||
if not puncher then return end
|
||||
if minetest.setting_getbool("creative_mode") then return end
|
||||
local pn = puncher:get_player_name()
|
||||
tools[pn] = puncher:get_wielded_item():get_name()
|
||||
ttyp[pn] = minetest.registered_items[tools[pn]].type
|
||||
local left = puncher:get_wielded_item():get_wear() + 65535/65--)
|
||||
local tab = minetest.registered_tools[tools[pn]]
|
||||
if tab == nil then return end
|
||||
local left = tonumber(dump(tab["uses"]))
|
||||
if left == nil then return end
|
||||
left = puncher:get_wielded_item():get_wear() + 65535/left
|
||||
if ttyp[pn] == "tool" and left >= 65535 then
|
||||
minetest.sound_play("intweak_tool_break", {pos = puncher:getpos(), gain = 1, max_hear_distance = 5})
|
||||
if auto_refill == true then minetest.after(0.01, refill, puncher, tools[pn], puncher:get_wield_index()) end
|
||||
end
|
||||
end)
|
||||
|
||||
minetest.register_on_dignode(function(pos, oldnode, digger)
|
||||
if not digger then return end
|
||||
if minetest.setting_getbool("creative_mode") then return end
|
||||
local pn = digger:get_player_name()
|
||||
local num = digger:get_wielded_item():get_wear()
|
||||
local index = digger:get_wield_index()
|
||||
if num == 0 and ttyp[pn] == "tool" and digger:get_wielded_item():get_name() == "" then
|
||||
minetest.sound_play("intweak_tool_break", {pos = digger:getpos(),gain = 1, max_hear_distance = 5})
|
||||
if auto_refill == true then minetest.after(0.01, refill, digger, tools[pn], index) end
|
||||
end
|
||||
end)
|
||||
|
||||
print("[Mod] Inventory Tweak _loaded")
|
BIN
mods/intweak/sounds/intweak_tool_break.ogg
Executable file
BIN
mods/intweak/sounds/intweak_tool_break.ogg
Executable file
Binary file not shown.
Reference in New Issue
Block a user