samisalreadytaken / vs_library Goto Github PK
View Code? Open in Web Editor NEWvscript library
License: MIT License
vscript library
License: MIT License
Entities.CreateByClassname()
does not work properly when trying to spawn prop entities. In these cases CreateProp()
should be used instead. Since VS.CreateEntity()
always calls the former, it is not usable when trying to spawn a prop.
I suggest creating a method (VS.CreateProp()
?) for this matter, and possible throwing an exception when VS.CreateEntity()
is called with a prop classname.
On the other hand, the same function could handle both cases. However, it must be noted that CreateProp()
's signature forces a model and an animation to be passed.
Trying to run the following code:
IncludeScript("vs_library");
VS.ListenToGameEvent( "bullet_impact", function( event )
{
local player = VS.GetPlayerByUserid( event );
printl(player)
local scope = player.GetScriptScope();
printl( scope.userid );
printl( scope.networkid );
printl( scope.name );
}, "test" );
But I get the following error in the console:
(null : 0x00000000)
AN ERROR HAS OCCURED [the index 'GetScriptScope' does not exist]
CALLSTACK
*FUNCTION [unknown()] myscript.nut line [8]
LOCALS
[player] NULL
[event] TABLE
[this] TABLE
I assume the Null response from printl(player) is part of the problem, but I cant figure out where I've gone wrong.
Did everything according to the guide and video, created a logic_eventlistener and point_template, well, it gives errors to the console
AN ERROR HAS OCCURED [the index 'ROOT' does not exist]
CALLSTACK
*FUNCTION [main()] vs_events.nut line [27]
*FUNCTION [DoIncludeScript()] NATIVE line [-1]
*FUNCTION [IncludeScript()] unnamed line [83]
*FUNCTION [main()] vs_eventlistener.nut line [1]
LOCALS
[Events] TABLE
[this] TABLE
[scope] TABLE
[name] "vs_events"
[this] TABLE
[this] TABLE
Error running script named vs_events
AN ERROR HAS OCCURED [Failed to include script "vs_events"]
CALLSTACK
*FUNCTION [IncludeScript()] unnamed line [83]
*FUNCTION [main()] vs_eventlistener.nut line [1]
LOCALS
[scope] TABLE
[name] "vs_events"
[this] TABLE
[this] TABLE
Error running script named vs_eventlistener.nut
AN ERROR HAS OCCURED [the index 'userid' does not exist]
CALLSTACK
*FUNCTION [main()] myscript.nut line [3]
LOCALS
[this] TABLE
Error running script named myscript.nut
Hello, I just created this discussion #7
I have a very important questions that I wanna find out, and I don't know if anyone checks discussions. So I created Issue for it.
I want to change this library a bit under portal 2 so that save/load doesn't update all existing objects, but I can't figure out how I can compile (compress) the src folder into a vs_library.nut file. How can this be done?
if ( !("eventlistener" in getroottable()) || !( getroottable()["eventlistener"].IsValid()) )
{
::eventlistener <- Entities.CreateByClassname("logic_eventlistener");
::eventlistener.__KeyValueFromString("targetname","vs.eventlistener");
}
if ( !("pointtemplate" in getroottable()) || !( getroottable()["pointtemplate"].IsValid()) )
{
::pointtemplate <- Entities.CreateByClassname("point_template");
::pointtemplate.__KeyValueFromString("vscripts","vs_events.nut");
::pointtemplate.__KeyValueFromString("Template01","vs.eventlistener");
}
IncludeScript("vs_events");
This seems to be caused when any one of the following consecutivley added events are called:
// Three attacks and one to return to idle
VS.EventQueue.AddEvent( Phase2Attack, 0.0, [this, 3] );
VS.EventQueue.AddEvent( Phase2Attack, 3.1, [this, 3] );
VS.EventQueue.AddEvent( Phase2Attack, 6.2, [this, 3] );
VS.EventQueue.AddEvent(ChangeStateToIdle, 9.3);
Occasionally, the entire event system will fail with the error that the index of 0 does not exist at line 6 of vs_library.nut
This seems to happen when the event is called, not when it is added, and it does not seem to happen consistently on any hardware.
Hello, there is a problem what I'm wondering.
It is hard to describe, so that I will use example to describe it.
For example, in an instance, counting:
When the counter reaches a limit, then stops counting, and release the counter handle, from the memory.
I've found the whole library, but didn't found how to do it...
In other languages, for example, sourcepawn, can be done like this, what is shown below:
int counter = 0;
Handle hTimer = null;
public void OnPluginStart()
{
delete hTimer;
hTimer = CreateTimer(1.0, Func, _, TIMER_REPEAT | TIMER_FLAG_NO_MAPCHANGE);
}
public Action Func(Handle myself)
{
counter++
if (counter >= 5)
{
counter = 0;
hTimer = null;
return Plugin_Stop; // Here to stop the timer
}
return Plugin_Continue;
}
Is there any method/tutorial to reach this problem in VScript? thx
I wasn't sure if this was a library bug or a coding mistake so I am posting it here.
The problem is when I execute StartTimer function. Console just prints vector : (0.000000, 0.000000, 0.000000)
IncludeScript("vs_library")
function StartTimer() {
VS.Timer(false, 0.5 , Think)
}
function Think()
{
HPlayer <- VS.GetLocalPlayer()
HPlayerEye <- VS.CreateMeasure(HPlayer.GetName())
printl(HPlayerEye.GetAngles())
}
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.