Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Fixes, improvements, and new utility for vscript.
Fixed a critical bug in
CBaseEntity::ScriptContextThink
where the entity would stop thinking and/or skip think functions or even crash the game when some contexts were stopped while processing multiple and/or nested contexts.Moved ScriptContextThink to shared code; however on client it is only supported on C_World for now. Usage:
Moved player script registration on server before the player_spawn event to be able to access it on event.
Added engine game event descriptor accession on
CScriptGameEventListener::WriteEventData
. This allows much more efficient code. Also enabled even datas on client.Improved performance of coloured console printing in
CGMsg
by changing string comparisons to direct array access.Replicated convars prevent unique colouring for sv/cl messages of the same types. A useful distinct sv/cl colours would be vscript printing. For the moment this workaround can be used for it:
Placing this in
vscript_client.nut
will ensure these always run on client.Changed
v.tostring()
calls in internal scripts to"" + v
. Empty string concatentation implicitly converts the variable without the cost of an explicit function call. This is a micro optimisation, but there's not really any reason not to do it.Simple benchmark (10000000 iterations)
Printing a vector now prints the address. This allows tracking of vectors, and it is useful for debugging scripts. The syntax is from Source 2.
Vector
Add
,Subtract
,Multiply
,Divide
set the result to the vector itself instead of creating a new vector like the overloaded operators do.The unary minus operator can be used to negate the vector.
Vector::IsEqualTo
takes an optional tolerance parameter.Vector::Set
can take a vector to copy, or 3 floats.Vector::FromKVString
usage:FromKVString
can be used with convars and file and data saving as well:Added convar and concommand registration from script. Works both client and serverside.
Completion callback functions can be added to and removed from script concommands at any time.
No existing convars or concommands can be replaced except for a few allowed ones - I added the ability override movement keys. This may seem very similiar to
PlayerRunCommand
hook at first, but this allows complete control over the keys.It can even be used along with
PlayerRunCommand
, basically intercepting button masks in script. Example reverse move keys, and suppress +use 3 times:This example script features concommands, multiple context thinking at different frequencies, network communication, effects and dynamic lights. It can be ran on any map with
script_execute
https://gist.github.com/samisalreadytaken/dbb6d96ac97c5ef24a123b14f96fb84e