Vscript reading keyvalues
Quote from innocentive on December 18, 2012, 6:44 amExpanding on my previous post, I've tried to use the CScriptKeyValues commands posted on VDC. This is the simple code I used:
kv <- self.GetModelKeyValues()
printl(kv)
printl(kv.GetKeyString("targetname"))I've applied this to a simple button which assumingly has a targetname (at least I assigned one!). Anyhow, this code properly returns the address of the kv handle but after that just an empty line. None of the other KeyValue commands produces any significant output but null either.
Where is my mistake? What am I overlooking? Anybody please...
Expanding on my previous post, I've tried to use the CScriptKeyValues commands posted on VDC. This is the simple code I used:
kv <- self.GetModelKeyValues()
printl(kv)
printl(kv.GetKeyString("targetname"))
I've applied this to a simple button which assumingly has a targetname (at least I assigned one!). Anyhow, this code properly returns the address of the kv handle but after that just an empty line. None of the other KeyValue commands produces any significant output but null either.
Where is my mistake? What am I overlooking? Anybody please...
Quote from FelixGriffin on December 18, 2012, 4:32 pmThat gets model KeyValues, which hold no information about targetname or such.
Make a trigger, have it RunScriptCode on the !activator to stick its GetName() in a ::variable.
That gets model KeyValues, which hold no information about targetname or such.
Make a trigger, have it RunScriptCode on the !activator to stick its GetName() in a ::variable.
Quote from innocentive on December 18, 2012, 4:48 pmIn know that there's an easier way to acces the targetname of an entity ... I am just curious what information the model KeyValues hold. And it seems I can't access any info in that handle. Why? And what are the CScriptKeyValue commands for? They work exactly like XML readers and the KeyValues are structured like an XML file.
Maybe I'm mistaken but I thought that the KeyValues of an Entity hold all the information that you can edit in Hammer plus further key data that every entity holds. At least that's how I understand the articles on VDC.
In know that there's an easier way to acces the targetname of an entity ... I am just curious what information the model KeyValues hold. And it seems I can't access any info in that handle. Why? And what are the CScriptKeyValue commands for? They work exactly like XML readers and the KeyValues are structured like an XML file.
Maybe I'm mistaken but I thought that the KeyValues of an Entity hold all the information that you can edit in Hammer plus further key data that every entity holds. At least that's how I understand the articles on VDC.
Quote from FelixGriffin on December 18, 2012, 6:20 pmNo, afaik they hold the MODEL KeyValues: data about the model the entity is using. Things like its mass, its friction, its flammability, et cetera.
Targetname is an ENTITY KeyValue. It's like you're using the XML reader correctly, but you're opening the wrong file.
I've never used model KVs much, so someone correct me if this is all wrong.
No, afaik they hold the MODEL KeyValues: data about the model the entity is using. Things like its mass, its friction, its flammability, et cetera.
Targetname is an ENTITY KeyValue. It's like you're using the XML reader correctly, but you're opening the wrong file. ![]()
I've never used model KVs much, so someone correct me if this is all wrong.
