Jordan Irwin 2021-05-15 16:12:10 -07:00
parent 6c8eaa5bb5
commit 40259b7066
9 changed files with 147 additions and 0 deletions

View File

@ -85,6 +85,7 @@ The game includes the mods from the default [minetest_game](https://github.com/m
* [enchanting][] ([GPL / WTFPL / CC BY-SA-NA][lic.enchanting]) -- version: [13ea31c Git][ver.enchanting] *2016-12-16* ([patched][patch.enchanting])
* [intllib][] ([Unlicense][lic.unlicense]) -- version: [6ebdc53][ver.intllib] *2021-02-23* ***DEPRECATED***
* [listitems][] ([MIT][lic.listitems]) -- version: [0.7][ver.listitems] *2021-04-29*
* [ownit][] ([MIT][lic.ownit]) -- version: [1.0][ver.ownit] *2021-05-15*
* [painting][] (???) -- version [8961849 Git][ver.painting] *2016-05-05*
* [pipeworks][] ([LGPL][lic.lgpl3.0] / [CC BY-SA][lic.ccbysa4.0]) -- version: [2670fd8 Git][ver.pipeworks] *2021-05-06* ([patched][patch.pipeworks])
* mobiles/
@ -319,6 +320,7 @@ The game includes the mods from the default [minetest_game](https://github.com/m
[nether]: https://forum.minetest.net/viewtopic.php?t=5790
[no_fall_damage]: https://forum.minetest.net/viewtopic.php?t=25876
[override]: https://github.com/AntumMT/mod-override
[ownit]: https://forum.minetest.net/viewtopic.php?t=26740
[painting]: https://github.com/minetest-mods/painting
[pipeworks]: https://forum.minetest.net/viewtopic.php?t=2155
[privilegeareas]: https://forum.minetest.net/viewtopic.php?t=5545
@ -404,6 +406,7 @@ The game includes the mods from the default [minetest_game](https://github.com/m
[lic.nether]: mods/world/nether/README.md
[lic.no_fall_damage]: mods/admin/no_fall_damage/README.md
[lic.override]: mods/admin/override/LICENSE.txt
[lic.ownit]: mods/misc/ownit/LICENSE.txt
[lic.privilegeareas]: mods/admin/privilegeareas/README.md
[lic.quartz]: mods/materials/quartz/LICENSE.txt
[lic.rainbow_ore]: mods/materials/rainbow_ore/README.md
@ -545,6 +548,7 @@ The game includes the mods from the default [minetest_game](https://github.com/m
[ver.no_fall_damage]: https://repo.or.cz/minetest_no_fall_damage.git/shortlog/refs/tags/1.0.0
[ver.oerkki]: https://github.com/AntumMT/mod-cmer/tree/70410fe
[ver.override]: https://github.com/AntumMT/mod-override/tree/e6dda7a
[ver.ownit]: https://github.com/AntumMT/mod-ownit/releases/tag/v1.0
[ver.painting]: https://github.com/minetest-mods/painting/tree/8961849
[ver.pipeworks]: https://gitlab.com/VanessaE/pipeworks/tree/2670fd8
[ver.privilegeareas]: https://github.com/minetest-mods/privilegeareas/tree/15eae20

View File

View File

@ -0,0 +1,21 @@
The MIT License (MIT)
Copyright © 2021 Jordan Irwin (AntumDeluge)
Permission is hereby granted, free of charge, to any person obtaining a copy of
this software and associated documentation files (the "Software"), to deal in
the Software without restriction, including without limitation the rights to
use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
of the Software, and to permit persons to whom the Software is furnished to do
so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.

33
mods/misc/ownit/README.md Normal file
View File

@ -0,0 +1,33 @@
## Ownit: Set/Unset Node Owner
### Description:
![wand](textures/ownit_wand.png)
A tool for setting or removing "ownership" of a node. Not to be confused with an area protection mod. Ownership is determined by the "owner" attribute in the node's meta data. In order for this to actually be effective, other mods must respect that attribute. Otherwise, setting the owner does nothing.
- Player can own a node if the node is unowned & in an area protected/owned by the player. A protection mod is required as vanilla `minetest.is_protected` method always returns `false`.
- Player can unown a node if they are the current owner.
Unsetting ownership can be useful for mods that set ownership automatically when a node is placed (some doors for instance).
This mod has been tested to be working with the following protection mods:
- [simple_protection](https://forum.minetest.net/viewtopic.php?t=9035)
### Usage:
- *left-click (use):* Sets/Unsets user as owner.
- *right-click (place):* Checks owner status & outputs to chat log.
### Licensing:
- Code: [MIT](LICENSE.txt)
- Textures:
- ownit_wand.png: CC0 (by [rcorre](https://opengameart.org/node/40598))
### Links:
- [Git repo](https://github.com/AntumMT/mod-ownit)
- [Forum](https://forum.minetest.net/viewtopic.php?t=26740)
- [Changelog](CHANGES.txt)
- [TODO](TODO.txt)

2
mods/misc/ownit/TODO.txt Normal file
View File

@ -0,0 +1,2 @@
- support `areas` mod

6
mods/misc/ownit/init.lua Normal file
View File

@ -0,0 +1,6 @@
ownit = {}
ownit.modname = core.get_current_modname()
ownit.modpath = core.get_modpath(ownit.modname)
dofile(ownit.modpath .. "/wand.lua")

6
mods/misc/ownit/mod.conf Normal file
View File

@ -0,0 +1,6 @@
name = ownit
description = Node ownership
license = MIT
author = Jordan Irwin (AntumDeluge)
version = 1.0
optional_depends = simple_protection

Binary file not shown.

After

Width:  |  Height:  |  Size: 238 B

75
mods/misc/ownit/wand.lua Normal file
View File

@ -0,0 +1,75 @@
local use_s_protect = core.global_exists("s_protect")
local function is_area_owner(pos, pname)
if not pname then return false end
if use_s_protect then
local claim = s_protect.get_claim(pos)
if claim then return pname == claim.owner end
else
return core.is_protected(pos, pname)
end
return false
end
local function check_node_pos(target)
if target.type ~= "node" then return end
local pos = core.get_pointed_thing_position(target, false)
if not core.get_node_or_nil(pos) then return end
return pos
end
core.register_craftitem(ownit.modname .. ":wand", {
description = "Tool for setting node owner",
short_description = "Ownit Wand",
inventory_image = "ownit_wand.png",
stack_max = 1,
on_use = function(itemstack, user, pointed_thing)
if not user:is_player() then return end
local pos = check_node_pos(pointed_thing)
if not pos then return end
local pname = user:get_player_name()
local nmeta = core.get_meta(pos)
local node_owner = nmeta:get_string("owner")
if node_owner ~= "" and pname ~= node_owner then
core.chat_send_player(pname, "You cannot take ownership of a node owned by " .. node_owner)
return
end
local unown = false
if pname == node_owner then unown = true end
if unown then
nmeta:set_string("owner", nil)
core.chat_send_player(pname, "You no longer own this node")
else
if not is_area_owner(pos, pname) then
core.chat_send_player(pname, "You cannot take ownership of a node that is not in an area owned by you")
return
end
nmeta:set_string("owner", pname)
core.chat_send_player(pname, "You now own this node")
end
end,
on_place = function(itemstack, placer, pointed_thing)
if not placer:is_player() then return end
local pos = check_node_pos(pointed_thing)
if not pos then return end
local pname = placer:get_player_name()
local node_owner = core.get_meta(pos):get_string("owner")
if node_owner == "" then
core.chat_send_player(pname, "This node is unowned")
else
core.chat_send_player(pname, "This node is owned by " .. node_owner)
end
end,
})