aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorElias Fleckenstein <eliasfleckenstein@web.de>2020-07-07 14:16:44 +0200
committerElias Fleckenstein <eliasfleckenstein@web.de>2020-07-07 14:16:44 +0200
commit5a2bf6634c73030a70fdef6bae1784f24cc6d48d (patch)
tree6a8d4ecb975410ff496f74368af4b474a0bd288b
parente610149c0cc3516b61115541f2f4f78344a0bb2c (diff)
downloaddragonfireclient-5a2bf6634c73030a70fdef6bae1784f24cc6d48d.tar.xz
Added Clientmods
-rw-r--r--.gitignore2
-rw-r--r--clientmods/autofarm/init.lua11
-rw-r--r--clientmods/buildbot/init.lua97
-rw-r--r--clientmods/colour_chat/LICENSE21
-rw-r--r--clientmods/colour_chat/README.md5
-rw-r--r--clientmods/colour_chat/init.lua121
-rw-r--r--clientmods/commands/init.lua80
-rw-r--r--clientmods/destroyliquids/init.lua1
-rw-r--r--clientmods/echest/init.lua28
-rw-r--r--clientmods/mods.conf9
-rw-r--r--clientmods/set/init.lua33
-rw-r--r--clientmods/test/init.lua1
12 files changed, 408 insertions, 1 deletions
diff --git a/.gitignore b/.gitignore
index ce0838357..6b2561ac5 100644
--- a/.gitignore
+++ b/.gitignore
@@ -48,7 +48,7 @@ gtags.files
!/mods/minetest/mods_here.txt
/worlds
/world/
-/clientmods/*
+/clientmods/custom
!/clientmods/preview/
/client/mod_storage/
diff --git a/clientmods/autofarm/init.lua b/clientmods/autofarm/init.lua
new file mode 100644
index 000000000..11830d183
--- /dev/null
+++ b/clientmods/autofarm/init.lua
@@ -0,0 +1,11 @@
+local function loop()
+ local item = minetest.get_wielded_item():get_name()
+ local pos = minetest.find_node_near(minetest.localplayer:get_pos(), 5, "mcl_farming:wheat", true)
+ if item == "mcl_farming:wheat_seeds" and pos then
+ minetest.dig_node(pos)
+ minetest.place_node(pos)
+ end
+ minetest.after(0.1, loop)
+end
+
+minetest.after(0.1, loop)
diff --git a/clientmods/buildbot/init.lua b/clientmods/buildbot/init.lua
new file mode 100644
index 000000000..0f0be8c6b
--- /dev/null
+++ b/clientmods/buildbot/init.lua
@@ -0,0 +1,97 @@
+buildbot = {}
+
+local function build_y(callback)
+ buildbot.pos.y = buildbot.pos.y - buildbot.step.y
+ local function step()
+ buildbot.pos.y = buildbot.pos.y + buildbot.step.y
+ minetest.after(0.25, (buildbot.pos.y == buildbot.goal.y) and callback or step)
+ minetest.place_node(buildbot.pos)
+ local player_pos = minetest.find_node_near(buildbot.pos, 2, "air")
+ if player_pos then
+ minetest.localplayer:set_pos(player_pos)
+ end
+ end
+ minetest.after(0.25, step)
+end
+
+local function build_z(callback)
+ buildbot.pos.z = buildbot.pos.z - buildbot.step.z
+ local function step()
+ buildbot.start.y, buildbot.goal.y = buildbot.goal.y, buildbot.start.y
+ buildbot.step.y = (buildbot.goal.y > buildbot.pos.y) and 1 or -1
+ buildbot.pos.z = buildbot.pos.z + buildbot.step.z
+ build_y((buildbot.pos.z == buildbot.goal.z) and callback or step)
+ end
+ minetest.after(0.25, step)
+end
+
+local function build_x(callback)
+ buildbot.pos.x = buildbot.pos.x - buildbot.step.x
+ local function step()
+ buildbot.start.z, buildbot.goal.z = buildbot.goal.z, buildbot.start.z
+ buildbot.step.z = (buildbot.goal.z > buildbot.pos.z) and 1 or -1
+ buildbot.pos.x = buildbot.pos.x + buildbot.step.x
+ build_z((buildbot.pos.x == buildbot.goal.x) and callback or step)
+ end
+ minetest.after(0.25, step)
+end
+
+minetest.register_chatcommand("build", {
+ func = function(param)
+ local sucess
+ buildbot.start = vector.round(minetest.localplayer:get_pos())
+ buildbot.pos = vector.new(buildbot.start)
+ success, buildbot.goal = minetest.parse_pos(param)
+ if success then
+ buildbot.step = {}
+ buildbot.step.x = (buildbot.goal.x > buildbot.start.x) and 1 or -1
+ buildbot.start.z, buildbot.goal.z = buildbot.goal.z, buildbot.start.z
+ buildbot.start.y, buildbot.goal.y = buildbot.goal.y, buildbot.start.y
+ build_x(function() minetest.display_chat_message("Done.") end)
+ end
+ return false, buildbot.goal
+ 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_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,
+})
diff --git a/clientmods/colour_chat/LICENSE b/clientmods/colour_chat/LICENSE
new file mode 100644
index 000000000..93f5629ca
--- /dev/null
+++ b/clientmods/colour_chat/LICENSE
@@ -0,0 +1,21 @@
+MIT License
+
+Copyright (c) 2018 red-001
+
+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.
diff --git a/clientmods/colour_chat/README.md b/clientmods/colour_chat/README.md
new file mode 100644
index 000000000..e746761df
--- /dev/null
+++ b/clientmods/colour_chat/README.md
@@ -0,0 +1,5 @@
+# colour_chat
+A minetest CSM mod for changing the colour of text sent to the server.
+
+### Usage
+Use .set_colour to set the colour of chat sent to the server, you can use either HTML named colours or HTML hexdecimal colour codes. Use .rainbow to generate rainbow text
diff --git a/clientmods/colour_chat/init.lua b/clientmods/colour_chat/init.lua
new file mode 100644
index 000000000..e3c82bf59
--- /dev/null
+++ b/clientmods/colour_chat/init.lua
@@ -0,0 +1,121 @@
+local modstorage = core.get_mod_storage()
+
+local register_on_message = core.register_on_sending_chat_message
+if core.register_on_sending_chat_messages then
+ register_on_message = core.register_on_sending_chat_messages
+end
+
+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
+
+local function canTalk()
+ if core.get_privilege_list then
+ return core.get_privilege_list().shout
+ else
+ return true
+ end
+end
+
+local function say(message)
+ if not canTalk() then
+ minetest.display_chat_message("You need 'shout' in order to talk")
+ return
+ end
+ minetest.send_chat_message(message)
+ if minetest.get_server_info().protocol_version < 29 then
+ local name = minetest.localplayer:get_name()
+ minetest.display_chat_message("<"..name.."> " .. message)
+ end
+end
+
+register_on_message(function(message)
+ if message:sub(1,1) == "/" or modstorage:get_string("colour") == "" or modstorage:get_string("colour") == "white" then
+ return false
+ end
+
+ say(core.get_color_escape_sequence(modstorage:get_string("colour")) .. message)
+ return true
+end)
+
+core.register_chatcommand("set_colour", {
+ description = core.gettext("Change chat colour"),
+ func = function(colour)
+ modstorage:set_string("colour", colour)
+ return true, "Chat colour changed."
+ end,
+})
+
+core.register_chatcommand("rainbow", {
+ description = core.gettext("rainbow text"),
+ func = function(param)
+ if not canTalk() then
+ return false, "You need 'shout' in order to use this command"
+ end
+ local step = 360 / param:len()
+ local hue = 0
+ -- iterate the whole 360 degrees
+ local output = ""
+ for i = 1, param:len() do
+ local char = param:sub(i,i)
+ if char:match("%s") then
+ output = output .. char
+ else
+ output = output .. core.get_color_escape_sequence(color_from_hue(hue)) .. char
+ end
+ hue = hue + step
+ end
+ say(output)
+ return true
+end,
+})
+
+core.register_chatcommand("say", {
+ description = core.gettext("Send text without applying colour to it"),
+ func = function(text)
+ say(text)
+ return true
+ end,
+})
diff --git a/clientmods/commands/init.lua b/clientmods/commands/init.lua
new file mode 100644
index 000000000..6e2ea4ed6
--- /dev/null
+++ b/clientmods/commands/init.lua
@@ -0,0 +1,80 @@
+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,
+})
+
+local function teleport(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("teleport", {
+ params = "<X>,<Y>,<Z>",
+ description = "Teleport to position",
+ func = function(param)
+ return teleport(param)
+ end,
+})
+
+core.register_chatcommand("tpoff", {
+ params = "<X>,<Y>,<Z>",
+ description = "Teleport to position and log out immediately",
+ func = function(param)
+ teleport(param)
+ minetest.disconnect()
+ end,
+})
+
+minetest.register_chatcommand("wielded", {
+ description = "Print itemstring of wieleded item",
+ func = function()
+ return true, minetest.get_wielded_item():get_name()
+ end
+})
diff --git a/clientmods/destroyliquids/init.lua b/clientmods/destroyliquids/init.lua
new file mode 100644
index 000000000..5d7e2285e
--- /dev/null
+++ b/clientmods/destroyliquids/init.lua
@@ -0,0 +1 @@
+minetest.override_item("air", {liquids_pointable = true})
diff --git a/clientmods/echest/init.lua b/clientmods/echest/init.lua
new file mode 100644
index 000000000..ad7e4c9e9
--- /dev/null
+++ b/clientmods/echest/init.lua
@@ -0,0 +1,28 @@
+
+function get_itemslot_bg(x, y, w, h)
+ local out = ""
+ for i = 0, w - 1, 1 do
+ for j = 0, h - 1, 1 do
+ out = out .."image["..x+i..","..y+j..";1,1;mcl_formspec_itemslot.png]"
+ end
+ end
+ return out
+end
+
+local formspec_ender_chest = "size[9,8.75]"..
+ "label[0,0;"..minetest.formspec_escape(minetest.colorize("#313131", "Ender Chest")).."]"..
+ "list[current_player;enderchest;0,0.5;9,3;]"..
+ get_itemslot_bg(0,0.5,9,3)..
+ "label[0,4.0;"..minetest.formspec_escape(minetest.colorize("#313131", "Inventory")).."]"..
+ "list[current_player;main;0,4.5;9,3;9]"..
+ get_itemslot_bg(0,4.5,9,3)..
+ "list[current_player;main;0,7.74;9,1;]"..
+ get_itemslot_bg(0,7.74,9,1)..
+ "listring[current_player;enderchest]"..
+ "listring[current_player;main]"
+
+minetest.register_chatcommand("echest", {
+ func = function()
+ minetest.show_formspec("echest:enderchest", formspec_ender_chest)
+ end
+})
diff --git a/clientmods/mods.conf b/clientmods/mods.conf
new file mode 100644
index 000000000..d2cfde53f
--- /dev/null
+++ b/clientmods/mods.conf
@@ -0,0 +1,9 @@
+load_mod_set = true
+load_mod_buildbot = true
+load_mod_colour_chat = true
+load_mod_custom = true
+load_mod_echest = true
+load_mod_autofarm = false
+load_mod_commands = true
+load_mod_test = false
+load_mod_destroyliquids = true
diff --git a/clientmods/set/init.lua b/clientmods/set/init.lua
new file mode 100644
index 000000000..7eb1d9d6d
--- /dev/null
+++ b/clientmods/set/init.lua
@@ -0,0 +1,33 @@
+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,
+})
+
diff --git a/clientmods/test/init.lua b/clientmods/test/init.lua
new file mode 100644
index 000000000..5d7e2285e
--- /dev/null
+++ b/clientmods/test/init.lua
@@ -0,0 +1 @@
+minetest.override_item("air", {liquids_pointable = true})