Witam. Mam problemz fragmentem skryptu kosnoli, który po wpisaniu frazy zmienia pozycje playera. Jest tam przerobiona jednakże źle przezemnie składnia z C#. Nie wiem jak naprawić ten skrypt a strasznie jest mi potrzebny. Jest to rozwinięcie skryptu Avallacha. Pozdrawiam forum jako nowy użytkownik i proszę o pomoc ;)
class konsola extends MonoBehaviour
{
var display : GUIText;
var background : GUITexture;
var forward = "do przodu";
var postac;
var position: Vector3;
function Start () : void
{
transform.position = Vector3 (0.0, 1.0, 0.0);
transform.localScale = Vector3 (0.0, 0.0, 0.0);
display = gameObject.AddComponent(GUIText);
display.enabled = false;
background = gameObject.AddComponent(GUITexture);
background.texture = new Texture2D (1, 1);
background.color = Color (0.0, 0.0, 0.0, 0.3);
background.pixelInset = Rect (0, -20, 5000, 20);
background.enabled = false;
}
function Update () : void
{
if (display.enabled)
{
if (Input.inputString == "\b" && display.text.Length > 0)
{
display.text = display.text.Substring(0, display.text.Length - 1);
if (Input.inputString == "do przodu")
{
string() split = display.text.Split( new Char()[' '] ); // tniemy tam gdzie jest spacja
if( split[0] == "DoPrzodu" )
{
if( split.Length >= 2 )
{
var v = ToInt32( split[1] );
postac[0].transform.Translate( 0, 0, v );
}
}
}
}
else
display.text += Input.inputString;
if( Input.inputString == "\b" && display.text.Length > 0)
display.text = display.text.Substring(0, display.text.Length - 1);
else if( Input.inputString == "\n" || Input.inputString == "\r" )
{
if( display.text == "Fraza" )
transform.position = new Vector3( 10, 10, 10 );
display.text = String.Empty;
}
else
display.text += Input.inputString;
}
}
}