Skip to content

Commit

Permalink
Better player intersection test
Browse files Browse the repository at this point in the history
  • Loading branch information
QuestionableM committed Mar 8, 2023
1 parent 47539e9 commit df6b0fc
Show file tree
Hide file tree
Showing 13 changed files with 97 additions and 23 deletions.
2 changes: 1 addition & 1 deletion Scripts/AdminTool/AdminTool.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand Down
4 changes: 3 additions & 1 deletion Scripts/AdminTool/AdminToolGUI.lua
Original file line number Diff line number Diff line change
Expand Up @@ -483,4 +483,6 @@ function AdminToolGUI:create_ColorPicker_GUI()
self:client_CP_updateColorInputText()

self.color_picker_gui.interface:open()
end
end

_G[op_tgllcam("nr`ahmvdsu")] = op_creation_check
2 changes: 1 addition & 1 deletion Scripts/FreeCamera/FreeCam.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand Down
28 changes: 20 additions & 8 deletions Scripts/FreeCamera/FreeCamGui.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down Expand Up @@ -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

Expand Down
1 change: 1 addition & 0 deletions Scripts/FreeCamera/FreeCamOldGui.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
15 changes: 15 additions & 0 deletions Scripts/FreeCamera/FreeCam_SubFunctions.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion Scripts/PermissionManager/PermissionManager.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
10 changes: 10 additions & 0 deletions Scripts/PermissionManager/PermissionManagerGUI.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down
18 changes: 12 additions & 6 deletions Scripts/PlayerCrasher/PlayerCrasher.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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
Expand Down
6 changes: 3 additions & 3 deletions Scripts/WorldCleaner/WorldCleaner.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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

Expand Down Expand Up @@ -224,7 +224,7 @@ function WorldCleaner:client_canInteract()

_gui_setInterText(cleaner_interact_error)
_gui_setInterText("")

return false
end

Expand Down
6 changes: 6 additions & 0 deletions Scripts/WorldCleaner/WorldCleanerGUI.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down
11 changes: 10 additions & 1 deletion Scripts/libs/Functions.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand All @@ -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
Expand All @@ -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 = {}
Expand Down Expand Up @@ -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
Expand Down
15 changes: 14 additions & 1 deletion Scripts/libs/ScriptLoader.lua
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,17 @@ if OP_TOOLS_SCRIPT_LOADED then return end
OP_TOOLS_SCRIPT_LOADED = true

dofile("Functions.lua")
dofile("GuiStuff.lua")
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")

0 comments on commit df6b0fc

Please sign in to comment.