This article's documentation is for anything that uses the Source engine. Click here for more information.

$keyvalues: Difference between revisions

From Valve Developer Community
Jump to navigation Jump to search
(I will eradicate unnecessary VDF quote marks from this website!)
No edit summary
 
(32 intermediate revisions by 13 users not shown)
Line 1: Line 1:
Embeds an arbitrary block of [[keyvalue]]s into the .mdl file. <code>[[prop_data]]</code> keyvalues are the most common, as they define various properties of [[prop_physics]] models, but there is no limit on what other KVs a mod's programmer might add support for.
{{LanguageBar}}
{{this is a|QC command|name=$keyvalues}} It embeds a block of arbitrary [[keyvalue]]s into the .mdl file.


{{warning|Since the values are arbitrary, [[studiomdl]] can't check that they're correct when it compiles them.}}
{{note|Since the values are arbitrary, [[studiomdl]] can't check that they are correct when it compiles the model.}}


== Examples ==
Programmers can access the $keyvalues block with <code>modelinfo->GetModelKeyValueText(GetModel())</code> and the <code>[[KeyValues]]</code> class.
 
== Syntax ==


  $keyvalues
  $keyvalues
  {
  {
  prop_data
    ''keyvalue data''
}
 
== Common KeyValues ==
 
See [[:Category:QC Keyvalues]] for a complete list.
 
;<code>[[prop_data]]</code>
:Defines various properties for models for use in Valve's prop_* entities - usually {{ent|prop_physics}}.
;<code>[[physgun_interactions]]</code>
:Defines any non-standard interactions with the [[Gravity Gun]].
;<code>[[Particles On Models|particles]]</code>
:Attaches [[:Category:Particle System|particles]].
; <code>[[prop_door_rotating#Custom Door Models|door_options]]</code>
: Configures the model for use with {{ent|prop_door_rotating}}.
;<code>vehicle_entry</code>
:Positions where the player will enter into a [[vehicle]], where the player's camera will blend into the vehicle's camera position ( eyes ). It is defined by [[attachments]] with a number to indicate the hitbox group, set previously on any hitbox within a [[$hboxset|hitbox set]] called "entryboxes".
;<code>vehicle_exit</code>
:Positions where the player will exit from a vehicle. Defined by the name of an attachment and if is intended to be used while the vehicle is upright ( "upright" ) or upside down ( "upsidedown" ).
;<code>vehicle_escape_exit</code>
:Positions where the player will exit from a vehicle in case there are problems ( underwater, upside down, other events... ). Same definitions as in vehicle_exit.
;<code>AddedAmbientScale <[[int]]></code>
:Softens the ambient lighting received by this model. Present in L4D2 infected.
 
== Example ==
 
$keyvalues
{
  [[prop_data]]
  {
  {
  base              Wooden.Small
  base              Wooden.Small
Line 14: Line 45:
  explosive_radius  100
  explosive_radius  100
  }
  }
}
  [[physgun_interactions]]
 
$keyvalues
{
  build_points
  {
  {
build_point_0
onfirstimpact break
{
  onfirstimpact paintsplat
valid_objects
  onlaunch spin_zaxis
{
  onbreak explode_fire
obj_manned_plasmagun 1
obj_resourcepump 1
obj_shieldwall 1
}
}
  build_point_1
  {
(...)
  }
  }
  }
''// hud_name has been made up as an example of a one-dimensional custom KV.
''// (If you were being picky, you might point out that it ought to be [[localised]] ...)''
hud_name "Rubber chicken with a pulley in the middle"
  }
  }


  $keyvalues
  $keyvalues
  {
  {
''// This is an example KV. It won't be recongised by any of Valve's games!''
  vehicle_entry
''// (If you were being picky, you might point out that this ought to be a [[localised]] string...)''
  {
hud_name "Rubber chicken with a pulley in the middle"
  "enter1" "1"
  "enter2" "2"
''// Of course, we can still include other KVs that ARE read.''
  "enter3" "3"
prop_data
  "enter4" "1"
{
  "enter5" "2"
(...)
  "enter6" "3"
}
  "enter7" "1"
  }
  vehicle_exit
  {
  "exit3" "upright"
  "exit4" "upright"
  "exit6" "upsidedown"
  }
  vehicle_escape_exit
  {
  "exit1" "upright"
  "exit2" "upright"
  "exit5" "upsidedown"
  "exit7" "upright"
  "exit8" "upsidedown"
  }
  }
  }
[[Category:QC Commands]]

Latest revision as of 21:24, 18 July 2025

English (en)中文 (zh)Translate (Translate)

$keyvalues is a QC command available in all Source Source games. It embeds a block of arbitrary keyvalues into the .mdl file.

Note.pngNote:Since the values are arbitrary, studiomdl can't check that they are correct when it compiles the model.

Programmers can access the $keyvalues block with modelinfo->GetModelKeyValueText(GetModel()) and the KeyValues class.

Syntax

$keyvalues
{
    keyvalue data
}

Common KeyValues

See Category:QC Keyvalues for a complete list.

prop_data
Defines various properties for models for use in Valve's prop_* entities - usually prop_physics.
physgun_interactions
Defines any non-standard interactions with the Gravity Gun.
particles
Attaches particles.
door_options
Configures the model for use with prop_door_rotating.
vehicle_entry
Positions where the player will enter into a vehicle, where the player's camera will blend into the vehicle's camera position ( eyes ). It is defined by attachments with a number to indicate the hitbox group, set previously on any hitbox within a hitbox set called "entryboxes".
vehicle_exit
Positions where the player will exit from a vehicle. Defined by the name of an attachment and if is intended to be used while the vehicle is upright ( "upright" ) or upside down ( "upsidedown" ).
vehicle_escape_exit
Positions where the player will exit from a vehicle in case there are problems ( underwater, upside down, other events... ). Same definitions as in vehicle_exit.
AddedAmbientScale <int>
Softens the ambient lighting received by this model. Present in L4D2 infected.

Example

$keyvalues
{
	prop_data
	{
		base              Wooden.Small
		dmg.bullets       0
		explosive_damage  100
		explosive_radius  100
	}
	physgun_interactions
	{
		onfirstimpact 	break
		onfirstimpact 	paintsplat
		onlaunch 	spin_zaxis
		onbreak 	explode_fire
	}

	// hud_name has been made up as an example of a one-dimensional custom KV.
	// (If you were being picky, you might point out that it ought to be localised ...)

	hud_name "Rubber chicken with a pulley in the middle"
}


$keyvalues
{
 vehicle_entry
 {
  "enter1" "1"
  "enter2" "2"
  "enter3" "3"
  "enter4" "1"
  "enter5" "2"
  "enter6" "3"
  "enter7" "1"
 }
 vehicle_exit
 {
  "exit3" "upright"
  "exit4" "upright"
  "exit6" "upsidedown"
 }
 vehicle_escape_exit
 {
  "exit1" "upright"
  "exit2" "upright"
  "exit5" "upsidedown"
  "exit7" "upright"
  "exit8" "upsidedown"
 }
}