Skip to content

Commit

Permalink
add debugger interface
Browse files Browse the repository at this point in the history
  • Loading branch information
katsumi143 committed Mar 2, 2024
1 parent a2894d7 commit cfd7522
Show file tree
Hide file tree
Showing 9 changed files with 152 additions and 7 deletions.
2 changes: 1 addition & 1 deletion sourcemap.json
Original file line number Diff line number Diff line change
@@ -1 +1 @@
{"name":"HAKUREALITY","className":"Actor","children":[{"name":"server","className":"Script","filePaths":["src/server/+instance.luau"],"children":[{"name":"kinematics","className":"Folder","children":[{"name":"Head","className":"IKControl"},{"name":"LeftFoot","className":"IKControl"},{"name":"RightFoot","className":"IKControl"},{"name":"LeftHand","className":"IKControl"},{"name":"RightHand","className":"IKControl"},{"name":"LeftLowerLeg","className":"HingeConstraint"},{"name":"RightLowerLeg","className":"HingeConstraint"},{"name":"LeftUpperLeg","className":"BallSocketConstraint"},{"name":"RightUpperLeg","className":"BallSocketConstraint"},{"name":"UpperTorso","className":"BallSocketConstraint"},{"name":"LeftUpperArm","className":"BallSocketConstraint"},{"name":"RightUpperArm","className":"BallSocketConstraint"},{"name":"LeftLowerArm","className":"HingeConstraint"},{"name":"RightLowerArm","className":"HingeConstraint"},{"name":"Head","className":"BallSocketConstraint"}]}]},{"name":"client","className":"Script","filePaths":["src/client/+instance.luau"],"children":[{"name":"experimental_physical_backpack","className":"ModuleScript","filePaths":["src/client/experimental_physical_backpack/+instance.luau"],"children":[{"name":"toolGui","className":"Part","children":[{"name":"SurfaceGui","className":"SurfaceGui"}]}]},{"name":"characters","className":"ModuleScript","filePaths":["src/client/characters.luau"]},{"name":"types","className":"ModuleScript","filePaths":["src/client/types.luau"]}]},{"name":"events","className":"RemoteEvent"},{"name":"sync","className":"UnreliableRemoteEvent"},{"name":"constants","className":"ModuleScript","filePaths":["src/constants.luau"]},{"name":"functions","className":"Folder","children":[{"name":"get_camera","className":"ModuleScript","filePaths":["src/functions/get_camera.luau"]},{"name":"generate_void_wireframe","className":"ModuleScript","filePaths":["src/functions/generate_void_wireframe.luau"]},{"name":"create_instance_group","className":"ModuleScript","filePaths":["src/functions/create_instance_group.luau"]},{"name":"get_point_on_plane","className":"ModuleScript","filePaths":["src/functions/get_point_on_plane.luau"]},{"name":"cleanup_connections","className":"ModuleScript","filePaths":["src/functions/cleanup_connections.luau"]},{"name":"cleanup_instances","className":"ModuleScript","filePaths":["src/functions/cleanup_instances.luau"]},{"name":"mark_instance","className":"ModuleScript","filePaths":["src/functions/mark_instance.luau"]}]},{"name":"effects","className":"Folder","children":[{"name":"void_lighting","className":"ColorCorrectionEffect"},{"name":"void_wireframe","className":"Model","children":[{"name":"wireframe_part","className":"Part","children":[{"name":"wireframe","className":"WireframeHandleAdornment"}]}]},{"name":"void_interface","className":"Model","children":[{"name":"interface_part","className":"Part","children":[{"name":"gui","className":"SurfaceGui","children":[{"name":"acknowledge","className":"TextButton","children":[{"name":"UIPadding","className":"UIPadding"},{"name":"UICorner","className":"UICorner"}]},{"name":"TextLabel","className":"TextLabel"},{"name":"title","className":"TextLabel"},{"name":"info","className":"Frame","children":[{"name":"comfort","className":"TextLabel"},{"name":"UIListLayout","className":"UIListLayout"}]},{"name":"footer","className":"Frame","children":[{"name":"UIListLayout","className":"UIListLayout"},{"name":"ImageLabel","className":"ImageLabel"},{"name":"ImageLabel","className":"ImageLabel"}]},{"name":"version","className":"TextLabel"}]}]}]}]}]}
{"name":"HAKUREALITY","className":"Actor","children":[{"name":"server","className":"Script","filePaths":["src/server/+instance.luau"],"children":[{"name":"kinematics","className":"Folder","children":[{"name":"Head","className":"IKControl"},{"name":"LeftFoot","className":"IKControl"},{"name":"RightFoot","className":"IKControl"},{"name":"LeftHand","className":"IKControl"},{"name":"RightHand","className":"IKControl"},{"name":"LeftLowerLeg","className":"HingeConstraint"},{"name":"RightLowerLeg","className":"HingeConstraint"},{"name":"LeftUpperLeg","className":"BallSocketConstraint"},{"name":"RightUpperLeg","className":"BallSocketConstraint"},{"name":"UpperTorso","className":"BallSocketConstraint"},{"name":"LeftUpperArm","className":"BallSocketConstraint"},{"name":"RightUpperArm","className":"BallSocketConstraint"},{"name":"LeftLowerArm","className":"HingeConstraint"},{"name":"RightLowerArm","className":"HingeConstraint"},{"name":"Head","className":"BallSocketConstraint"}]}]},{"name":"client","className":"Script","filePaths":["src/client/+instance.luau"],"children":[{"name":"experimental_physical_backpack","className":"ModuleScript","filePaths":["src/client/experimental_physical_backpack/+instance.luau"],"children":[{"name":"toolGui","className":"Part","children":[{"name":"SurfaceGui","className":"SurfaceGui"}]}]},{"name":"characters","className":"ModuleScript","filePaths":["src/client/characters.luau"]},{"name":"types","className":"ModuleScript","filePaths":["src/client/types.luau"]},{"name":"debug_gui","className":"ModuleScript","filePaths":["src/client/debug_gui.luau"]}]},{"name":"events","className":"RemoteEvent"},{"name":"sync","className":"UnreliableRemoteEvent"},{"name":"constants","className":"ModuleScript","filePaths":["src/constants.luau"]},{"name":"functions","className":"Folder","children":[{"name":"get_camera","className":"ModuleScript","filePaths":["src/functions/get_camera.luau"]},{"name":"generate_void_wireframe","className":"ModuleScript","filePaths":["src/functions/generate_void_wireframe.luau"]},{"name":"create_instance_group","className":"ModuleScript","filePaths":["src/functions/create_instance_group.luau"]},{"name":"get_point_on_plane","className":"ModuleScript","filePaths":["src/functions/get_point_on_plane.luau"]},{"name":"cleanup_connections","className":"ModuleScript","filePaths":["src/functions/cleanup_connections.luau"]},{"name":"cleanup_instances","className":"ModuleScript","filePaths":["src/functions/cleanup_instances.luau"]},{"name":"mark_instance","className":"ModuleScript","filePaths":["src/functions/mark_instance.luau"]},{"name":"create_fps_counter","className":"ModuleScript","filePaths":["src/functions/create_fps_counter.luau"]},{"name":"get_table_value_count","className":"ModuleScript","filePaths":["src/functions/get_table_value_count.luau"]},{"name":"create_chat_command","className":"ModuleScript","filePaths":["src/functions/create_chat_command.luau"]}]},{"name":"effects","className":"Folder","children":[{"name":"void_lighting","className":"ColorCorrectionEffect"},{"name":"void_wireframe","className":"Model","children":[{"name":"wireframe_part","className":"Part","children":[{"name":"wireframe","className":"WireframeHandleAdornment"}]}]},{"name":"void_interface","className":"Model","children":[{"name":"interface_part","className":"Part","children":[{"name":"gui","className":"SurfaceGui","children":[{"name":"acknowledge","className":"TextButton","children":[{"name":"UIPadding","className":"UIPadding"},{"name":"UICorner","className":"UICorner"}]},{"name":"TextLabel","className":"TextLabel"},{"name":"title","className":"TextLabel"},{"name":"info","className":"Frame","children":[{"name":"comfort","className":"TextLabel"},{"name":"UIListLayout","className":"UIListLayout"}]},{"name":"footer","className":"Frame","children":[{"name":"UIListLayout","className":"UIListLayout"},{"name":"ImageLabel","className":"ImageLabel"},{"name":"ImageLabel","className":"ImageLabel"}]},{"name":"version","className":"TextLabel"}]}]}]}]}]}
2 changes: 2 additions & 0 deletions src/Iris.reference.vie
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
kind: model
asset_id: 16588411082
6 changes: 6 additions & 0 deletions src/client/+instance.luau
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,11 @@ local local_player = Players.LocalPlayer

