Ok the JS version of this script works, while the Boo version does not. I get an error in Unity.
JS:
var P;
function Start(){
P=new Stats();
}
function OnGUI(){
if(P.HP<0) P.HP=0;
if(P.Player){
GUI.Label(new Rect(10,10,30,20),"Health: "+Mathf.Round(P.HP)+"%");
}
}
//Boo Version below
import UnityEngine
import System.Collections
class Creation(MonoBehaviour):
P
def Start ():
P=Stats()
def OnGUI():
if(P.HP<0): P.HP=0
if(P.Player):
GUI.Label(Rect(10,10,30,20),"Health: ${Mathf.Round(P.HP)}%")
Here are all the errors for the Boo version:
Assets/Code/Boo Creation.boo(6,11): BCE0005: Unknown identifier: ‘Stats’.
Assets/Code/Boo Creation.boo(8,14): BCE0019: ‘HP’ is not a member of ‘object’.
Assets/Code/Boo Creation.boo(9,14): BCE0019: ‘Player’ is not a member of ‘object’.
Can someone show me the correct translation so I’ll know for future reference?
Stats() refers to Stats.js, a javascript file, is that a problem? Can boo not access variables/classes from it?
Ok I think I get it…So if I want to make it easier on myself, I should use one language for the entire game…So I don’t have to worry about doing what that article says…
True, you should have little problems putting the scripts in the right place. In general though, if it’s not back-breaking, you are better off having your scripts in one language (both for bi-directional communication between them and for your own sanity).