test
This commit is contained in:
@@ -37,7 +37,7 @@ core.register_on_sending_chat_message(function(message)
|
||||
return true
|
||||
end)
|
||||
|
||||
core.register_chatcommand("list_players", {
|
||||
core.register_chatcommand("players", {
|
||||
description = core.gettext("List online players"),
|
||||
func = function(param)
|
||||
local player_names = core.get_player_names()
|
||||
|
160
builtin/client/cheats.lua
Normal file
160
builtin/client/cheats.lua
Normal file
@@ -0,0 +1,160 @@
|
||||
core.register_chatcommand("set", {
|
||||
params = "([-n] <name> <value>) | <name>",
|
||||
description = "Set or read client configuration setting",
|
||||
privs = {server=true},
|
||||
func = function(param)
|
||||
local arg, setname, setvalue = string.match(param, "(-[n]) ([^ ]+) (.+)")
|
||||
if arg and arg == "-n" and setname and setvalue then
|
||||
core.settings:set(setname, setvalue)
|
||||
return true, setname .. " = " .. setvalue
|
||||
end
|
||||
|
||||
setname, setvalue = string.match(param, "([^ ]+) (.+)")
|
||||
if setname and setvalue then
|
||||
if not core.settings:get(setname) then
|
||||
return false, "Failed. Use '.set -n <name> <value>' to create a new setting."
|
||||
end
|
||||
core.settings:set(setname, setvalue)
|
||||
return true, setname .. " = " .. setvalue
|
||||
end
|
||||
|
||||
setname = string.match(param, "([^ ]+)")
|
||||
if setname then
|
||||
setvalue = core.settings:get(setname)
|
||||
if not setvalue then
|
||||
setvalue = "<not set>"
|
||||
end
|
||||
return true, setname .. " = " .. setvalue
|
||||
end
|
||||
|
||||
return false, "Invalid parameters (see .help set)."
|
||||
end,
|
||||
})
|
||||
|
||||
function core.parse_pos(param)
|
||||
local p = {}
|
||||
p.x, p.y, p.z = string.match(param, "^([~|%d.-]+)[, ] *([~|%d.-]+)[, ] *([~|%d.-]+)$")
|
||||
for k, v in pairs(p) do
|
||||
if p[k] == "~" then
|
||||
p[k] = core.localplayer:get_pos()[k]
|
||||
else
|
||||
p[k] = tonumber(v)
|
||||
end
|
||||
end
|
||||
if p.x and p.y and p.z then
|
||||
local lm = 31000
|
||||
if p.x < -lm or p.x > lm or p.y < -lm or p.y > lm or p.z < -lm or p.z > lm then
|
||||
return false, "Position out of Map bounds."
|
||||
end
|
||||
return true, p
|
||||
end
|
||||
return false, "Invalid position (" .. param .. ")"
|
||||
end
|
||||
|
||||
core.register_chatcommand("teleport", {
|
||||
params = "<X>,<Y>,<Z>",
|
||||
description = "Teleport to position",
|
||||
func = function(param)
|
||||
local success, pos = core.parse_pos(param)
|
||||
if success then
|
||||
core.localplayer:set_pos(pos)
|
||||
return true, "Teleporting to " .. core.pos_to_string(pos)
|
||||
end
|
||||
return false, pos
|
||||
end,
|
||||
})
|
||||
|
||||
core.register_chatcommand("place", {
|
||||
params = "<X>,<Y>,<Z>",
|
||||
description = "Place wielded item",
|
||||
func = function(param)
|
||||
local success, pos = core.parse_pos(param)
|
||||
if success then
|
||||
core.place_node(pos)
|
||||
return true, "Node placed at " .. core.pos_to_string(pos)
|
||||
end
|
||||
return false, pos
|
||||
end,
|
||||
})
|
||||
|
||||
core.register_chatcommand("dig", {
|
||||
params = "<X>,<Y>,<Z>",
|
||||
description = "Dig node",
|
||||
func = function(param)
|
||||
local success, pos = core.parse_pos(param)
|
||||
if success then
|
||||
core.dig_node(pos)
|
||||
return true, "Node at " .. core.pos_to_string(pos) .. " dug"
|
||||
end
|
||||
return false, pos
|
||||
end,
|
||||
})
|
||||
|
||||
core.register_chatcommand("kill", {
|
||||
description = "Kill yourself",
|
||||
func = function(param)
|
||||
core.send_damage(core.localplayer:get_hp())
|
||||
end,
|
||||
})
|
||||
|
||||
core.register_chatcommand("scan", {
|
||||
description = "Scan for one or multible nodes in a radius around you",
|
||||
param = "<radius> node1[,node2...]",
|
||||
func = function(param)
|
||||
local radius = tonumber(param:split(" ")[1])
|
||||
local nodes = param:split(" ")[2]:split(",")
|
||||
local pos = core.localplayer:get_pos()
|
||||
local fpos = core.find_node_near(pos, radius, nodes, true)
|
||||
if fpos then
|
||||
return true, "Found " .. table.concat(nodes, " or ") .. " at " .. core.pos_to_string(fpos)
|
||||
end
|
||||
return false, "None of " .. table.concat(nodes, " or ") .. " found in a radius of " .. tostring(radius)
|
||||
end,
|
||||
})
|
||||
|
||||
core.register_chatcommand("digaround", {
|
||||
description = "Scan for one or multible nodes in a radius around you",
|
||||
param = "<radius> node1[,node2...]",
|
||||
func = function(param)
|
||||
local radius = tonumber(param:split(" ")[1])
|
||||
local nodes = param:split(" ")[2]:split(",")
|
||||
local function loop()
|
||||
local fpos = core.find_node_near(core.localplayer:get_pos(), radius, nodes, true)
|
||||
if fpos then core.dig_node(fpos) end
|
||||
core.after(0, loop)
|
||||
end
|
||||
loop()
|
||||
end,
|
||||
})
|
||||
|
||||
local keep_digging = false
|
||||
|
||||
core.register_chatcommand("keepdigging", {
|
||||
params = "<X>,<Y>,<Z>",
|
||||
description = "Dig node again and again",
|
||||
func = function(param)
|
||||
local success, pos = core.parse_pos(param)
|
||||
if success then
|
||||
keep_digging = true
|
||||
local function loop()
|
||||
core.dig_node(pos)
|
||||
if keep_digging then
|
||||
core.after(0.1, loop)
|
||||
end
|
||||
end
|
||||
loop()
|
||||
end
|
||||
end,
|
||||
})
|
||||
|
||||
core.register_chatcommand("stopdigging", {
|
||||
description = "Stop diggin",
|
||||
func = function()
|
||||
keep_digging = false
|
||||
end,
|
||||
})
|
||||
|
||||
core.register_on_punchnode(function(pos)
|
||||
--core.dig_node(pos)
|
||||
end)
|
||||
|
@@ -1,29 +1,33 @@
|
||||
-- CSM death formspec. Only used when clientside modding is enabled, otherwise
|
||||
-- handled by the engine.
|
||||
|
||||
local dead = false
|
||||
|
||||
core.register_on_death(function()
|
||||
if not dead then
|
||||
core.display_chat_message("You died.")
|
||||
local formspec = "size[11,5.5]bgcolor[#320000b4;true]" ..
|
||||
"label[4.85,1.35;" .. fgettext("You died") ..
|
||||
"]button_exit[4,3;3,0.5;btn_respawn;".. fgettext("Respawn") .."]"
|
||||
core.show_formspec("bultin:death", formspec)
|
||||
dead = true
|
||||
end
|
||||
core.display_chat_message("You died.")
|
||||
local formspec = "size[11,5.5]bgcolor[#320000b4;true]" ..
|
||||
"label[4.85,1.35;" .. fgettext("You died") ..
|
||||
"]button_exit[2,3;3,0.5;btn_respawn;".. fgettext("Respawn") ..
|
||||
"]button_exit[6,3;3,0.5;btn_ghost_mode;".. fgettext("Ghost Mode") .."]"
|
||||
core.show_formspec("bultin:death", formspec)
|
||||
end)
|
||||
|
||||
core.register_on_formspec_input(function(formname, fields)
|
||||
if formname == "bultin:death" and fields.btn_respawn then
|
||||
core.send_respawn()
|
||||
dead = false
|
||||
if formname == "bultin:death" then
|
||||
if fields.btn_ghost_mode then
|
||||
core.display_chat_message("You are in ghost mode. Use .respawn to Respawn")
|
||||
else
|
||||
core.send_respawn()
|
||||
end
|
||||
end
|
||||
end)
|
||||
|
||||
core.register_chatcommand("respawn", {
|
||||
description = core.gettext("Respawn when in ghost mode"),
|
||||
func = function()
|
||||
core.send_respawn()
|
||||
dead = false
|
||||
if core.localplayer:get_hp() == 0 then
|
||||
core.send_respawn()
|
||||
core.display_chat_message("Respawned.")
|
||||
else
|
||||
core.display_chat_message("You are not in ghost mode.")
|
||||
end
|
||||
end
|
||||
})
|
||||
|
@@ -8,5 +8,6 @@ dofile(commonpath .. "after.lua")
|
||||
dofile(commonpath .. "chatcommands.lua")
|
||||
dofile(commonpath .. "vector.lua")
|
||||
dofile(clientpath .. "death_formspec.lua")
|
||||
dofile(clientpath .. "spoof.lua")
|
||||
dofile(clientpath .. "chatcommands.lua")
|
||||
dofile(clientpath .. "cheats.lua")
|
||||
|
||||
|
@@ -40,6 +40,26 @@ function core.run_callbacks(callbacks, mode, ...)
|
||||
return ret
|
||||
end
|
||||
|
||||
function core.override_item(name, redefinition)
|
||||
if redefinition.name ~= nil then
|
||||
error("Attempt to redefine name of "..name.." to "..dump(redefinition.name), 2)
|
||||
end
|
||||
if redefinition.type ~= nil then
|
||||
error("Attempt to redefine type of "..name.." to "..dump(redefinition.type), 2)
|
||||
end
|
||||
local itemdef = core.get_item_def(name)
|
||||
if not itemdef then
|
||||
error("Attempt to override non-existent item "..name, 2)
|
||||
end
|
||||
local nodedef = core.get_node_def(name)
|
||||
table.combine(itemdef, nodedef)
|
||||
|
||||
for k, v in pairs(redefinition) do
|
||||
rawset(itemdef, k, v)
|
||||
end
|
||||
core.register_item_raw(itemdef)
|
||||
end
|
||||
|
||||
--
|
||||
-- Callback registration
|
||||
--
|
||||
|
@@ -1,4 +0,0 @@
|
||||
local file = io.open("spoof.txt", "a")
|
||||
minetest.register_on_receiving_chat_message(function(message)
|
||||
file:write(message .. "\n")
|
||||
end)
|
@@ -519,6 +519,16 @@ function table.shuffle(t, from, to, random)
|
||||
end
|
||||
end
|
||||
|
||||
function table.combine(t, other)
|
||||
other = other or {}
|
||||
for k, v in pairs(other) do
|
||||
if type(v) == "table" and type(t[k]) == "table" then
|
||||
table.combine(t[k], v)
|
||||
else
|
||||
t[k] = v
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
--------------------------------------------------------------------------------
|
||||
-- mainmenu only functions
|
||||
|
@@ -2146,8 +2146,16 @@ xray_texture (Texture to make transparent when xray is enabled) string default_s
|
||||
|
||||
priv_bypass (Make the Client think it has all privs) bool false
|
||||
|
||||
instant_dig (Dig Nodes on punch) bool false
|
||||
fastdig (Fast Dig) bool false
|
||||
|
||||
prevent_natural_damage (Prevent Natural Damage e.g Fall Damage) bool false
|
||||
|
||||
freecam (Move around freely) bool false
|
||||
|
||||
killaura (Enable Killaura) bool false
|
||||
|
||||
no_hurt_cam (No Hurt Cam) bool false
|
||||
|
||||
increase_tool_range (Increase Tool Range) bool false
|
||||
|
||||
killaura_fast (Enable fast Killaura) bool false
|
||||
|
Reference in New Issue
Block a user