everything added
This commit is contained in:
41
mods/pn/.gitignore
vendored
Normal file
41
mods/pn/.gitignore
vendored
Normal file
@@ -0,0 +1,41 @@
|
||||
# Compiled Lua sources
|
||||
luac.out
|
||||
|
||||
# luarocks build files
|
||||
*.src.rock
|
||||
*.zip
|
||||
*.tar.gz
|
||||
|
||||
# Object files
|
||||
*.o
|
||||
*.os
|
||||
*.ko
|
||||
*.obj
|
||||
*.elf
|
||||
|
||||
# Precompiled Headers
|
||||
*.gch
|
||||
*.pch
|
||||
|
||||
# Libraries
|
||||
*.lib
|
||||
*.a
|
||||
*.la
|
||||
*.lo
|
||||
*.def
|
||||
*.exp
|
||||
|
||||
# Shared objects (inc. Windows DLLs)
|
||||
*.dll
|
||||
*.so
|
||||
*.so.*
|
||||
*.dylib
|
||||
|
||||
# Executables
|
||||
*.exe
|
||||
*.out
|
||||
*.app
|
||||
*.i*86
|
||||
*.x86_64
|
||||
*.hex
|
||||
|
||||
21
mods/pn/LICENSE
Normal file
21
mods/pn/LICENSE
Normal file
@@ -0,0 +1,21 @@
|
||||
MIT License
|
||||
|
||||
Copyright (c) 2020 Emojigit
|
||||
|
||||
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.
|
||||
9
mods/pn/README.md
Normal file
9
mods/pn/README.md
Normal file
@@ -0,0 +1,9 @@
|
||||
This mod add `setblock` and `place` command
|
||||
|
||||
## Commands
|
||||
|
||||
### /setblock x y z modname:foobar_node & /place x y z modname:foobar_node
|
||||
Place a block at x,y,z (setblock call `minetest.set_node`, and place call `minetest.place_node`)
|
||||
|
||||
### /setblock_heremodname:foobar_node & /place_here modname:foobar_node
|
||||
Place a block at your pos (setblock call `minetest.set_node`, and place call `minetest.place_node`)
|
||||
103
mods/pn/init.lua
Normal file
103
mods/pn/init.lua
Normal file
@@ -0,0 +1,103 @@
|
||||
minetest.register_privilege("setblock", {
|
||||
description = "Player can use place and setblock command.",
|
||||
give_to_singleplayer= false,
|
||||
})
|
||||
|
||||
local function split (inputstr, sep)
|
||||
if sep == nil then
|
||||
sep = "%s"
|
||||
end
|
||||
local t={}
|
||||
for str in string.gmatch(inputstr, "([^"..sep.."]+)") do
|
||||
table.insert(t, str)
|
||||
end
|
||||
return t
|
||||
end
|
||||
|
||||
minetest.register_chatcommand("place", {
|
||||
params = "<x> <y> <x> <nodename>",
|
||||
description = "Place block",
|
||||
privs = {setblock = true},
|
||||
func = function(name, param)
|
||||
splited = split(param," ")
|
||||
if not(tonumber(splited[1]) and tonumber(splited[2]) and tonumber(splited[3])) then
|
||||
return false, "Pos error: please give int!"
|
||||
end
|
||||
x,y,z,node = tonumber(splited[1]),tonumber(splited[2]),tonumber(splited[3]),splited[4]
|
||||
if node == "ignore" then
|
||||
return false, "You can't place \"ignore\"!"
|
||||
end
|
||||
if minetest.registered_nodes[node] then
|
||||
minetest.place_node({x=x, y=y, z=z}, {name=node})
|
||||
return true, "Setted node "..node.." at "..tostring(x)..tostring(y)..tostring(z)
|
||||
else
|
||||
return false, "Cannot place a unknown node."
|
||||
end
|
||||
end,
|
||||
})
|
||||
|
||||
minetest.register_chatcommand("place_here", {
|
||||
params = "<node>",
|
||||
privs = {setblock = true},
|
||||
description = "Place block at player's pos",
|
||||
func = function(name, param)
|
||||
local player = minetest.get_player_by_name(name)
|
||||
if not player then
|
||||
return false, "Player is not online."
|
||||
end
|
||||
if param == "ignore" then
|
||||
return false, "You can't place \"ignore\"!"
|
||||
end
|
||||
if minetest.registered_nodes[param] then
|
||||
minetest.place_node(player:get_pos(), {name=param})
|
||||
return true, "Placed node "..param.." at "..tostring(math.floor(player:get_pos().x))..","..tostring(math.floor(player:get_pos().y))..","..tostring(math.floor(player:get_pos().z))
|
||||
else
|
||||
return false, "Cannot place a unknown node."
|
||||
end
|
||||
end,
|
||||
})
|
||||
|
||||
-- minetest.set_node
|
||||
|
||||
minetest.register_chatcommand("setblock", {
|
||||
params = "<x> <y> <x> <nodename>",
|
||||
privs = {setblock = true},
|
||||
description = "Set a block",
|
||||
func = function(name, param)
|
||||
splited = split(param," ")
|
||||
if not(tonumber(splited[1]) and tonumber(splited[2]) and tonumber(splited[3])) then
|
||||
return false, "Pos error: please give int!"
|
||||
end
|
||||
x,y,z,node = tonumber(splited[1]),tonumber(splited[2]),tonumber(splited[3]),splited[4]
|
||||
if node == "ignore" then
|
||||
return false, "You can't set \"ignore\"!"
|
||||
end
|
||||
if minetest.registered_nodes[node] then
|
||||
minetest.set_node({x=x, y=y, z=z}, {name=node})
|
||||
return true, "Setted node "..node.." at "..tostring(x)..tostring(y)..tostring(z)
|
||||
else
|
||||
return false, "Cannot set a unknown node."
|
||||
end
|
||||
end,
|
||||
})
|
||||
|
||||
minetest.register_chatcommand("setblock_here", {
|
||||
params = "<node>",
|
||||
privs = {setblock = true},
|
||||
description = "Set a block at player's pos",
|
||||
func = function(name, param)
|
||||
local player = minetest.get_player_by_name(name)
|
||||
if not player then
|
||||
return false, "Player is not online."
|
||||
end
|
||||
if param == "ignore" then
|
||||
return false, "You can't set \"ignore\"!"
|
||||
end
|
||||
if minetest.registered_nodes[param] then
|
||||
minetest.set_node(player:get_pos(), {name=param})
|
||||
return true, "Setted node "..param.." at "..tostring(math.floor(player:get_pos().x))..","..tostring(math.floor(player:get_pos().y))..","..tostring(math.floor(player:get_pos().z))
|
||||
else
|
||||
return false, "Cannot set a unknown node."
|
||||
end
|
||||
end,
|
||||
})
|
||||
2
mods/pn/mod.conf
Normal file
2
mods/pn/mod.conf
Normal file
@@ -0,0 +1,2 @@
|
||||
name = place_node
|
||||
description = Add `setblock` and `place` command to the game
|
||||
BIN
mods/pn/screenshot.png
Normal file
BIN
mods/pn/screenshot.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 2.8 MiB |
Reference in New Issue
Block a user