removed dupe csms, changed "Leak" to be a chatcommand

master
cora 2020-10-25 11:24:56 +01:00
parent df7000639d
commit 35c586625f
13 changed files with 17 additions and 549 deletions

View File

@ -1,49 +0,0 @@
chat = {}
chat.rainbow = dofile(minetest.get_modpath("chat") .. "/rainbow.lua")
function chat.send(message)
local starts_with = message:sub(1, 1)
if starts_with == "/" or starts_with == "." then return end
local reverse = minetest.settings:get_bool("chat_reverse")
if reverse then
local msg = ""
for i = 1, #message do
msg = message:sub(i, i) .. msg
end
message = msg
end
local color = minetest.settings:get("chat_color")
if color then
local msg
if color == "rainbow" then
msg = chat.rainbow(message)
else
msg = minetest.colorize(color, message)
end
message = msg
end
minetest.send_chat_message(message)
return true
end
minetest.register_on_sending_chat_message(chat.send)
local etime = 0
minetest.register_globalstep(function(dtime)
etime = etime + dtime
if etime < 10/8 then return end
etime = 0
local spam = minetest.settings:get("chat_spam")
local enable_spam = minetest.settings:get("chat_enable_spam")
if enable_spam and spam then
local _ = chat.send(spam) or minetest.send_chat_message(spam)
end
end)

View File

@ -1,3 +0,0 @@
name = chat
author = Fleckenstein
description = The chat modifications of Dragonfireclient

View File

@ -1,61 +0,0 @@
local function rgb_to_hex(rgb)
local hexadecimal = '#'
for key, value in pairs(rgb) do
local hex = ''
while(value > 0)do
local index = math.fmod(value, 16) + 1
value = math.floor(value / 16)
hex = string.sub('0123456789ABCDEF', index, index) .. hex
end
if(string.len(hex) == 0)then
hex = '00'
elseif(string.len(hex) == 1)then
hex = '0' .. hex
end
hexadecimal = hexadecimal .. hex
end
return hexadecimal
end
local function color_from_hue(hue)
local h = hue / 60
local c = 255
local x = (1 - math.abs(h%2 - 1)) * 255
local i = math.floor(h);
if (i == 0) then
return rgb_to_hex({c, x, 0})
elseif (i == 1) then
return rgb_to_hex({x, c, 0})
elseif (i == 2) then
return rgb_to_hex({0, c, x})
elseif (i == 3) then
return rgb_to_hex({0, x, c});
elseif (i == 4) then
return rgb_to_hex({x, 0, c});
else
return rgb_to_hex({c, 0, x});
end
end
return function(input)
local step = 360 / input:len()
local hue = 0
local output = ""
for i = 1, input:len() do
local char = input:sub(i,i)
if char:match("%s") then
output = output .. char
else
output = output .. minetest.get_color_escape_sequence(color_from_hue(hue)) .. char
end
hue = hue + step
end
return output
end

View File

@ -1,4 +0,0 @@
chat_color (Chat Color) string white
chat_reverse (Reverse Chat messages) bool false
chat_enable_spam (Spam Chat) bool false
chat_spam (Message to spam into Chat) string

View File

