Skip to content

Commit

Permalink
tostring override removed
Browse files Browse the repository at this point in the history
  • Loading branch information
unknown-gd committed Mar 11, 2024
1 parent 5afbf56 commit 2da3d67
Showing 1 changed file with 3 additions and 84 deletions.
87 changes: 3 additions & 84 deletions lua/autorun/!!!random-patches.yue
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ CLIENT = CLIENT
SERVER = SERVER
pairs = pairs

addonName = "Random Patches v5.17.3"
addonName = "Random Patches v5.17.4"

getHookName = ( patchName, hookName ) ->
return addonName .. "::" .. patchName .. ( hookName or "" )
Expand Down Expand Up @@ -330,56 +330,15 @@ do
do

getmetatable = getmetatable
:format = string

-- global tostring
do

type = type

global tostring = ( value ) ->
metatable = getmetatable( value )
if metatable
func = metatable.__tostring
if func
return func( value )

return format( "%s: %p", type( value ), value )

:EntIndex = ENTITY

-- Entity
do

ENTITY.__type = "Entity"
:IsWorld = ENTITY

ENTITY.__tostring = ( entity ) ->
if IsValid( entity ) or IsWorld( entity )
return ( entity.__type or "Entity" ) .. " [" .. EntIndex( entity ) .. "][" .. GetClass( entity ) .. "]"

return "[NULL " .. ( entity.__type or "Entity" ) .. "]"

-- Player
do

PLAYER.__type = "Player"
:Nick = PLAYER

PLAYER.__tostring = =>
if IsValid( @ )
return "Player [" .. EntIndex( @ ) .. "][" .. Nick( @ ) .. "]"

return "[NULL Player]"

ENTITY.IsPlayer = =>
return getmetatable( @ ) == PLAYER
ENTITY.IsPlayer = =>
return getmetatable( @ ) == PLAYER

-- Vehicle
do

metatable = registry[ "Vehicle" ]
metatable.__type = "Vehicle"

ENTITY.IsVehicle = =>
return getmetatable( @ ) == metatable
Expand All @@ -388,7 +347,6 @@ do
do

metatable = registry[ "NPC" ]
metatable.__type = "NPC"

ENTITY.IsNPC = =>
return getmetatable( @ ) == metatable
Expand All @@ -397,23 +355,15 @@ do
do

metatable = registry[ "NextBot" ]
metatable.__type = "NextBot"

ENTITY.IsNextBot = =>
return getmetatable( @ ) == metatable

-- nil
registry[ "nil" ].__tostring = ->
return "nil"

-- number
do

metatable = registry[ "number" ]

metatable.__tostring = ( number ) ->
return "" .. number

global isnumber = =>
return getmetatable( @ ) == metatable

Expand All @@ -422,9 +372,6 @@ do

metatable = registry[ "string" ]

metatable.__tostring = ( str ) ->
return str

global isstring = =>
return getmetatable( @ ) == metatable

Expand All @@ -433,9 +380,6 @@ do

metatable = registry[ "boolean" ]

metatable.__tostring = ( boolean ) ->
return boolean and "true" or "false"

global isbool = =>
return getmetatable( @ ) == metatable

Expand All @@ -452,9 +396,6 @@ do

metatable = registry[ "Vector" ]

metatable.__tostring = ( vector ) ->
return format( "%f %f %f", vector[ 1 ], vector[ 2 ], vector[ 3 ] )

global isvector = =>
return getmetatable( @ ) == metatable

Expand All @@ -463,25 +404,13 @@ do

metatable = registry[ "Angle" ]

metatable.__tostring = ( angles ) ->
return format( "%f %f %f", angles[ 1 ], angles[ 2 ], angles[ 3 ] )

global isangle = =>
return getmetatable( @ ) == metatable

-- VMatrix
do

metatable = registry[ "VMatrix" ]
:GetField = metatable

metatable.__tostring = ( matrix ) ->
return format( "[%f, %f, %f, %f]\n[%f, %f, %f, %f]\n[%f, %f, %f, %f]\n[%f, %f, %f, %f]",
GetField( matrix, 1, 1 ), GetField( matrix, 1, 2 ), GetField( matrix, 1, 3 ), GetField( matrix, 1, 4 ),
GetField( matrix, 2, 1 ), GetField( matrix, 2, 2 ), GetField( matrix, 2, 3 ), GetField( matrix, 2, 4 ),
GetField( matrix, 3, 1 ), GetField( matrix, 3, 2 ), GetField( matrix, 3, 3 ), GetField( matrix, 3, 4 ),
GetField( matrix, 4, 1 ), GetField( matrix, 4, 2 ), GetField( matrix, 4, 3 ), GetField( matrix, 4, 4 )
)

global ismatrix = =>
return getmetatable( @ ) == metatable
Expand All @@ -491,13 +420,6 @@ do

metatable = registry[ "Panel" ]

:GetName, :GetClassName, :GetBounds = metatable
x, y, w, h = 0, 0, 0, 0

metatable.__tostring = ( pnl ) ->
x, y, w, h = GetBounds( pnl )
return "Panel: [name:" .. GetName( pnl ) .."][class:" .. GetClassName( pnl ) .. "][" .. x .. "," .. y .. "," .. w .. "," .. h .. "]"

global ispanel = =>
return getmetatable( @ ) == metatable

Expand All @@ -506,9 +428,6 @@ do

metatable = registry[ "Color" ]

metatable.__tostring = ( color ) ->
return color.r .. " " .. color.g .. " " .. color.b .. " " .. color.a

global IsColor = =>
return getmetatable( @ ) == metatable

Expand Down

0 comments on commit 2da3d67

Please sign in to comment.