Get Keyvalue With Script

Avatar
FelixGriffin
2,680 Posts
Posted Jun 17, 2012
Sorry, but I have yet another esoteric mapping question: can I specify something within an entity, say, as a KeyValue, and then have a script be able to read it?
Advertisement
Registered users don’t see ads! Register now!
Avatar
ChickenMobile
2,460 Posts
Posted Jun 18, 2012
Replied 6 hours later
What exactly are you trying to do?

Passing values to a script can be as easy as putting a value inside a RunScriptCode or by naming a certain entity (using the EntityGroup[] values in a logic_script).

Avatar
FelixGriffin
2,680 Posts
Posted Jun 18, 2012
Replied 5 hours later
I'm using a modified Sendificator script to make cubes which react differently to portal shots and lasers, but if the cubes can have different radii, I need a way to get that radius. It would be known at compile-time, but I need to get it from a handle returned by Entities.FindInSphere(). I hope that makes sense.
Advertisement
Registered users don’t see ads! Register now!
Avatar
ChickenMobile
2,460 Posts
Posted Jun 18, 2012
Replied 4 hours later
So it is a user-defined value right, Not one which Hammer compiles in?

To make things simple I would just pre-define these values based on which cube it is. e.g. the cube named Cube1 can be referenced in the script within an 'if' or 'switch' statement which grabs the name of it and assigns in another value to your wanted radius.

if(foundEntity.GetName() == "cube1")
{
   local cubeRadius = 256
}
elseif(foundEntity.GetName() == "cube2")
{
        ...
)
...

switch (foundEntity.GetName()) {    case "cube1":       local cubeRadius = 256       break    case "cube2":       local cubeRadius = 1024       break    case ... }You can then either use this for your wanted function or you could save it for later (or continuous use).