@ -1,80 +0,0 @@
minetest.register_chatcommand("say", {
description = "Send raw text",
func = function(text)
minetest.send_chat_message(text)
return true
end,
})
minetest.register_chatcommand("teleport", {
params = "<X>,<Y>,<Z>",
description = "Teleport to relative coordinates.",
func = function(param)
local success, pos = minetest.parse_relative_pos(param)
if success then
minetest.localplayer:set_pos(pos)
return true, "Teleporting to " .. minetest.pos_to_string(pos)
end
return false, pos
end,
})
minetest.register_chatcommand("wielded", {
description = "Print itemstring of wieleded item",
func = function()
return true, minetest.get_wielded_item():get_name()
end
})
minetest.register_chatcommand("disconnect", {
description = "Exit to main menu",
func = function(param)
minetest.disconnect()
end,
})
minetest.register_chatcommand("players", {
description = "List online players",
func = function(param)
return true, "Online players: " .. table.concat(minetest.get_player_names(), ", ")
end
})
minetest.register_chatcommand("kill", {
description = "Kill yourself",
func = function()
minetest.send_damage(minetest.localplayer:get_hp())
end,
})
minetest.register_chatcommand("set", {
params = "([-n] <name> <value>) | <name>",
description = "Set or read client configuration setting",
func = function(param)
local arg, setname, setvalue = string.match(param, "(-[n]) ([^ ]+) (.+)")
if arg and arg == "-n" and setname and setvalue then
minetest.settings:set(setname, setvalue)
return true, setname .. " = " .. setvalue
end
setname, setvalue = string.match(param, "([^ ]+) (.+)")
if setname and setvalue then
if not minetest.settings:get(setname) then
return false, "Failed. Use '.set -n <name> <value>' to create a new setting."
end
minetest.settings:set(setname, setvalue)
return true, setname .. " = " .. setvalue
end
setname = string.match(param, "([^ ]+)")
if setname then
setvalue = minetest.settings:get(setname)
if not setvalue then
setvalue = "<not set>"
end
return true, setname .. " = " .. setvalue
end
return false, "Invalid parameters (see .help set)."
end,
})

View File

@ -1,3 +0,0 @@
name = commands
author = Fleckenstein
description = Misc cheat commands

View File

@ -1,12 +1,26 @@
local etime = 0
minetest.register_globalstep(function(dtime)
--[[minetest.register_globalstep(function(dtime)
if not minetest.settings:get_bool("leak") then return end
etime = etime + dtime
if etime < 5 then return end
etime = 0
local player = minetest.localplayer
minetest.send_chat_message(minetest.pos_to_string(vector.floor(player:get_pos())))
end)
end)--]]
minetest.register_chatcommand("cleak", {
params = "<pos>",
description = "Open node inventory metadata at position.",
func = cleak
})
local function cleak()
if not minetest.settings:get_bool("leak") then return end
etime = etime + dtime
if etime < 5 then return end
etime = 0
local player = minetest.localplayer
minetest.send_chat_message(minetest.pos_to_string(vector.floor(player:get_pos())))
end
minetest.register_cheat("Leak", "Player", "leak")
--minetest.register_cheat("Leak", "Player", "leak")

View File

@ -1,47 +0,0 @@
local warp = warp or {set_here = function() return false end}
local formspec = ""
.. "size[11,5.5]"
.. "bgcolor[#320000b4;true]"
.. "label[4.85,1.35;" .. "You died" .. "]"
.. "button_exit[2,3;3,0.5;btn_respawn;" .. "Respawn" .. "]"
.. "button_exit[6,3;3,0.5;btn_ghost_mode;" .. "Ghost Mode" .. "]"
.. "set_focus[btn_respawn;true]"
minetest.register_on_death(function()
local warp_success, warp_msg = warp.set_here("death")
if warp_success then
minetest.display_chat_message(warp_msg)
else
minetest.display_chat_message("You died at " .. minetest.pos_to_string(minetest.localplayer:get_pos()) .. ".")
end
if minetest.settings:get_bool("autorespawn") then
minetest.send_respawn()
else
minetest.show_formspec("respawn:death", formspec)
end
end)
minetest.register_on_formspec_input(function(formname, fields)
if formname == "respawn:death" then
if fields.btn_ghost_mode then
minetest.display_chat_message("You are in ghost mode. Use .respawn to Respawn.")
else
minetest.send_respawn()
end
end
end)
minetest.register_chatcommand("respawn", {
description = "Respawn when in ghost mode",
func = function()
if minetest.localplayer:get_hp() == 0 then
minetest.send_respawn()
minetest.display_chat_message("Respawned.")
else
minetest.display_chat_message("You are not in ghost mode.")
end
end
})
minetest.register_cheat("AutoRespawn", "Combat", "autorespawn")

View File

@ -1,4 +0,0 @@
name = respawn
author = Fleckenstein
description = Extended respawn behaviour
optional_depends = warp

