Add a custom key/button
Quote from Fracture on May 14, 2017, 7:22 pmLONG 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
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
Quote from TeamSpen210 on May 15, 2017, 3:01 amYou 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).
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).
[spoiler]- BEE2 Addons | (BEE2)
- Hammer Addons
Maps:
- Crushed Gel
- Gel is Not Always Helpful[/spoiler]
Quote from FelixGriffin on May 15, 2017, 1:21 pmTeamSpen210 wrote:(for example naming a function InputEnable will make it be called whenever the entity receives an Enable input)Wait WHAT?!
Wait WHAT?!
Quote from Fracture on May 15, 2017, 5:00 pmokay 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
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
Quote from TeamSpen210 on May 16, 2017, 1:47 amFelixGriffin 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.
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.
[spoiler]- BEE2 Addons | (BEE2)
- Hammer Addons
Maps:
- Crushed Gel
- Gel is Not Always Helpful[/spoiler]
Quote from FelixGriffin on May 16, 2017, 8:32 pmThat is a very useful feature! Especially since the "Use" input is so universal.
That is a very useful feature! Especially since the "Use" input is so universal.
Quote from josepezdj on May 17, 2017, 9:56 amFracture 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 nothingUsually, 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!)
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...)
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!)
Quote from josepezdj on May 18, 2017, 7:52 amIf 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.
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.