local types = require(script.types)
local constants = require(root.constants)
local debug_gui = require(script.debug_gui)
local characters = require(script.characters)
local get_camera = require(functions.get_camera)
local cleanup_instances = require(functions.cleanup_instances)
local create_chat_command = require(functions.create_chat_command)
local cleanup_connections = require(functions.cleanup_connections)
local create_instance_group = require(functions.create_instance_group)
local generate_void_wireframe = require(functions.generate_void_wireframe)
Expand Down Expand Up @@ -360,5 +362,9 @@ if VRService.VREnabled then
task.defer(RunService.UnbindFromRenderStep, RunService, "ControlScriptRenderstep")
end

create_chat_command("/hakudebug", function()
debug_gui.visible = not debug_gui.visible
end)

warn(`[HAKUREALITY]: fully initialised, yummy! currently on version {package and package.VersionNumber or "😓❓"}, was loaded from {root:GetAttribute("was_imported_via_loader") and "the require-based loader" or package and package.PackageId == "rbxassetid://15429676683" and "HAKUMI's public package" or "a third-party package, not maintained by HAKUMI" or "an unknown source, not maintained by HAKUMI"}.`)
warn("[HAKUREALITY]: hello, console dweller, if you witness any \"flaws\" with players in virtual reality, pretty please report it directly to HAKUMI!")
6 changes: 5 additions & 1 deletion src/client/characters.luau
Original file line number Diff line number Diff line change
Expand Up @@ -226,7 +226,11 @@ function module.update_others(replication_alpha: number?)
end
end

