commit 9769907c861edcbcc72872982d03a88e8cc45be8 Author: Brent Hull Date: Thu May 2 21:06:30 2013 -0400 Initial commit diff --git a/COPYING b/COPYING new file mode 100644 index 0000000..ee7d6a5 --- /dev/null +++ b/COPYING @@ -0,0 +1,14 @@ + DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE + Version 2, December 2004 + + Copyright (C) 2004 Sam Hocevar + + 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. + diff --git a/README.txt b/README.txt new file mode 100644 index 0000000..28abe27 --- /dev/null +++ b/README.txt @@ -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. diff --git a/inventory_plus/README.txt b/inventory_plus/README.txt new file mode 100644 index 0000000..e3a6199 --- /dev/null +++ b/inventory_plus/README.txt @@ -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. diff --git a/inventory_plus/depends.txt b/inventory_plus/depends.txt new file mode 100644 index 0000000..fd9f8a6 --- /dev/null +++ b/inventory_plus/depends.txt @@ -0,0 +1 @@ +modmenu diff --git a/inventory_plus/init.lua b/inventory_plus/init.lua new file mode 100644 index 0000000..956d466 --- /dev/null +++ b/inventory_plus/init.lua @@ -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) diff --git a/modmenu/init.lua b/modmenu/init.lua new file mode 100644 index 0000000..a011408 --- /dev/null +++ b/modmenu/init.lua @@ -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, +}) diff --git a/modpack.txt b/modpack.txt new file mode 100644 index 0000000..e69de29