EDIT: new problem, the quotes now crash hammer on loadup of the VMF
Add a custom key/button
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.
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.
Fracture wrote:
scripts can be pakratted, right?
Sure ![]()
how does one employ a script in hammer??
I have never made or used scripts before, fyi
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).
TeamSpen210 wrote:
(for example naming a function InputEnable will make it be called whenever the entity receives an Enable input)
Wait WHAT?!
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.
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!) ![]()