aboutsummaryrefslogtreecommitdiff
path: root/builtin
diff options
context:
space:
mode:
authorElias Fleckenstein <eliasfleckenstein@web.de>2020-06-23 17:43:47 +0200
committerElias Fleckenstein <eliasfleckenstein@web.de>2020-06-23 17:43:47 +0200
commita87805a9445f280ca71da322c4b32cf357744511 (patch)
tree0404bc58a6f556b0603283fdbd01121dc73d3cd9 /builtin
parent68f9263a24a345435d2310ab559ce8a811ef0427 (diff)
downloaddragonfireclient-a87805a9445f280ca71da322c4b32cf357744511.tar.xz
test
Diffstat (limited to 'builtin')
-rw-r--r--builtin/client/chatcommands.lua2
-rw-r--r--builtin/client/cheats.lua160
-rw-r--r--builtin/client/death_formspec.lua34
-rw-r--r--builtin/client/init.lua3
-rw-r--r--builtin/client/register.lua20
-rw-r--r--builtin/client/spoof.lua4
-rw-r--r--builtin/common/misc_helpers.lua10
-rw-r--r--builtin/settingtypes.txt10
8 files changed, 221 insertions, 22 deletions
diff --git a/builtin/client/chatcommands.lua b/builtin/client/chatcommands.lua
index 5cb1b40bb..f514f754b 100644
--- a/builtin/client/chatcommands.lua
+++ b/builtin/client/chatcommands.lua
@@ -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()
diff --git a/builtin/client/cheats.lua b/builtin/client/cheats.lua
new file mode 100644
index 000000000..9d7fd932c
--- /dev/null
+++ b/builtin/client/cheats.lua
@@ -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)
+
diff --git a/builtin/client/death_formspec.lua b/builtin/client/death_formspec.lua
index 516a15efc..0a4a98ea3 100644
--- a/builtin/client/death_formspec.lua
+++ b/builtin/client/death_formspec.lua
@@ -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
})
diff --git a/builtin/client/init.lua b/builtin/client/init.lua
index bcaa5244e..6c024f02e 100644
--- a/builtin/client/init.lua
+++ b/builtin/client/init.lua
@@ -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")
diff --git a/builtin/client/register.lua b/builtin/client/register.lua
index c1b4965c1..071220a43 100644
--- a/builtin/client/register.lua
+++ b/builtin/client/register.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
--
diff --git a/builtin/client/spoof.lua b/builtin/client/spoof.lua
deleted file mode 100644
index f053a8a08..000000000
--- a/builtin/client/spoof.lua
+++ /dev/null
@@ -1,4 +0,0 @@
-local file = io.open("spoof.txt", "a")
-minetest.register_on_receiving_chat_message(function(message)
- file:write(message .. "\n")
-end)
diff --git a/builtin/common/misc_helpers.lua b/builtin/common/misc_helpers.lua
index 715f89bc4..c904bccfc 100644
--- a/builtin/common/misc_helpers.lua
+++ b/builtin/common/misc_helpers.lua
@@ -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
diff --git a/builtin/settingtypes.txt b/builtin/settingtypes.txt
index ba0cf9610..698dcf57b 100644
--- a/builtin/settingtypes.txt
+++ b/builtin/settingtypes.txt
@@ -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