- Home /
My script seems fine, yet I keep getting BCE0044: expecting }, found ''.
Hi all,
I currently have a script which is mainly composed of classes, with a function in the same file. It seems that everything is normal with my script, that I have included all of the ;, }, etc. in the right places. And yet, although my syntax and all seems in order, I keep getting this error:
Assets/GeneralClasses.js(191,1): BCE0044: expecting }, found ''.
And this is my script:
#pragma strict
/*function ColorAlgorithim() : Color32
{
var newColor = Color32(Random.Range(0,255),Random.Range(0,255),Random.Range(0,255),255);
var notBalanced : boolean = false;
while(notBalanced == false)
{
if(newColor.g > (newColor.r * 2))
{
newColor.g = Random.Range(0,255);
notBalanced = false;
}
else if((newColor.b == newColor.r) || (newColor.b*2 > newColor.r))
{
newColor.b = Random.Range(0,255);
newColor.r = Random.Range(0,255);
notBalanced = false;
}
else
{
notBalanced = true;
}
}
return(newColor);
}
*/
function StellarClassPicker() : String
{
var randomNumber : float = Random.Range(0,1);
if(randomNumber <= 0.0000003)
{
return("O");
}
else if(randomNumber <= 0.0013)
{
return("B");
}
else if(randomNumber <= 0.006)
{
return("A");
}
else if(randomNumber <= 0.03)
{
return("F");
}
else if(randomNumber <= 0.076)
{
return("G");
}
else if(randomNumber <= 0.121)
{
return("K");
}
else if(randomNumber <= 0.7645)
{
return("M");
}
}
public class Person
{
public var name : String;
public function Person(nme : String)
{
this.name = nme;
}
}
public class Group
{
public var name : String;
public var size : int;
public function Group(nameGroup : Array)
{
this.name = nameGroup[Mathf.Ceil(Random.Range(0,nameGroup.length))];
this.size = Mathf.Ceil(Random.Range(50,500));
}
}
public class Planet
{
public var name : String;
public var size : int;
public var distanceFromStar : int;
public var orbitalSpeed : float;
public function Planet(namePlanets : Array)
{
this.name = namePlanets[Mathf.Ceil(Random.Range(0,namePlanets.length))];
this.size = Mathf.Ceil(Random.Range(1,7));
this.distanceFromStar = Mathf.Ceil(Random.Range(10,200));
this.orbitalSpeed = Mathf.Ceil(Random.Range(5,20));
}
}
public class Star
{
public var stellarClass : String; //each class gets a letter under Harvard Classification system
public var mass : float;
public var size : float;
public var luminosity : int;
public var color : Color;
public function Star()
{
this.stellarClass = StellarClassPicker();
switch(this.stellarClass)
{
case "O":
this.mass = Random.Range(16,100);
this.size = Random.Range(6.6,70);
this.luminosity = Random.Range(7,8);
this.color = Color32(154,175,254,255);
break;
case "B":
this.mass = Random.Range(2.1,16);
this.size = Random.Range(1.8,6.6);
this.luminosity = 7;
this.color = Color32(186,203,254,255);
break;
case "A":
this.mass = Random.Range(1.4,2.1);
this.size = Random.Range(1.4,1.8);
this.luminosity = 6;
this.color = Color32(250,247,254,255);
break;
case "F":
this.mass = Random.Range(1.04,1.4);
this.size = Random.Range(1.15,1.4);
this.luminosity = 5;
this.color = Color32(254,254,236,255);
break;
case "G":
this.mass = Random.Range(0.8,1.04);
this.size = Random.Range(0.96,1.15);
this.luminosity = 4;
this.color = Color32(254,254,0,255);
break;
case "K":
this.mass = Random.Range(0.45,0.8);
this.size = Random.Range(0.7,0.96);
this.luminosity = 3;
this.color = Color32(254,151,51,255);
break;
case "M":
this.mass = Random.Range(0.08,0.45);
this.size = Random.Range(0,0.7);
this.luminosity = 2;
this.color = Color32(254,0,0,255);
break;
}
}
public class StarSystem
{
public var name : String;
public var numPlanets : int;
public var planets : Planet[];
public var star : Star;
public var location : Vector3;
public var group : Group;
//public var tradesWith : Array;
public var physicalObject : GameObject;
public function StarSystem(nameSystems : Array,namePlanets : Array,sizeMap : int)
{
this.name = nameSystems[Mathf.Ceil(Random.Range(0,nameSystems.length))];
this.numPlanets = Mathf.Ceil(Random.Range(1,7));
this.planets = new Planet[numPlanets];
for(var i : int = 0; i<numPlanets;i++)
{
var newPlanet = new Planet(namePlanets);
planets[i]=(newPlanet);
}
this.star = new Star();
this.location = Vector3(Random.Range(-sizeMap,sizeMap),Random.Range(-sizeMap,sizeMap),Random.Range(-sizeMap,sizeMap));
this.group = null;
//this.tradesWith = [null];
this.physicalObject = null;
}
}
Does anyone know what the issue is? Thanks!
Answer by gjf · Jun 21, 2014 at 04:11 PM
public function Star()
is missing a }
- add it to line 160
also, unless StellarClass
needs to use letters, you could assign an index into an array then the code for setting mass
, size
, etc. can be much simpler...
Thank you very much! $$anonymous$$y code is working now, and I will most likely use your advice. Again, thank you.
Your answer
![](https://koobas.hobune.stream/wayback/20220613152205im_/https://answers.unity.com/themes/thub/images/avi.jpg)