Add a custom key/button

Avatar
Fracture
797 Posts
Posted Feb 27, 2015
Replied 9 hours later
aw i thought someone said that using quotes would break the game. that must have been somewhere else

EDIT: new problem, the quotes now crash hammer on loadup of the VMF

Advertisement
Registered users don't see ads! Register now!
Avatar
CamBen
973 Posts
Posted Feb 28, 2015
Replied 18 hours later
Oh I didn't know you were trying to implement those into hammer entities. Well, I don't know if there is a way to do It without the vmf crashing.
Avatar
FelixGriffin
2,680 Posts
Posted Feb 28, 2015
Replied 3 hours later
Edit the VMF in a text editor and remove those particular quote marks. Then Hammer should be able to work with it again.
Avatar
Fracture
797 Posts
Posted Feb 28, 2015
Replied 2 hours later
Looks like it would be easier to delete the command and save the vmf after saving and compiling the map into the bsp, and then re-input the command before compiling in the future
Avatar
Fracture
797 Posts
Posted Mar 23, 2015
Replied 23 days later
update: hammer suddenly decided that it is having none of that binding crap and is preventing me from compiling with the quotations
Avatar
TeamSpen210
608 Posts
Posted Mar 23, 2015
Replied 6 hours later
Here's a workaround to allow sending quoted commands - write them in a VScript which can have escaped quotes.
Just do something like this:

SendToConsole("bind g \"ent_fire @special_relay_g Trigger\"");
SendToConsole("bind b \"ent_fire @special_relay_b Trigger\"");

Save in scripts/vscripts, and in your map use RunScriptFile with the path to your script (from vscripts/) to run it when needed. You'll need to pack the script into your map.

Avatar
josepezdj
2,386 Posts
Posted Mar 24, 2015
Replied 7 hours later
Some time ago I discovered also a vscripting way of introducing quotes. It's a bit more convoluted than TeamSpen's but this is also useful to change certain keyvalues of an entity when you must use use quotes in the output:

commanduse <- @"""+use""";

function UseBinding()
{
   EntFire( "@clientcommand", "Command", "bind e " + commanduse, 0, 0 );
}

You'll need a point_clientcommand entity (named "@clientcommand")as well as a logic_script to execute this function.

Notice the space after the letter e in the part: "bind e " (that space is important to separate the letter e from the command "+use")

Fracture, I know you hate scripts, however this one is very simple, and an effective workaround to using quotes in Hammer.

Avatar
CamBen
973 Posts
Posted Mar 24, 2015
Replied 5 hours later
Is there any way to make this work on the portal 1 engine? Because I don't think they have vscripts in that game but I don't know.
Avatar
josepezdj
2,386 Posts
Posted Mar 24, 2015
Replied 50 minutes later
Well, I have never tried. However, even though the logic_script entity doesn't seem to exist in Portal, I guess you could try to pass functions through the entities themselves (via the "Entity Scripts" property). Like for example the point_clientcommand entity, give it a go
Avatar
Fracture
797 Posts
Posted Mar 24, 2015
Replied 3 hours later
scripts can be pakratted, right?
Avatar
josepezdj
2,386 Posts
Posted Mar 25, 2015
Replied 10 hours later

Fracture wrote:
scripts can be pakratted, right?

Sure

Avatar
Fracture
797 Posts
Posted May 14, 2017
Replied 2 years later
LONG TIME NO SEE, and late as hell to get back to this thread for obvious reasons.

how does one employ a script in hammer??

I have never made or used scripts before, fyi

Avatar
TeamSpen210
608 Posts
Posted May 15, 2017
Replied 7 hours later
You write one, and save in the scripts/vscripts/ folder. It's written in Squirrel (.nut files). To use them, set the Entity Scripts field on an entity to a script file - then that script file will be run on the entity during spawn, letting you set functions and variables on it. You can then use the RunScriptCode input to run functions at other times.

The script API gives you functions to do things such as find entities in the map by classname/targetname, fire outputs on them, get/set things like their location, angles, name, model, etc. Additionally creating functions with certain names will permit them to be called when certain events happen (for example naming a function InputEnable will make it be called whenever the entity receives an Enable input).

Avatar
FelixGriffin
2,680 Posts
Posted May 15, 2017
Replied 10 hours later

TeamSpen210 wrote:
(for example naming a function InputEnable will make it be called whenever the entity receives an Enable input)

Wait WHAT?!

Avatar
Fracture
797 Posts
Posted May 15, 2017
Replied 3 hours later
okay so wrote a script for the first time, and it seemed to work as intended, however when i pakratted it and uploaded it to the workshop and tried it there AFTER deleting the script from the folder, it did abssolutely nothing
Avatar
TeamSpen210
608 Posts
Posted May 16, 2017
Replied 8 hours later

FelixGriffin wrote:
TeamSpen210 wrote:

(for example naming a function InputEnable will make it be called whenever the entity receives an Enable input)

Wait WHAT?!

It does indeed, although I think it might need to be Inputenable() (kinda a bug). In addition, the vars 'activator' and 'caller' in the local script scope are set to the relevant entities while the function is executing. I think that also happens for CallScriptFunction, I can't remember. You can also return False to cancel the event before it gets to the entity. The Alien Swarm SDK has the code for part of VScript in it, so you can read the code behind this stuff.

Avatar
FelixGriffin
2,680 Posts
Posted May 16, 2017
Replied 18 hours later
That is a very useful feature! Especially since the "Use" input is so universal.
Avatar
josepezdj
2,386 Posts
Posted May 17, 2017
Replied 13 hours later

Fracture wrote:
okay so wrote a script for the first time, and it seemed to work as intended, however when i pakratted it and uploaded it to the workshop and tried it there AFTER deleting the script from the folder, it did abssolutely nothing

Usually, you need to edit the path for the script inside the BSP file to make it to work. Make sure that, after being packed, it is right inside the /scripts/vscripts folder (sometimes it's under a /dlc1 for example...)

TeamSpen210 wrote:
FelixGriffin wrote:

TeamSpen210 wrote:

(for example naming a function InputEnable will make it be called whenever the entity receives an Enable input)

Wait WHAT?!

It does indeed, although I think it might need to be Inputenable() (kinda a bug). In addition, the vars 'activator' and 'caller' in the local script scope are set to the relevant entities while the function is executing. I think that also happens for CallScriptFunction, I can't remember. You can also return False to cancel the event before it gets to the entity. The Alien Swarm SDK has the code for part of VScript in it, so you can read the code behind this stuff.

That is SO helpful indeed! (and truly weird!)

Avatar
Fracture
797 Posts
Posted May 17, 2017
Replied 4 hours later
still wondering why scripts wont pak over here
Advertisement
Registered users don't see ads! Register now!
Avatar
josepezdj
2,386 Posts
Posted May 18, 2017
Replied 17 hours later
If you want, send the packratted map to me via a pm, I'll check the paths and stuff and see if there's any problem.