Improved X-Ray, added AutoEject
This commit is contained in:
28
clientmods/dragonfire/inventory/autoeject.lua
Normal file
28
clientmods/dragonfire/inventory/autoeject.lua
Normal file
@@ -0,0 +1,28 @@
|
||||
local old_index
|
||||
|
||||
minetest.register_globalstep(function()
|
||||
if inventory_mod.nodrop then
|
||||
inventory_mod.nodrop = false
|
||||
return
|
||||
end
|
||||
local player = minetest.localplayer
|
||||
if old_index then
|
||||
player:set_wield_index(old_index)
|
||||
minetest.set_keypress("drop", false)
|
||||
old_index = nil
|
||||
elseif minetest.settings:get_bool("autoeject") then
|
||||
local list = (minetest.settings:get("eject_items") or ""):split(",")
|
||||
local inventory = minetest.get_inventory("current_player")
|
||||
for index, stack in pairs(inventory.main) do
|
||||
if table.indexof(list, stack:get_name()) ~= -1 then
|
||||
old_index = player:get_wield_index()
|
||||
player:set_wield_index(index - 1)
|
||||
minetest.set_keypress("drop", true) -- causes to drop tools selected using autotool sometimes, just
|
||||
return
|
||||
end
|
||||
end
|
||||
end
|
||||
end)
|
||||
|
||||
minetest.register_chatcommand("eject", list.new("Configure AutoEject", "eject_items"))
|
||||
minetest.register_cheat("AutoEject", "Player", "autoeject")
|
@@ -1,8 +1,11 @@
|
||||
inventory_mod = {}
|
||||
|
||||
local modname = minetest.get_current_modname()
|
||||
local modpath = minetest.get_modpath(modname)
|
||||
|
||||
dofile(modpath .. "/invhack.lua")
|
||||
dofile(modpath .. "/enderchest.lua")
|
||||
dofile(modpath .. "/next_item.lua")
|
||||
dofile(modpath .. "/enderchest.lua")
|
||||
dofile(modpath .. "/hand.lua")
|
||||
dofile(modpath .. "/next_item.lua")
|
||||
dofile(modpath .. "/autotool.lua")
|
||||
dofile(modpath .. "/hand.lua")
|
||||
dofile(modpath .. "/autoeject.lua")
|
||||
|
@@ -1,3 +1,4 @@
|
||||
name = inventory
|
||||
author = Fleckenstein
|
||||
description = The inventory cheats for Dragonfireclient
|
||||
dependencies = list
|
||||
|
@@ -1,2 +1,4 @@
|
||||
next_item (NextItem) bool false
|
||||
autotool (AutoTool) bool false
|
||||
autoeject (AutoEject) bool false
|
||||
eject_items (AutoEject Items) string
|
||||
|
47
clientmods/dragonfire/list/init.lua
Normal file
47
clientmods/dragonfire/list/init.lua
Normal file
@@ -0,0 +1,47 @@
|
||||
list = {}
|
||||
|
||||
function list.new(desc, setting)
|
||||
local def = {}
|
||||
def.description = desc
|
||||
def.params = "del <item> | add <item> | list"
|
||||
function def.func(param)
|
||||
local list = (minetest.settings:get(setting) or ""):split(",")
|
||||
if param == "list" then
|
||||
return true, table.concat(list, ", ")
|
||||
else
|
||||
local sparam = param:split(" ")
|
||||
local cmd = sparam[1]
|
||||
local item = sparam[2]
|
||||
if cmd == "del" then
|
||||
if not item then
|
||||
return false, "Missing item."
|
||||
end
|
||||
local i = table.indexof(list, item)
|
||||
if i == -1 then
|
||||
return false, item .. " is not on the list."
|
||||
else
|
||||
table.remove(list, i)
|
||||
minetest.settings:set(setting, table.concat(list, ","))
|
||||
return true, "Removed " .. item .. " from the list."
|
||||
end
|
||||
elseif cmd == "add" then
|
||||
if not item then
|
||||
return false, "Missing item."
|
||||
end
|
||||
local i = table.indexof(list, item)
|
||||
if i ~= -1 then
|
||||
return false, item .. " is already on the list."
|
||||
else
|
||||
table.insert(list, item)
|
||||
minetest.settings:set(setting, table.concat(list, ","))
|
||||
return true, "Added " .. item .. " to the list."
|
||||
end
|
||||
end
|
||||
end
|
||||
return false, "Invalid usage. (See /help <command>)"
|
||||
end
|
||||
return def
|
||||
end
|
||||
|
||||
minetest.register_chatcommand("xray", list.new("Configure X-Ray", "xray_nodes"))
|
||||
--minetest.register_chatcommand("Configure Search Nodes", "search_nodes")
|
@@ -9,3 +9,4 @@ load_mod_pathfinding = true
|
||||
load_mod_autoeat = true
|
||||
load_mod_perlin = true
|
||||
load_mod_autosneak = true
|
||||
load_mod_list = true
|
||||
|
Reference in New Issue
Block a user