util/GetModelInfo

From Garry's Mod
(Difference between revisions)
Jump to: navigation, search
(example)
(The limit is not new)
 
Line 26: Line 26:
 
|desc=The model info as a table with the following keys:
 
|desc=The model info as a table with the following keys:
 
*{{FuncArg|number|SkinCount|Identical to {{ClassFunction|Entity|SkinCount}}.}}
 
*{{FuncArg|number|SkinCount|Identical to {{ClassFunction|Entity|SkinCount}}.}}
*{{FuncArg|string|KeyValues|Valve key-value formatted info about the model ( Constraint Info, etc )}}
+
*{{FuncArg|string|KeyValues|Valve key-value formatted info about the model's physics (Constraint Info, etc). This is limited to 4096 characters.}}
 +
*{{FuncArg|string|ModelKeyValues|Valve key-value formatted info about the model ($keyvalues command in the .qc of the model), if present}}
 +
 
 +
{{NextUpdate|New ModelKeyValues field}}
 
}}
 
}}
 
{{Example
 
{{Example
 
|Description=Example usage of the function. We use {{LibraryFunction|util|KeyValuesToTablePreserveOrder}} in order to preserve multiple keys with the same name.
 
|Description=Example usage of the function. We use {{LibraryFunction|util|KeyValuesToTablePreserveOrder}} in order to preserve multiple keys with the same name.
 
|Code=local ModelInfo = util.GetModelInfo("models/combine_gate_vehicle.mdl" )
 
|Code=local ModelInfo = util.GetModelInfo("models/combine_gate_vehicle.mdl" )
print( ModelInfo.SkinCount ) // 1
+
print( ModelInfo.SkinCount ) // The skin count
PrintTable( util.KeyValuesToTablePreserveOrder( ModelInfo.KeyValues ) ) // A
+
PrintTable( util.KeyValuesToTablePreserveOrder( ModelInfo.KeyValues ) ) // Physics data
 
|OutputFixedWidth=Fixed width
 
|OutputFixedWidth=Fixed width
 
|Output=1:
 
|Output=1:
Line 73: Line 76:
 
Key = totalmass
 
Key = totalmass
 
Value = 1
 
Value = 1
 
 
}}
 
}}

Latest revision as of 12:51, 9 July 2019

 util.GetModelInfo( )

Contents

Description

Returns a table containing the info about the model. It seems to be not working serverside, but still exists serverside.

NOTE

This function will silently fail if used on models with following strings in them:

  • _shared
  • _anims
  • _gestures
  • _anim
  • _postures
  • _gst
  • _pst
  • _shd
  • _ss
  • _anm
  • _include

Arguments

string mdl

Model path

Returns

table

The model info as a table with the following keys:

  • number SkinCount - Identical to Entity:SkinCount.
  • string KeyValues - Valve key-value formatted info about the model's physics (Constraint Info, etc). This is limited to 4096 characters.
  • string ModelKeyValues - Valve key-value formatted info about the model ($keyvalues command in the .qc of the model), if present


Next Update Change

New ModelKeyValues field

Examples

Example

Example usage of the function. We use util.KeyValuesToTablePreserveOrder in order to preserve multiple keys with the same name.

local ModelInfo = util.GetModelInfo("models/combine_gate_vehicle.mdl" )
print( ModelInfo.SkinCount ) // The skin count
PrintTable( util.KeyValuesToTablePreserveOrder( ModelInfo.KeyValues ) ) // Physics data

Output:

1:
		Key	=	solid
		Value:
				1:
						Key	=	index
						Value	=	0
				2:
						Key	=	name
						Value	=	Vehicle_Gate.Gate2_L
				3:
						Key	=	mass
						Value	=	1
				4:
						Key	=	surfaceprop
						Value	=	metal
				5:
						Key	=	damping
						Value	=	0
				6:
						Key	=	rotdamping
						Value	=	0
				7:
						Key	=	inertia
						Value	=	1
				8:
						Key	=	volume
						Value	=	68522.9296875

.......

6:
		Key	=	editparams
		Value:
				1:
						Key	=	rootname
						Value	=	
				2:
						Key	=	totalmass
						Value	=	1
Personal tools
Navigation