Add "home_gui" mod.
This commit is contained in:
parent
ff84bc1b64
commit
6dccffa5c5
@ -30,6 +30,9 @@ The following mods are also included:
|
||||
* crafting/
|
||||
* [craft_guide][] ([BSD 3-Clause](mods/crafting/craft_guide/LICENSE))
|
||||
* display/
|
||||
* [bags][] ([BSD 3-Clause](mods/display/bags/LICENSE))
|
||||
* [compass][] (CC-BY-SA / WTFPL)
|
||||
* [home_gui][] ([BSD 3-Clause](mods/display/home_gui/README.md))
|
||||
* [inventory_plus][] ([BSD 3-Clause](mods/display/inventory_plus/LICENSE))
|
||||
* farming/
|
||||
* [farming_plus][] ([WTFPL](mods/farming/farming_plus/README.txt))
|
||||
@ -93,8 +96,6 @@ The following mods are also included:
|
||||
* [carts][] ([WTFPL/CC0](mods/transport/carts/README.txt))
|
||||
* [helicopter][] ([GPL](mods/transport/helicopter/LICENSE) / [CC-BY-NC](mods/transport/helicopter/README.md))
|
||||
* ui/
|
||||
* [bags][] ([BSD 3-Clause](mods/display/bags/LICENSE))
|
||||
* [compass][] (CC-BY-SA / WTFPL)
|
||||
* weather/
|
||||
* [lightning][] ([LGPL/CC-BY-SA](mods/weather/lightning/README.md))
|
||||
* [weather][] ([LGPL/WTFPL/CC-BY-SA](mods/weather/weather/README))
|
||||
@ -128,6 +129,7 @@ The following mods are also included:
|
||||
[fort_spikes]: https://forum.minetest.net/viewtopic.php?t=14574
|
||||
[glow]: https://forum.minetest.net/viewtopic.php?t=6300
|
||||
[helicopter]: https://forum.minetest.net/viewtopic.php?t=6183
|
||||
[home_gui]: http://cornernote.github.io/minetest-home_gui/
|
||||
[homedecor]: https://forum.minetest.net/viewtopic.php?t=2041
|
||||
[intllib]: https://forum.minetest.net/viewtopic.php?t=4929
|
||||
[inventory_plus]: https://forum.minetest.net/viewtopic.php?t=3100
|
||||
|
32
mods/display/home_gui/LICENSE
Normal file
32
mods/display/home_gui/LICENSE
Normal file
@ -0,0 +1,32 @@
|
||||
Copyright (c) 2013, Brett O'Donnell http://cornernote.github.io
|
||||
All rights reserved.
|
||||
_____ _____ _____ _____ _____ _____
|
||||
| |___| __ | | |___| __ | | |___|_ _|___
|
||||
| --| . | -| | | | -_| -| | | | . | | | | -_|
|
||||
|_____|___|__|__|_|___|___|__|__|_|___|___| |_| |___|
|
||||
|
||||
|
||||
Redistribution and use in source and binary forms, with or without modification,
|
||||
are permitted provided that the following conditions are met:
|
||||
|
||||
* Redistributions of source code must retain the above copyright notice, this
|
||||
list of conditions and the following disclaimer.
|
||||
|
||||
* Redistributions in binary form must reproduce the above copyright notice, this
|
||||
list of conditions and the following disclaimer in the documentation and/or
|
||||
other materials provided with the distribution.
|
||||
|
||||
* Neither the name of the organization nor the names of its
|
||||
contributors may be used to endorse or promote products derived from
|
||||
this software without specific prior written permission.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
|
||||
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR
|
||||
ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
||||
(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
|
||||
ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
32
mods/display/home_gui/README.md
Normal file
32
mods/display/home_gui/README.md
Normal file
@ -0,0 +1,32 @@
|
||||
# Home GUI for Minetest
|
||||
|
||||
Set home position and then go to it using the inventory screen.
|
||||
|
||||
|
||||
## Features
|
||||
|
||||
- Player can set home position using their inventory.
|
||||
- Player can jump to home position using their inventory.
|
||||
|
||||
|
||||
## Resources
|
||||
|
||||
- **[Documentation](http://cornernote.github.io/minetest-home_gui)**
|
||||
- **[GitHub Project](https://github.com/cornernote/minetest-home_gui)**
|
||||
- **[Minetest Forum](http://minetest.net/forum/viewtopic.php?id=3101)**
|
||||
|
||||
|
||||
## Support
|
||||
|
||||
- Does this README need improvement? Go ahead and [suggest a change](https://github.com/cornernote/minetest-home_gui/edit/master/README.md).
|
||||
- Found a bug, or need help using this project? Check the [open issues](https://github.com/cornernote/minetest-home_gui/issues) or [create an issue](https://github.com/cornernote/minetest-home_gui/issues/new).
|
||||
|
||||
|
||||
## About
|
||||
|
||||
This module is open source, so it's distributed freely. If you find it useful then I ask not for your wealth, but simply to spare your time to consider the world we share by watching [Earthlings](http://earthlings.com/), a multi-award winning film available to watch online for free. A must-see for anyone who wishes to make the world a better place.
|
||||
|
||||
|
||||
## License
|
||||
|
||||
[BSD-3-Clause](https://raw.github.com/cornernote/minetest-home_gui/master/LICENSE), Copyright © 2013-2014 [Brett O'Donnell](http://cornernote.github.io/)
|
1
mods/display/home_gui/depends.txt
Normal file
1
mods/display/home_gui/depends.txt
Normal file
@ -0,0 +1 @@
|
||||
inventory_plus
|
95
mods/display/home_gui/init.lua
Normal file
95
mods/display/home_gui/init.lua
Normal file
@ -0,0 +1,95 @@
|
||||
--[[
|
||||
|
||||
Home GUI for Minetest
|
||||
|
||||
Copyright (c) 2012 cornernote, Brett O'Donnell <cornernote@gmail.com>
|
||||
Source Code: https://github.com/cornernote/minetest-particles
|
||||
License: GPLv3
|
||||
|
||||
]]--
|
||||
|
||||
-- local api
|
||||
local home_gui = {}
|
||||
|
||||
-- filename
|
||||
home_gui.filename = minetest.get_worldpath()..'/home_gui'
|
||||
|
||||
-- load_home
|
||||
local homepos = {}
|
||||
local load_home = function()
|
||||
local input = io.open(home_gui.filename..".home", "r")
|
||||
if input then
|
||||
while true do
|
||||
local x = input:read("*n")
|
||||
if x == nil then
|
||||
break
|
||||
end
|
||||
local y = input:read("*n")
|
||||
local z = input:read("*n")
|
||||
local name = input:read("*l")
|
||||
homepos[name:sub(2)] = {x = x, y = y, z = z}
|
||||
end
|
||||
io.close(input)
|
||||
else
|
||||
homepos = {}
|
||||
end
|
||||
end
|
||||
load_home() -- run it now
|
||||
|
||||
-- set_home
|
||||
home_gui.set_home = function(player, pos)
|
||||
homepos[player:get_player_name()] = pos
|
||||
-- save the home data from the table to the file
|
||||
local output = io.open(home_gui.filename..".home", "w")
|
||||
for k, v in pairs(homepos) do
|
||||
if v ~= nil then
|
||||
output:write(math.floor(v.x).." "..math.floor(v.y).." "..math.floor(v.z).." "..k.."\n")
|
||||
end
|
||||
end
|
||||
io.close(output)
|
||||
end
|
||||
|
||||
-- go_home
|
||||
home_gui.go_home = function(player)
|
||||
local pos = homepos[player:get_player_name()]
|
||||
if pos~=nil then
|
||||
player:setpos(pos)
|
||||
end
|
||||
end
|
||||
|
||||
-- get_formspec
|
||||
home_gui.get_formspec = function(player)
|
||||
local formspec = "size[4,1.5]"
|
||||
.."button[0,0;2,0.5;main;Back]"
|
||||
.."button_exit[0,1;2,0.5;home_gui_set;Set Home]"
|
||||
.."button_exit[2,1;2,0.5;home_gui_go;Go Home]"
|
||||
local home = homepos[player:get_player_name()]
|
||||
if home ~= nil then
|
||||
formspec = formspec
|
||||
.."label[2,-0.2;Home set to:]"
|
||||
.."label[2,0.2;"..math.floor(home.x)..","..math.floor(home.y)..","..math.floor(home.z).."]"
|
||||
end
|
||||
return formspec
|
||||
end
|
||||
|
||||
-- register_on_joinplayer
|
||||
minetest.register_on_joinplayer(function(player)
|
||||
-- add inventory_plus page
|
||||
inventory_plus.register_button(player,"home_gui","Home Pos")
|
||||
end)
|
||||
|
||||
-- register_on_player_receive_fields
|
||||
minetest.register_on_player_receive_fields(function(player, formname, fields)
|
||||
if fields.home_gui_set then
|
||||
home_gui.set_home(player, player:getpos())
|
||||
end
|
||||
if fields.home_gui_go then
|
||||
home_gui.go_home(player)
|
||||
end
|
||||
if fields.home_gui or fields.home_gui_set or fields.home_gui_go then
|
||||
inventory_plus.set_inventory_formspec(player, home_gui.get_formspec(player))
|
||||
end
|
||||
end)
|
||||
|
||||
-- log that we started
|
||||
minetest.log("action", "[MOD]"..minetest.get_current_modname().." -- loaded from "..minetest.get_modpath(minetest.get_current_modname()))
|
Loading…
x
Reference in New Issue
Block a user