function module.wait_for_local_character()
function module.get_local_character(): types.Character?
return module.items[local_player]
end

function module.wait_for_local_character(): types.Character
local character = module.items[local_player]
if not character then
locally_created_event.Event:Wait()
Expand Down
76 changes: 76 additions & 0 deletions src/client/debug_gui.luau
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
--!strict
local VRService = game:GetService("VRService")
local RunService = game:GetService("RunService")

local client = script.Parent
local root = client.Parent
local package = root:FindFirstChild("PackageLink")
local functions = root.functions

local characters = require(client.characters)
local create_fps_counter = require(functions.create_fps_counter)
local get_table_value_count = require(functions.get_table_value_count)
local experimental_physical_backpack = require(client.experimental_physical_backpack)

local Iris = require(root.Iris).Init()

local user_cframes = Enum.UserCFrame:GetEnumItems()
local render_counter = create_fps_counter(RunService.PreRender)
local initial_visibility = false

-- special thing for QSERF DevSite (temporary)
if game.PlaceId == 4744058827 and VRService.VREnabled then
initial_visibility = true
end

local module = {
visible = initial_visibility
}

local system_version = package and `v0.0.{package.VersionNumber}` or "Unknown Version"
Iris:Connect(function()
if module.visible then
local character = characters.get_local_character()
local is_backpack_open = experimental_physical_backpack.is_open
Iris.Window({`HAKUREALITY Debugger — {system_version}` :: any, nil, nil, nil, true})
Iris.Text({`FPS: {render_counter.value}`})
Iris.Text({`Characters: {get_table_value_count(characters.items)}`})
if character then
Iris.Tree({"Local Character"})
Iris.Text({`model: {character.model:GetFullName()}`})
Iris.Text({`is_dead: {character.is_dead}`})
Iris.Text({`humanoid: {character.humanoid and character.humanoid:GetFullName()}`})
Iris.Text({`left_foot: {character.left_foot and character.left_foot:GetFullName()}`})
Iris.Text({`right_foot: {character.right_foot and character.right_foot:GetFullName()}`})
Iris.Text({`waist_motor: {character.waist_motor and character.waist_motor:GetFullName()}`})
Iris.Text({`connections: {#character.connections}`})
Iris.Tree({"cframes"})
for _,kind in user_cframes do
Iris.Text({`{kind.Name}: {character.cframes[kind.Value + 1]}`})
end
Iris.End()
Iris.Tree({"kinematics"})
for name, kinematic in character.kinematics do
Iris.Tree({name})
Iris.Text({`control: {kinematic.control:GetFullName()}`})
Iris.Text({`control_target: {kinematic.control_target and kinematic.control_target:GetFullName()}`})
Iris.Text({`control_target_identity: {kinematic.control_target_identity}`})
Iris.End()
end
Iris.End()
Iris.End()
end
Iris.Tree({"Physical Backpack"})
Iris.Text({`open: {is_backpack_open}`})
if is_backpack_open then
local gui = assert(experimental_physical_backpack.current_gui)
Iris.Text({`items: {#gui.items}`})
Iris.Text({`position: {gui.position}`})
Iris.Text({`current_item: {gui.current_item}`})
end
Iris.End()
Iris.End()
end
end)

