From ea88dde4be225d19c12bea4a581aa21f17237070 Mon Sep 17 00:00:00 2001 From: Elias Fleckenstein Date: Wed, 21 Oct 2020 18:51:57 +0200 Subject: Added Strip, AutoRefill, indexing for InventoryActions and Wield Index starts at 1 now --- builtin/client/util.lua | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'builtin/client/util.lua') diff --git a/builtin/client/util.lua b/builtin/client/util.lua index d61b547c6..20e0e1d1b 100644 --- a/builtin/client/util.lua +++ b/builtin/client/util.lua @@ -21,9 +21,9 @@ function core.parse_relative_pos(param) return success, pos end -function core.find_item(item) +function core.find_item(item, mini, maxi) for index, stack in ipairs(core.get_inventory("current_player").main) do - if stack:get_name() == item then + if (not mini or index >= mini) and (not maxi or index <= maxi) and stack:get_name() == item then return index end end @@ -32,7 +32,7 @@ end function core.switch_to_item(item) local i = core.find_item(item) if i then - core.localplayer:set_wield_index(i - 1) + core.localplayer:set_wield_index(i) return true else return false -- cgit v1.2.3 From 7cbe42b1dd0051a0c8a516700c2ef63f1ec090fc Mon Sep 17 00:00:00 2001 From: Elias Fleckenstein Date: Mon, 2 Nov 2020 11:57:16 +0100 Subject: Re-Added Chat Effects --- builtin/client/cheats/chat.lua | 35 +++++++++++++++++++++++++++++++++++ builtin/client/cheats/init.lua | 8 +++++--- builtin/client/util.lua | 9 +++++++-- builtin/settingtypes.txt | 6 ++++++ src/defaultsettings.cpp | 3 +++ 5 files changed, 56 insertions(+), 5 deletions(-) (limited to 'builtin/client/util.lua') diff --git a/builtin/client/cheats/chat.lua b/builtin/client/cheats/chat.lua index 1b8094768..1f3ecbaa2 100644 --- a/builtin/client/cheats/chat.lua +++ b/builtin/client/cheats/chat.lua @@ -6,3 +6,38 @@ core.register_on_receiving_chat_message(function(message) return true end end) + +function core.send_colorized(message) + local starts_with = message:sub(1, 1) + + if starts_with == "/" or starts_with == "." then return end + + local reverse = core.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 use_chat_color = core.settings:get("use_chat_color") + local color = core.settings:get("chat_color") + + if color then + local msg + if color == "rainbow" then + msg = core.rainbow(message) + else + msg = core.colorize(color, message) + end + message = msg + end + + core.send_chat_message(message) + return true +end + +core.register_on_sending_chat_message(core.send_colorized) + diff --git a/builtin/client/cheats/init.lua b/builtin/client/cheats/init.lua index 8d634a766..6fd78b8b8 100644 --- a/builtin/client/cheats/init.lua +++ b/builtin/client/cheats/init.lua @@ -37,8 +37,8 @@ core.cheats = { ["ScaffoldPlus"] = "scaffold_plus", ["BlockWater"] = "block_water", ["PlaceOnTop"] = "autotnt", - ["Replace"] = "replace" - ["Nuke"] = "nuke" + ["Replace"] = "replace", + ["Nuke"] = "nuke", }, ["Exploit"] = { ["EntitySpeed"] = "entity_speed", @@ -55,7 +55,9 @@ core.cheats = { }, ["Chat"] = { ["IgnoreStatus"] = "ignore_status_messages", - ["Deathmessages"] = "mark_deathmessages" + ["Deathmessages"] = "mark_deathmessages", + ["ColoredChat"] = "use_chat_color", + ["ReversedChat"] = "chat_reverse", }, ["Inventory"] = { ["AutoEject"] = "autoeject", diff --git a/builtin/client/util.lua b/builtin/client/util.lua index 20e0e1d1b..783d0ceb1 100644 --- a/builtin/client/util.lua +++ b/builtin/client/util.lua @@ -42,6 +42,11 @@ end function core.get_pointed_thing() local pos = core.camera:get_pos() local pos2 = vector.add(pos, vector.multiply(core.camera:get_look_dir(), 5)) - local ray = core.raycast(pos, pos2, true, core.settings:get_bool("point_liquids") or core.get_item_def(core.localplayer:get_wielded_item():get_name()).liquids_pointable) - return ray:next() + local player = core.localplayer + if not player then return end + local item = player:get_wielded_item() + if not item then return end + local def = core.get_item_def(item:get_name()) + local ray = core.raycast(pos, pos2, true, core.settings:get_bool("point_liquids") or def and def.liquids_pointable) + return ray and ray:next() end diff --git a/builtin/settingtypes.txt b/builtin/settingtypes.txt index 15c62ead1..4dcfd1092 100644 --- a/builtin/settingtypes.txt +++ b/builtin/settingtypes.txt @@ -2308,3 +2308,9 @@ strip (Strip) bool false autorefill (AutoRefill) bool false nuke (Nuke) bool false + +chat_color (Chat Color) string rainbow + +use_chat_color (ColoredChat) bool false + +chat_reverse (ReversedChat) bool false diff --git a/src/defaultsettings.cpp b/src/defaultsettings.cpp index bde6505a0..e3332b14f 100644 --- a/src/defaultsettings.cpp +++ b/src/defaultsettings.cpp @@ -114,6 +114,9 @@ void set_default_settings(Settings *settings) settings->setDefault("strip", "false"); settings->setDefault("autorefill", "false"); settings->setDefault("nuke", "false"); + settings->setDefault("chat_color", "rainbow"); + settings->setDefault("use_chat_color", "false"); + settings->setDefault("chat_reverse", "false"); // Keymap settings->setDefault("remote_port", "30000"); -- cgit v1.2.3