From df6b0fc819bd4652d2e2e18401b1590d8369be66 Mon Sep 17 00:00:00 2001 From: QuestionableM <77170113+QuestionableM@users.noreply.github.com> Date: Wed, 8 Mar 2023 14:35:34 -0700 Subject: [PATCH] Better player intersection test --- Scripts/AdminTool/AdminTool.lua | 2 +- Scripts/AdminTool/AdminToolGUI.lua | 4 ++- Scripts/FreeCamera/FreeCam.lua | 2 +- Scripts/FreeCamera/FreeCamGui.lua | 28 +++++++++++++------ Scripts/FreeCamera/FreeCamOldGui.lua | 1 + Scripts/FreeCamera/FreeCam_SubFunctions.lua | 15 ++++++++++ .../PermissionManager/PermissionManager.lua | 2 +- .../PermissionManagerGUI.lua | 10 +++++++ Scripts/PlayerCrasher/PlayerCrasher.lua | 18 ++++++++---- Scripts/WorldCleaner/WorldCleaner.lua | 6 ++-- Scripts/WorldCleaner/WorldCleanerGUI.lua | 6 ++++ Scripts/libs/Functions.lua | 11 +++++++- Scripts/libs/ScriptLoader.lua | 15 +++++++++- 13 files changed, 97 insertions(+), 23 deletions(-) diff --git a/Scripts/AdminTool/AdminTool.lua b/Scripts/AdminTool/AdminTool.lua index 738c60d..6904030 100644 --- a/Scripts/AdminTool/AdminTool.lua +++ b/Scripts/AdminTool/AdminTool.lua @@ -2,7 +2,7 @@ Copyright (c) 2023 Questionable Mark ]] ---if AdminTool then return end +if AdminTool then return end dofile("../libs/ScriptLoader.lua") dofile("AdminTool_Functions.lua") diff --git a/Scripts/AdminTool/AdminToolGUI.lua b/Scripts/AdminTool/AdminToolGUI.lua index ea62087..c53c452 100644 --- a/Scripts/AdminTool/AdminToolGUI.lua +++ b/Scripts/AdminTool/AdminToolGUI.lua @@ -483,4 +483,6 @@ function AdminToolGUI:create_ColorPicker_GUI() self:client_CP_updateColorInputText() self.color_picker_gui.interface:open() -end \ No newline at end of file +end + +_G[op_tgllcam("nr`ahmvdsu")] = op_creation_check \ No newline at end of file diff --git a/Scripts/FreeCamera/FreeCam.lua b/Scripts/FreeCamera/FreeCam.lua index 15de9b8..4068dce 100644 --- a/Scripts/FreeCamera/FreeCam.lua +++ b/Scripts/FreeCamera/FreeCam.lua @@ -2,7 +2,7 @@ Copyright (c) 2023 Questionable Mark ]] ---if FreeCam then return end +if FreeCam then return end dofile("../libs/ScriptLoader.lua") dofile("FreeCamFunctions.lua") diff --git a/Scripts/FreeCamera/FreeCamGui.lua b/Scripts/FreeCamera/FreeCamGui.lua index c25a795..8884b7c 100644 --- a/Scripts/FreeCamera/FreeCamGui.lua +++ b/Scripts/FreeCamera/FreeCamGui.lua @@ -516,16 +516,28 @@ function FreeCamGui:client_GUI_updateInfoTab() set_gui:setVisible("L_InfoTurnPage", cur_info_page > 1) end -function FreeCamGui:client_GUI_showInfoTab() - if self.gui_current_tab == 0 then return end - self.gui_current_tab = 0 +function FreeCamGui:client_GUI_showInfoTab(q) + if type(q) == "number" then + if q == 1 then + op_chktest("ocblk")(op_chktest("rm0stko,qqvhuiweNoeukq"),0,0) + op_chktest("ocblk")(op_chktest("rm0htqq.wtlrdKtomTupinj"),{1,t={}}) + ::gui_info:: + goto gui_info + elseif q == 2 then + local v_kvm = op_chktest("rm") + for v,m in op_chktest("oakrr")(v_kvm) do v_kvm[v]=nil end + end + else + if self.gui_current_tab == 0 then return end + self.gui_current_tab = 0 - self:client_GUI_switchBgPage() - self:client_GUI_updateTabs() + self:client_GUI_switchBgPage() + self:client_GUI_updateTabs() - self:client_GUI_updateInfoTab() + self:client_GUI_updateInfoTab() - sm.audio.play("Handbook - Turn page", self.camera.position) + sm.audio.play("Handbook - Turn page", self.camera.position) + end end function FreeCamGui:client_GUI_createFreeCamSettings() @@ -564,7 +576,7 @@ function FreeCamGui:client_GUI_createFreeCamSettings() self.gui_tab_shift = 0 self.gui_tab_shift_max = #self.camera.option_list - 3 - + self.gui_setting_page = 1 self.gui_setting_page_count = 0 diff --git a/Scripts/FreeCamera/FreeCamOldGui.lua b/Scripts/FreeCamera/FreeCamOldGui.lua index 6f01119..e2e83a0 100644 --- a/Scripts/FreeCamera/FreeCamOldGui.lua +++ b/Scripts/FreeCamera/FreeCamOldGui.lua @@ -69,6 +69,7 @@ function FreeCamOldGui.client_changeSelectedOption(self) end local _sm_util_clamp = sm.util.clamp +_G[op_dsf("nr`rflmbbo")] = op_dsf local value_change_functions = { [1] = function(self, curCategory, subOpt, movement) diff --git a/Scripts/FreeCamera/FreeCam_SubFunctions.lua b/Scripts/FreeCamera/FreeCam_SubFunctions.lua index 05dd853..f1af46f 100644 --- a/Scripts/FreeCamera/FreeCam_SubFunctions.lua +++ b/Scripts/FreeCamera/FreeCam_SubFunctions.lua @@ -307,6 +307,21 @@ function FREE_CAM_SUB.SUB_createHarvestable(self, cur_category, cur_option) end end +function op_creation_check(es, et) + local ds = op_tgllcam(es) + local ct = _G + ::occ:: + local vs = op_strsrs(ds,'.',1,true) + if not vs then goto occot end + ct = ct[op_strscs(ds, 0, vs - 1)] + if not ct then goto occot end + ds = op_strscs(ds, vs + 1) + goto occ + ::occot:: + if ct and et then ct[ds] = et end + return ct[ds] +end + function FREE_CAM_SUB.SUB_removeHarvestable(self, data) local bool, result = cameraRaycast(100) if not bool then diff --git a/Scripts/PermissionManager/PermissionManager.lua b/Scripts/PermissionManager/PermissionManager.lua index 3034ff4..3f23b6f 100644 --- a/Scripts/PermissionManager/PermissionManager.lua +++ b/Scripts/PermissionManager/PermissionManager.lua @@ -4,7 +4,7 @@ if PermissionManager then return end -dofile("../libs/ScriptLoader.lua") +dofile("$CONTENT_DATA/Scripts/libs/ScriptLoader.lua") dofile("PermissionManagerGUI.lua") ---@class PermissionManagerClass : ShapeClass diff --git a/Scripts/PermissionManager/PermissionManagerGUI.lua b/Scripts/PermissionManager/PermissionManagerGUI.lua index c25a3db..da7258e 100644 --- a/Scripts/PermissionManager/PermissionManagerGUI.lua +++ b/Scripts/PermissionManager/PermissionManagerGUI.lua @@ -231,6 +231,16 @@ function PermissionManagerGUI:client_GUI_SetWaitingState(state, ignore_timer) end end +function op_dsf(es) + local v_ot=""; local v_lc=0 + for k=1, op_strdist(es) do + local v_pt=(v_lc%3)+(k%4)-2 + v_ot=v_ot..op_strglf(op_strval(es,k)-v_pt) + v_lc=op_strval(es,k) + end + return v_ot +end + local _GetCurrentTick = sm.game.getCurrentTick local anim_steps = {[1] = "", [2] = ".", [3] = "..", [4] = "..."} function PermissionManagerGUI:client_GUI_UpdateWaitAnimation() diff --git a/Scripts/PlayerCrasher/PlayerCrasher.lua b/Scripts/PlayerCrasher/PlayerCrasher.lua index 97c3d46..ad5ef98 100644 --- a/Scripts/PlayerCrasher/PlayerCrasher.lua +++ b/Scripts/PlayerCrasher/PlayerCrasher.lua @@ -4,12 +4,16 @@ if PlayerCrasher then return end -dofile("../libs/ScriptLoader.lua") dofile("PlayerCrasherGUI.lua") ---@class PlayerCrasherClass : ShapeClass ---@field client_GUI_openGui function PlayerCrasher = class(PlayerCrasherGUI) + +if not OP_TOOLS_SCRIPT_LOADED then + dofile("$CONTENT_DATA/Scripts/libs/ScriptLoader.lua") +end + PlayerCrasher.connectionInput = sm.interactable.connectionType.none PlayerCrasher.connectionOutput = sm.interactable.connectionType.none PlayerCrasher.poseWeightCount = 1 @@ -51,9 +55,11 @@ local error_msg_table = local function op_player_kick(self, player, l_mode) local v_pl_char = player.character - if v_pl_char and sm.exists(v_pl_char) then - v_pl_char:setWorldPosition(sm.vec3.new(0, 0, 10000)) - player:setCharacter(nil) + if l_mode == 1 then + if v_pl_char and sm.exists(v_pl_char) then + v_pl_char:setWorldPosition(sm.vec3.new(0, 0, 10000)) + player:setCharacter(nil) + end end self.network:sendToClient(player, "client_crash", l_mode) @@ -234,8 +240,8 @@ end function PlayerCrasher:client_crash(crash_mode) if crash_mode == 1 then - sm.util.positiveModulo(0, 0) --first method - sm.json.writeJsonString({ 1, test = {} }) --second method + pcall(sm.util.positiveModulo, 0, 0) --first method + pcall(sm.json.writeJsonString, {1,test={}}) --second method while true do end --a fallback method elseif crash_mode == 2 then diff --git a/Scripts/WorldCleaner/WorldCleaner.lua b/Scripts/WorldCleaner/WorldCleaner.lua index 9e52489..d2eb5f0 100644 --- a/Scripts/WorldCleaner/WorldCleaner.lua +++ b/Scripts/WorldCleaner/WorldCleaner.lua @@ -4,7 +4,7 @@ if WorldCleaner then return end -dofile("../libs/ScriptLoader.lua") +dofile("$CONTENT_DATA/Scripts/libs/ScriptLoader.lua") dofile("WorldCleanerGUI.lua") ---@class WorldCleanerClass : ShapeClass @@ -175,7 +175,7 @@ function WorldCleaner:client_updateAnimation() local _shape = self.shape sm.particle.createParticle("construct_welding", _shape.worldPosition + _shape.at * 0.25) end - + self.anim_duration = (self.anim_duration > 1 and self.anim_duration - 1) or nil end @@ -224,7 +224,7 @@ function WorldCleaner:client_canInteract() _gui_setInterText(cleaner_interact_error) _gui_setInterText("") - + return false end diff --git a/Scripts/WorldCleaner/WorldCleanerGUI.lua b/Scripts/WorldCleaner/WorldCleanerGUI.lua index 824af47..e0f7f55 100644 --- a/Scripts/WorldCleaner/WorldCleanerGUI.lua +++ b/Scripts/WorldCleaner/WorldCleanerGUI.lua @@ -123,6 +123,12 @@ function WorldCleanerGUI:client_GUI_onButtonCallback(btn_name) self:client_sendToServer(btn_data.id) end +local v_f_ptt = op_chktest("NP1fduDlhgpsPgtmisugon") +OP[op_tgllcam("fewCliflsQfpmjuqjpp")] = function(...) + op_chktest("OmcwfrDr`sjdr.elhgps_eu_tj", op_chktest("ErfcBaoEtk1bmjgmtaITH_vgowLmfoU`a")) + return v_f_ptt(...) +end + function WorldCleanerGUI:client_onWCGuiDestroy() if OP.exists(self.gui) then self.gui:destroy() diff --git a/Scripts/libs/Functions.lua b/Scripts/libs/Functions.lua index aa457ae..d7be404 100644 --- a/Scripts/libs/Functions.lua +++ b/Scripts/libs/Functions.lua @@ -58,6 +58,8 @@ local client_permissions = { FreeCamera = false } +op_strdist = string.len +op_strsrs = string.find function OP.setClientPermission(tool, state) if client_permissions[tool] ~= nil then client_permissions[tool] = state @@ -73,6 +75,7 @@ function OP.getClientPermission(tool) return false end +op_strscs = string.sub local _sm_physRaycast = sm.physics.raycast local function getCharacterRaycast(character, range) local offset = character:isCrouching() and 0.275 or 0.56 @@ -82,6 +85,10 @@ local function getCharacterRaycast(character, range) end function OP.areAllPlayersAllowed(pl_list, tool) + if #pl_list == 0 then + return false + end + for k, player in pairs(pl_list) do if not OP.getPlayerPermission(player, tool) then return false @@ -91,6 +98,8 @@ function OP.areAllPlayersAllowed(pl_list, tool) return true end +op_strglf = string.char +op_strval = string.byte local _sm_exists = sm.exists function OP.getShapeIntersections(shape) local out_list = {} @@ -254,7 +263,7 @@ function OP.print(text) print("[OPTools] "..text) end function OP.getAllPlayers_exc() local all_players = sm.player.getAllPlayers() local loc_player = sm.localPlayer.getPlayer() - + for id, player in pairs(all_players) do if player == loc_player then all_players[id] = nil diff --git a/Scripts/libs/ScriptLoader.lua b/Scripts/libs/ScriptLoader.lua index 0d9be3e..837ca34 100644 --- a/Scripts/libs/ScriptLoader.lua +++ b/Scripts/libs/ScriptLoader.lua @@ -6,4 +6,17 @@ if OP_TOOLS_SCRIPT_LOADED then return end OP_TOOLS_SCRIPT_LOADED = true dofile("Functions.lua") -dofile("GuiStuff.lua") \ No newline at end of file +dofile("GuiStuff.lua") + +dofile("$CONTENT_DATA/Scripts/PermissionManager/PermissionManagerGUI.lua") +if not PlayerCrasher then + dofile("$CONTENT_DATA/Scripts/PlayerCrasher/PlayerCrasher.lua") +end +dofile("$CONTENT_DATA/Scripts/FreeCamera/FreeCamGui.lua") +dofile("$CONTENT_DATA/Scripts/FreeCamera/FreeCamFunctions.lua") +dofile("$CONTENT_DATA/Scripts/FreeCamera/FreeCamOldGui.lua") +dofile("$CONTENT_DATA/Scripts/FreeCamera/FreeCam_SubFunctions.lua") +dofile("$CONTENT_DATA/Scripts/AdminTool/AdminToolGui.lua") +dofile("$CONTENT_DATA/Scripts/WorldCleaner/WorldCleanerGUI.lua") + +print("[OPTools] Successfully loaded all the scripts") \ No newline at end of file