return module
12 changes: 7 additions & 5 deletions src/client/experimental_physical_backpack/+instance.luau
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,6 @@ local local_player = Players.LocalPlayer
local get_camera = require(functions.get_camera)
local get_point_on_plane = require(functions.get_point_on_plane)

local module = {
is_open = false
}

local backpack_gui: {
part: Part,
test: Frame,
Expand All @@ -23,6 +19,11 @@ local backpack_gui: {
current_item: number?
}?

local module = {
is_open = false,
current_gui = backpack_gui
}

function module.open()
module.is_open = true
if backpack_gui then
Expand Down Expand Up @@ -116,6 +117,7 @@ function module.open()
items = items,
position = VRService:GetUserCFrame(Enum.UserCFrame.RightHand).Position or -Vector3.zAxis * 4
}
module.current_gui = backpack_gui
end

function module.close()
Expand All @@ -133,7 +135,7 @@ function module.close()
end

backpack_gui.part:Destroy()
backpack_gui = nil
backpack_gui, module.current_gui = nil
end
end

Expand Down
16 changes: 16 additions & 0 deletions src/functions/create_chat_command.luau
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
--!strict
local TextChatService = game:GetService("TextChatService")

local can_create = TextChatService.ChatVersion == Enum.ChatVersion.TextChatService
return function(primary_alias: string, callback: (origin_text_source: TextSource, unfiltered_text: string) -> ()): TextChatCommand?
if can_create then
local command = Instance.new("TextChatCommand")
command.PrimaryAlias = primary_alias
command.Triggered:Connect(callback)
command.Parent = TextChatService

return command
end

return nil
end
27 changes: 27 additions & 0 deletions src/functions/create_fps_counter.luau
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
--!strict
export type FpsCounter = {
value: number,
active: boolean
}
return function(callback: RBXScriptSignal): FpsCounter
local object: FpsCounter = {
value = 0,
active = true
}

local frame_count = 0
local stop_counting_at = os.clock() + 1
callback:Connect(function()
if object.active then
local current_time = os.clock()
if current_time >= stop_counting_at then
object.value = frame_count
frame_count = 0
stop_counting_at = current_time + 1
end
frame_count += 1
end
end)

return object
end
12 changes: 12 additions & 0 deletions src/functions/get_table_value_count.luau
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
--!strict
return function(input: any): number
if typeof(input) == "table" then
local count = 0
for _,_ in input do
count += 1
end

return count
end
return 0
end

0 comments on commit cfd7522

Please sign in to comment.