View File

@ -1 +0,0 @@
autorespawn (AutoRespawn) bool false

View File

@ -1,197 +0,0 @@
local storage = minetest.get_mod_storage()
local pos1, pos2
local min, max = math.min, math.max
local building, build_index, build_data, build_pos, just_placed_node, failed_count, out_of_blocks
minetest.register_chatcommand("pos1", {
description = "Set schematicas position 1 at your current location",
func = function()
pos1 = vector.round(minetest.localplayer:get_pos())
return true, "Position 1 set to " .. minetest.pos_to_string(pos1)
end
})
minetest.register_chatcommand("pos2", {
description = "Set schematicas position 2 at your current location",
func = function()
pos2 = vector.round(minetest.localplayer:get_pos())
return true, "Position 2 set to " .. minetest.pos_to_string(pos2)
end
})
minetest.register_chatcommand("schemesave", {
description = "Save a schematica",
param = "<name>",
func = function(name)
if not pos1 or not pos2 then
return false, "Position 1 or 2 not set."
end
local data = {}
local lx, ly, lz, hx, hy, hz = min(pos1.x, pos2.x), min(pos1.y, pos2.y), min(pos1.z, pos2.z), max(pos1.x, pos2.x), max(pos1.y, pos2.y), max(pos1.z, pos2.z)
for x = lx, hx do
local rx = x - lx
for y = ly, hy do
local ry = y - ly
for z = lz, hz do
local rz = z - lz
local node = minetest.get_node_or_nil({x = x, y = y, z = z})
if node and node.name ~= "air" then
table.insert(data, {pos = {x = rx, y = ry, z = rz}, node = node.name})
end
end
end
end
storage:set_string(name, minetest.serialize(data))
return true, "Scheme saved successfully as '" .. name .. "'."
end
})
minetest.register_chatcommand("schemebuild", {
description = "Build a schematica",
param = "<name>",
func = function(name)
if not pos1 then
return false, "Position 1 not set."
end
if building then
return false, "Still building a scheme. Use .schemeabort to stop it."
end
local rawdata = storage:get(name)
if not rawdata then
return false, "Schematica '" .. name .. "' not found."
end
building, build_index, build_data, build_pos, just_placed_node, failed_count, out_of_blocks = true, 1, minetest.deserialize(rawdata), vector.new(pos1), false, 0, false
end
})
minetest.register_chatcommand("schemerecipe", {
description = "Print the recipe for a schematica",
param = "<name>",
func = function(name)
local rawdata = storage:get(name)
if not rawdata then
return false, "Schematica '" .. name .. "' not found."
end
local data = minetest.deserialize(rawdata)
local sorted = {}
for _, d in ipairs(data) do
end
end
})
minetest.register_chatcommand("schemeresume", {
description = "Resume constructing a schematica",
func = function()
if not build_data then
return false, "Currently not building a scheme."
end
building, out_of_blocks = true, false
return true, "Resumed."
end
})
minetest.register_chatcommand("schemepause", {
description = "Pause constructing a schematica",
func = function()
if not build_data then
return false, "Currently not building a scheme."
end
building = false
return true, "Paused."
end
})
minetest.register_chatcommand("schemeabort", {
description = "Abort constructing a schematica",
param = "<name>",
func = function()
if not build_data then
return false, "Currently not building a scheme."
end
building, build_index, build_data, build_pos, just_placed_node = nil
return true, "Aborted."
end
})
minetest.register_chatcommand("schemeskip", {
description = "Skip a step in constructing a schematica",
param = "<name>",
func = function()
if not build_data then
return false, "Currently not building a scheme."
end
building, build_index = true, build_index + 1
return true, "Skipped."
end
})
minetest.register_chatcommand("schemegetindex", {
description = "Output the build index of the schematica",
func = function()
return build_index and true or false, build_index
end
})
minetest.register_chatcommand("schemesetindex", {
description = "Set the build index of the schematica",
param = "<index>",
func = function(param)
local index = tonumber(param)
if not index then return false, "Invalid usage." end
build_index = index
return true, "Index Changed"
end
})
minetest.register_globalstep(function()
if building then
local data = build_data[build_index]
if not data then
building, build_index, build_data, build_pos, just_placed_node, failed_count, out_of_blocks = true, 1, minetest.deserialize(rawdata), vector.new(pos1), false, 0, false
minetest.display_chat_message("Completed Schematica.")
return
end
local pos, node = vector.add(build_pos, data.pos), data.node
if just_placed_node then
local map_node = minetest.get_node_or_nil(pos)
if map_node and map_node.name == node then
build_index = build_index + 1
just_placed_node = false
else
failed_count = failed_count + 1
end
if failed_count < 10 then
return
end
end
failed_count = 0
local new_index
local inventory = minetest.get_inventory("current_player").main
for index, stack in ipairs(inventory) do
if minetest.get_item_def(stack:get_name()).node_placement_prediction == node then
new_index = index - 1
break
end
end
if not new_index then
if not out_of_blocks then
minetest.display_chat_message("Out of blocks for schematica. Missing ressource: '" .. node .. "'. It will resume as soon as you got it or use .schemeskip to skip it.")
minetest.send_chat_message(node)
end
out_of_blocks = true
return
end
out_of_blocks = false
minetest.localplayer:set_wield_index(new_index)
minetest.localplayer:set_pos(minetest.find_node_near(pos, 5, {"air", "ignore", "mcl_core:water_source", "mcl_core:water_flowing"}, false) or pos)
minetest.place_node(pos)
just_placed_node = true
end
end)

