This forum is locked and will eventually go offline. If you have feedback to share you can find us in our Discord channel "MythoLogic Interactive" https://discord.gg/nECKnbT7gk

Forum rules

"Could not create sandbox" after script crash.

All technical topics that have been answered in one way or another can be found here.
Forum rules
By using the forum you agree to the following rules.
Locked
User avatar
TheOriginalCj
Moderator
Moderator
Posts: 177
Joined: Tue Mar 15, 2016 10:28 pm
Title: Lifetime Sentence to SF Wiki
SFD Alias: RedneckJed
Started SFD: PreAlpha 1.1.0
Location: USA
Gender:
Contact:

"Could not create sandbox" after script crash.

Post by TheOriginalCj » Wed Jun 22, 2016 3:06 am

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
1 x
Superfighters Wiki Founder
The Superfighters Wiki
Join the Wiki!
Danger Ross wrote: What are you doing here wiki-slave?! GET BACK TO WORK!

User avatar
Gurt
Lead Programmer
Lead Programmer
Posts: 1887
Joined: Sun Feb 28, 2016 3:22 pm
Title: Lead programmer
Started SFD: Made it!
Location: Sweden
Gender:
Age: 36

Post by Gurt » Wed Jun 22, 2016 10:42 am

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.
0 x
Gurt

User avatar
TheOriginalCj
Moderator
Moderator
Posts: 177
Joined: Tue Mar 15, 2016 10:28 pm
Title: Lifetime Sentence to SF Wiki
SFD Alias: RedneckJed
Started SFD: PreAlpha 1.1.0
Location: USA
Gender:
Contact:

Post by TheOriginalCj » Wed Jun 22, 2016 10:11 pm

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;
}
0 x
Superfighters Wiki Founder
The Superfighters Wiki
Join the Wiki!
Danger Ross wrote: What are you doing here wiki-slave?! GET BACK TO WORK!

User avatar
Gurt
Lead Programmer
Lead Programmer
Posts: 1887
Joined: Sun Feb 28, 2016 3:22 pm
Title: Lead programmer
Started SFD: Made it!
Location: Sweden
Gender:
Age: 36

Post by Gurt » Wed Jun 22, 2016 11:09 pm

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".
0 x
Gurt

User avatar
TheOriginalCj
Moderator
Moderator
Posts: 177
Joined: Tue Mar 15, 2016 10:28 pm
Title: Lifetime Sentence to SF Wiki
SFD Alias: RedneckJed
Started SFD: PreAlpha 1.1.0
Location: USA
Gender:
Contact:

Post by TheOriginalCj » Wed Jun 22, 2016 11:33 pm

Excellent. Fixed the problem. Learned something new today.
0 x
Superfighters Wiki Founder
The Superfighters Wiki
Join the Wiki!
Danger Ross wrote: What are you doing here wiki-slave?! GET BACK TO WORK!

Locked