Page 1 of 1

"Could not create sandbox" after script crash.

Posted: Wed Jun 22, 2016 3:06 am
by TheOriginalCj
So I decided to make a script that couldn't (and probably shouldn't) have run. Crashed the game, sort of as expected. But now I can't run any scripts i trigger, as in doing so would prompt the following error:

http://i.imgur.com/eYSuVWg.png

Re: "Could not create sandbox" after script crash.

Posted: Wed Jun 22, 2016 10:42 am
by Gurt
It's hard to know exactly why this happens without seeing the code but it could be that you're trying to utilize some .NET functionality that's not available in SFD (but still not a security exception). You could also try to restart SFD or restart the computer if you don't think the code is the problem.

Re: "Could not create sandbox" after script crash.

Posted: Wed Jun 22, 2016 10:11 pm
by TheOriginalCj
The code I'm using right now is something I use almost all the time, and it did work prior to this problem. After a different script I ran crashed the game, the function did not work. In fact, none of the functions I'm using are working in any map.

After restarting both SFD and my PC, I might have to reinstall SFD, since the problem has not been fixed.

Added in 5 hours 10 minutes 28 seconds:
Oh god, this is probably the update itself. When I rewrite part of the code I wanted to implement, it works again, but when I rewrite it in full, it gives me the same glitch. If this is because of the update, is it possible to look into this as soon as possible?

I'll post the code here to show you I'm doing nothing too extreme

Code: Select all

IObjectTrigger Tick = (IObjectTrigger) Game.GetSingleObjectByCustomId("SmallTick");
IPlayer target;

public void Spark(TriggerArgs args)
{
IObject sparkie = (IObject) args.Caller;
Vector2 pos = sparkie.GetWorldPosition();

Game.PlayEffect("Electric", pos);
}

public void SwitchPosition(TriggerArgs args)
{
IObject spark = Game.GetSingleObjectByCustomId("Sparkie");
IObject Positioner = Game.GetSingleObjectByCustomId("THING");

Random numb = new Random();
float Ox = numb.Next(-64,64);
float Oy = numb.Next(-92,92);

//You'll want to keep this the same.
float PosX = Positioner.GetWorldPosition().X;
float PosY = Positioner.GetWorldPosition().Y;
Vector2 Reposition = new Vector2((PosX + Ox), (PosY+ Oy));

//This does the repositioning.
spark.SetWorldPosition(Reposition);
}

public void InitalizeRemove(TriggerArgs args)
{
IPlayer ply = (IPlayer) args.Sender;
IObject[] ladda = Game.GetObjectsByCustomId("N");
IObject guy = (IObject) args.Sender;
Vector2 vel = new Vector2(0f,15f);

if (ply.IsClimbing == true)
{
//deal some dmg
if (ply.GetHealth() < 3)
ply.Kill();
else
ply.SetHealth(ply.GetHealth()-3);

ply.SetInputEnabled(false);
SendPlayer(ply);
Tick.Trigger();
guy.SetLinearVelocity(vel);

}
//random space!!!
}

public void Reenable(TriggerArgs args)
{
target.SetInputEnabled(true);
}

private void SendPlayer(IPlayer pltag)
{
target = pltag;
}

Re: "Could not create sandbox" after script crash.

Posted: Wed Jun 22, 2016 11:09 pm
by Gurt
While your very first line of code comiles:
IObjectTrigger Tick = (IObjectTrigger) Game.GetSingleObjectByCustomId("SmallTick");
you cannot access the Game instance during the ctor (constructor) of the script. You can only access the Game object inside functions. Now you will get a null-reference-exceptions during the creation of the sandbox which the script runs in.
I will clarify that in the documentations and provide another error message than "Sandbox failed".

Re: "Could not create sandbox" after script crash.

Posted: Wed Jun 22, 2016 11:33 pm
by TheOriginalCj
Excellent. Fixed the problem. Learned something new today.