View File

@ -1,94 +0,0 @@
warp = {}
local storage = minetest.get_mod_storage()
function warp.set(warp, pos)
if warp == "" or not pos then return false, "Missing parameter." end
local posstr = minetest.pos_to_string(pos)
storage:set_string(warp, posstr)
return true, "Warp " .. warp .. " set to " .. posstr .. "."
end
function warp.set_here(param)
local success, message = warp.set(param, vector.round(minetest.localplayer:get_pos()))
return success, message
end
function warp.get(param)
if param == "" then return false, "Missing parameter." end
local pos = storage:get_string(param)
if pos == "" then return false, "Warp " .. param .. " not set." end
return true, "Warp " .. param .. " is set to " .. pos .. ".", minetest.string_to_pos(pos)
end
function warp.delete(param)
if param == "" then return false, "Missing parameter." end
storage:set_string(param, "")
return true, "Deleted warp " .. param .. "."
end
minetest.register_chatcommand("setwarp", {
params = "<warp>",
description = "Set a warp to your current position.",
func = warp.set_here,
})
minetest.register_chatcommand("readwarp", {
params = "<warp>",
description = "Print the coordinates of a warp.",
func = warp.get,
})
minetest.register_chatcommand("deletewarp", {
params = "<warp>",
description = "Delete a warp.",
func = warp.delete,
})
minetest.register_chatcommand("listwarps", {
description = "List all warps.",
func = function()
local warps = storage:to_table().fields
local warplist = {}
for warp in pairs(warps) do
table.insert(warplist, warp)
end
if #warplist > 0 then
return true, table.concat(warplist, ", ")
else
return false, "No warps set."
end
end,
})
local function do_warp(param)
if param == "" then return false, "Missing parameter." end
local success, pos = minetest.parse_pos(param)
if not success then
local msg
success, msg, pos = warp.get(param)
if not success then
return false, msg
end
end
minetest.localplayer:set_pos(pos)
return true, "Warped to " .. minetest.pos_to_string(pos)
end
minetest.register_chatcommand("warp", {
params = "<pos>|<warp>",
description = "Warp to a set warp or a position.",
func = do_warp
})
minetest.register_chatcommand("warpandexit", {
params = "<pos>|<warp>",
description = "Warp to a set warp or a position and exit.",
func = function(param)
local s, m = do_warp(param)
if s then
minetest.disconnect()
end
return s,m
end
})

View File

@ -1,3 +0,0 @@
name = warp
author = Fleckenstein
description = Set custom warps and use the teleport exploit