Format code
This commit is contained in:
parent
82bc10d94b
commit
1d8b476861
@ -1,36 +1,36 @@
|
||||
minetest.register_privilege("fun", {
|
||||
description = "Access to \"powerful\" fun commands",
|
||||
give_to_singeplayer = true
|
||||
description = "Access to \"powerful\" fun commands",
|
||||
give_to_singeplayer = true
|
||||
})
|
||||
|
||||
minetest.register_chatcommand("explode", {
|
||||
params = "<range>",
|
||||
description = "Create an explosion of size RANGE.",
|
||||
privs = {
|
||||
fun = true
|
||||
},
|
||||
func = function(name, param)
|
||||
local player = minetest.get_player_by_name(name)
|
||||
local range = tonumber(param)
|
||||
params = "<range>",
|
||||
description = "Create an explosion of size RANGE.",
|
||||
privs = {
|
||||
fun = true
|
||||
},
|
||||
func = function(name, param)
|
||||
local player = minetest.get_player_by_name(name)
|
||||
local range = tonumber(param)
|
||||
|
||||
if range == nil then
|
||||
return false, "Please use a number for the range."
|
||||
end
|
||||
if range == nil then
|
||||
return false, "Please use a number for the range."
|
||||
end
|
||||
|
||||
PyuTestCore.create_explosion(player:get_pos(), range, false, range, player, true)
|
||||
end
|
||||
PyuTestCore.create_explosion(player:get_pos(), range, false, range, player, true)
|
||||
end
|
||||
})
|
||||
|
||||
minetest.register_chatcommand("rtp", {
|
||||
description = [[Teleport to a random location in the world.
|
||||
This command may or may not kill you.]],
|
||||
func = function(name)
|
||||
local player = minetest.get_player_by_name(name)
|
||||
local player = minetest.get_player_by_name(name)
|
||||
|
||||
local player_pos = player:get_pos()
|
||||
local player_pos = player:get_pos()
|
||||
|
||||
math.randomseed(os.time())
|
||||
local pos = vector.new(math.random(-31000, 31000), player_pos.y, math.random(-31000, 31000))
|
||||
player:set_pos(pos)
|
||||
math.randomseed(os.time())
|
||||
local pos = vector.new(math.random(-31000, 31000), player_pos.y, math.random(-31000, 31000))
|
||||
player:set_pos(pos)
|
||||
end
|
||||
})
|
||||
|
@ -2,72 +2,72 @@
|
||||
Format:
|
||||
|
||||
user = {
|
||||
name = {
|
||||
pos = {x = 128, y = 50, z = 256},
|
||||
idx = 439
|
||||
}
|
||||
name = {
|
||||
pos = {x = 128, y = 50, z = 256},
|
||||
idx = 439
|
||||
}
|
||||
}
|
||||
|
||||
]]
|
||||
local waypoints = {}
|
||||
|
||||
minetest.register_chatcommand("waypoint", {
|
||||
params = "<name>",
|
||||
description = [[Creates a waypoint at your position called <NAME>
|
||||
params = "<name>",
|
||||
description = [[Creates a waypoint at your position called <NAME>
|
||||
If the waypoint is already set, move the waypoint.]],
|
||||
func = function (name, param)
|
||||
if waypoints[name] == nil then
|
||||
waypoints[name] = {}
|
||||
end
|
||||
if waypoints[name] == nil then
|
||||
waypoints[name] = {}
|
||||
end
|
||||
|
||||
local player = minetest.get_player_by_name(name)
|
||||
if player == nil then return end
|
||||
local player = minetest.get_player_by_name(name)
|
||||
if player == nil then return end
|
||||
|
||||
if waypoints[name][param] ~= nil then
|
||||
player:hud_remove(waypoints[name][param].idx)
|
||||
end
|
||||
if waypoints[name][param] ~= nil then
|
||||
player:hud_remove(waypoints[name][param].idx)
|
||||
end
|
||||
|
||||
local pos = player:get_pos()
|
||||
local pos = player:get_pos()
|
||||
|
||||
waypoints[name][param] = {}
|
||||
waypoints[name][param].pos = pos
|
||||
waypoints[name][param] = {}
|
||||
waypoints[name][param].pos = pos
|
||||
|
||||
local idx = player:hud_add({
|
||||
local idx = player:hud_add({
|
||||
hud_elem_type = "waypoint",
|
||||
name = param,
|
||||
text = "m",
|
||||
world_pos = pos,
|
||||
number = 0xFFFFFFFF,
|
||||
})
|
||||
waypoints[name][param].idx = idx
|
||||
})
|
||||
waypoints[name][param].idx = idx
|
||||
end
|
||||
})
|
||||
|
||||
minetest.register_chatcommand("teleportwaypoint", {
|
||||
params = "<name>",
|
||||
description = "Teleport to waypoint NAME",
|
||||
func = function (name, param)
|
||||
if waypoints[name] == nil then
|
||||
waypoints[name] = {}
|
||||
end
|
||||
if waypoints[name][param] == nil then return end
|
||||
params = "<name>",
|
||||
description = "Teleport to waypoint NAME",
|
||||
func = function (name, param)
|
||||
if waypoints[name] == nil then
|
||||
waypoints[name] = {}
|
||||
end
|
||||
if waypoints[name][param] == nil then return end
|
||||
|
||||
local player = minetest.get_player_by_name(name)
|
||||
if player == nil then return end
|
||||
local player = minetest.get_player_by_name(name)
|
||||
if player == nil then return end
|
||||
|
||||
player:set_pos(waypoints[name][param].pos)
|
||||
end
|
||||
player:set_pos(waypoints[name][param].pos)
|
||||
end
|
||||
})
|
||||
|
||||
minetest.register_chatcommand("biome", {
|
||||
description = "Return the current biome name",
|
||||
func = function (name)
|
||||
local player = minetest.get_player_by_name(name)
|
||||
if player == nil then return end
|
||||
description = "Return the current biome name",
|
||||
func = function (name)
|
||||
local player = minetest.get_player_by_name(name)
|
||||
if player == nil then return end
|
||||
|
||||
local pos = player:get_pos()
|
||||
local pos = player:get_pos()
|
||||
|
||||
local name = minetest.get_biome_name(minetest.get_biome_data(pos).biome)
|
||||
return true, string.format("Current biome name: %s", name)
|
||||
end
|
||||
local name = minetest.get_biome_name(minetest.get_biome_data(pos).biome)
|
||||
return true, string.format("Current biome name: %s", name)
|
||||
end
|
||||
})
|
||||
|
@ -1,63 +1,63 @@
|
||||
minetest.register_privilege("builder", {
|
||||
description = "Builder/World Edit Privilege",
|
||||
give_to_singeplayer = true
|
||||
description = "Builder/World Edit Privilege",
|
||||
give_to_singeplayer = true
|
||||
})
|
||||
|
||||
minetest.register_chatcommand("replacenear", {
|
||||
params = "<range> <from> <to>",
|
||||
description = [[Replace blocks around RANGE from FROM to TO.
|
||||
params = "<range> <from> <to>",
|
||||
description = [[Replace blocks around RANGE from FROM to TO.
|
||||
FROM can be comma seperated, or it can be `any` which replaces any node.
|
||||
Or it can be `anyblock` which replaces any node other than air and ignore.
|
||||
]],
|
||||
privs = {
|
||||
builder = true
|
||||
builder = true
|
||||
},
|
||||
func = function (name, param)
|
||||
local parts = param:split(" ")
|
||||
if #parts == 3 then
|
||||
local player = minetest.get_player_by_name(name)
|
||||
local pos = player:get_pos()
|
||||
local range = tonumber(parts[1]) or 5
|
||||
local from = parts[2]:split(",")
|
||||
local to = parts[3]
|
||||
local replaced = 0
|
||||
local parts = param:split(" ")
|
||||
if #parts == 3 then
|
||||
local player = minetest.get_player_by_name(name)
|
||||
local pos = player:get_pos()
|
||||
local range = tonumber(parts[1]) or 5
|
||||
local from = parts[2]:split(",")
|
||||
local to = parts[3]
|
||||
local replaced = 0
|
||||
|
||||
local function replace(p)
|
||||
for _, v in pairs(from) do
|
||||
local name = minetest.get_node(p).name
|
||||
local anyblock_match = (v == "anyblock" or v == "anynode" and name ~= "air" and name ~= "ignore")
|
||||
local function replace(p)
|
||||
for _, v in pairs(from) do
|
||||
local name = minetest.get_node(p).name
|
||||
local anyblock_match = (v == "anyblock" or v == "anynode" and name ~= "air" and name ~= "ignore")
|
||||
|
||||
if name == v or v == "any" or anyblock_match then
|
||||
minetest.set_node(p, {name = to})
|
||||
replaced = replaced + 1
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
PyuTestCore.dorange(pos, range, function(p)
|
||||
replace(p)
|
||||
end)
|
||||
|
||||
return true, string.format("Replaced %d blocks", replaced)
|
||||
if name == v or v == "any" or anyblock_match then
|
||||
minetest.set_node(p, {name = to})
|
||||
replaced = replaced + 1
|
||||
end
|
||||
return false, "Requires 3 arguments"
|
||||
end
|
||||
end
|
||||
|
||||
PyuTestCore.dorange(pos, range, function(p)
|
||||
replace(p)
|
||||
end)
|
||||
|
||||
return true, string.format("Replaced %d blocks", replaced)
|
||||
end
|
||||
return false, "Requires 3 arguments"
|
||||
end
|
||||
})
|
||||
|
||||
minetest.register_chatcommand("place", {
|
||||
params = "<schematic>",
|
||||
description = "Place SCHEMATIC at player position",
|
||||
privs = {
|
||||
builder = true
|
||||
},
|
||||
func = function(name, param)
|
||||
local player = minetest.get_player_by_name(name)
|
||||
minetest.place_schematic(player:get_pos(),
|
||||
PyuTestCore.get_schem_path(param),
|
||||
"random",
|
||||
nil,
|
||||
false,
|
||||
"place_center_x, place_center_z"
|
||||
)
|
||||
end
|
||||
params = "<schematic>",
|
||||
description = "Place SCHEMATIC at player position",
|
||||
privs = {
|
||||
builder = true
|
||||
},
|
||||
func = function(name, param)
|
||||
local player = minetest.get_player_by_name(name)
|
||||
minetest.place_schematic(player:get_pos(),
|
||||
PyuTestCore.get_schem_path(param),
|
||||
"random",
|
||||
nil,
|
||||
false,
|
||||
"place_center_x, place_center_z"
|
||||
)
|
||||
end
|
||||
})
|
||||
|
Loading…
x
Reference in New Issue
Block a user