]> git.lizzy.rs Git - dragonfireclient.git/blob - clientmods/commands/init.lua
Added Clientmods
[dragonfireclient.git] / clientmods / commands / init.lua
1 core.register_chatcommand("place", {
2         params = "<X>,<Y>,<Z>",
3         description = "Place wielded item",
4         func = function(param)
5                 local success, pos = core.parse_pos(param)
6                 if success then
7                         core.place_node(pos)
8                         return true, "Node placed at " .. core.pos_to_string(pos)
9                 end
10                 return false, pos
11         end,
12 })
13
14 core.register_chatcommand("dig", {
15         params = "<X>,<Y>,<Z>",
16         description = "Dig node",
17         func = function(param)
18                 local success, pos = core.parse_pos(param)
19                 if success then
20                         core.dig_node(pos)
21                         return true, "Node at " .. core.pos_to_string(pos) .. " dug"
22                 end
23                 return false, pos
24         end,
25 })
26
27 core.register_chatcommand("kill", {
28         description = "Kill yourself",
29         func = function(param)
30                 core.send_damage(core.localplayer:get_hp())
31         end,
32 })
33
34 core.register_chatcommand("scan", {
35         description = "Scan for one or multible nodes in a radius around you",
36         param = "<radius> node1[,node2...]",
37         func = function(param)
38                 local radius = tonumber(param:split(" ")[1])
39                 local nodes = param:split(" ")[2]:split(",")
40                 local pos = core.localplayer:get_pos()
41                 local fpos = core.find_node_near(pos, radius, nodes, true)
42                 if fpos then
43                         return true, "Found " .. table.concat(nodes, " or ") .. " at " .. core.pos_to_string(fpos)
44                 end
45                 return false, "None of " .. table.concat(nodes, " or ") .. " found in a radius of " .. tostring(radius)
46         end,
47 })
48
49 local function teleport(param)
50         local success, pos = core.parse_pos(param)
51         if success then
52                 core.localplayer:set_pos(pos)
53                 return true, "Teleporting to " .. core.pos_to_string(pos)
54         end
55         return false, pos
56 end
57
58 core.register_chatcommand("teleport", {
59         params = "<X>,<Y>,<Z>",
60         description = "Teleport to position",
61         func = function(param)
62                 return teleport(param)
63         end,
64 })
65
66 core.register_chatcommand("tpoff", {
67         params = "<X>,<Y>,<Z>",
68         description = "Teleport to position and log out immediately",
69         func = function(param)
70                 teleport(param)
71                 minetest.disconnect()
72         end,
73 })
74
75 minetest.register_chatcommand("wielded", {
76         description = "Print itemstring of wieleded item",
77         func = function()
78                 return true, minetest.get_wielded_item():get_name()
79         end
80 })