Initial commit
commit
9769907c86
|
@ -0,0 +1,14 @@
|
|||
DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE
|
||||
Version 2, December 2004
|
||||
|
||||
Copyright (C) 2004 Sam Hocevar <sam@hocevar.net>
|
||||
|
||||
Everyone is permitted to copy and distribute verbatim or modified
|
||||
copies of this license document, and changing it is allowed as long
|
||||
as the name is changed.
|
||||
|
||||
DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE
|
||||
TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
|
||||
|
||||
0. You just DO WHAT THE FUCK YOU WANT TO.
|
||||
|
|
@ -0,0 +1,14 @@
|
|||
Modmenu - Simple menu for mod actions
|
||||
License: WTFPL
|
||||
Requires Minetest 0.4.5 or later
|
||||
|
||||
This mod provides an in-game menu that can be used to access formspecs of other
|
||||
mods which add buttons to it. The menu can be accessed by typing "/m" in the
|
||||
in-game chat.
|
||||
|
||||
This modpack also includes a compatibility mod for inventory_plus (written from
|
||||
scratch), which places mods that use inventory_plus.register_button() in the
|
||||
menu as well. This should allow mods that previously used inventory_plus to work
|
||||
with other mods that change the inventory (such as Unified Inventory).
|
||||
If you want to use the original inventory_plus, remove the inventory_plus folder
|
||||
from this modpack.
|
|
@ -0,0 +1,4 @@
|
|||
This is a compatibility mod that provides the api of inventory_plus using
|
||||
minetest.show_formspec() and modmenu (part of this modpack) for buttons.
|
||||
This is written from scratch, with some examination of Zeg9's skins mod (WTFPL)
|
||||
to learn how mods used inventory_plus functions.
|
|
@ -0,0 +1 @@
|
|||
modmenu
|
|
@ -0,0 +1,24 @@
|
|||
--inventory_plus compatibility wrapper for use with modmenu
|
||||
|
||||
--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://www.wtfpl.net/ for more details.
|
||||
|
||||
inventory_plus = {}
|
||||
|
||||
inventory_plus.set_inventory_formspec = function(player, formspec)
|
||||
minetest.show_formspec(player:get_player_name(), "custom", formspec)
|
||||
end
|
||||
|
||||
inventory_plus.register_button = function(player, button_name, button_text)
|
||||
modmenu.add_button(player:get_player_name(), button_name, button_text)
|
||||
end
|
||||
|
||||
--handle the "Back" button on inv. plus forms (such as skins/3d armor)
|
||||
minetest.register_on_player_receive_fields(function(player,formname,fields)
|
||||
if fields.main then
|
||||
modmenu.show_menu(player:get_player_name())
|
||||
end
|
||||
end)
|
|
@ -0,0 +1,53 @@
|
|||
--Modmenu - Simple menu for mod actions
|
||||
|
||||
--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://www.wtfpl.net/ for more details.
|
||||
|
||||
modmenu = {}
|
||||
modmenu.users = {}
|
||||
|
||||
--Adds a button to a player's menu
|
||||
--Parameters:
|
||||
-- name - name of player to add the button for
|
||||
-- button_name - name that will be submitted in fields.*
|
||||
-- button_text - label for the button in the menu
|
||||
modmenu.add_button = function(name, button_name, button_text)
|
||||
--Don't crash if user doesn't have any buttons yet
|
||||
if modmenu.users[name] == nil then
|
||||
modmenu.users[name] = {}
|
||||
end
|
||||
table.insert(modmenu.users[name], {button_name,button_text})
|
||||
end
|
||||
|
||||
--Builds the formspec to display
|
||||
--Use modmenu.show_menu() in other mods instead (if needed)
|
||||
modmenu.get_formspec = function(name)
|
||||
local spec = "size[3,8;]label[1,0;Menu]"
|
||||
local pos = 1
|
||||
if modmenu.users[name] ~= nil then
|
||||
for i,button in ipairs((modmenu.users[name])) do
|
||||
spec = spec .. "button[0," .. pos ..";3,1;" .. button[1] .. ";" .. button[2] .. "]"
|
||||
pos = pos + 1
|
||||
end
|
||||
end
|
||||
spec = spec .. "button_exit[0," .. pos .. ";3,1;close;Close]"
|
||||
return spec
|
||||
end
|
||||
|
||||
--Shows the menu to a player
|
||||
--Parameters:
|
||||
-- name: name of player who will be shown the menu
|
||||
modmenu.show_menu = function(name)
|
||||
minetest.show_formspec(name, "modmenu", modmenu.get_formspec(name))
|
||||
end
|
||||
|
||||
--Register the /m command to show the menu
|
||||
minetest.register_chatcommand("m", {
|
||||
description = "Show a menu for various actions",
|
||||
func = function(name, param)
|
||||
modmenu.show_menu(name)
|
||||
end,
|
||||
})
|
Loading…
Reference in New Issue