1. 변수
%local_var = value1;
-> 지역변수
$globl_var = value2;
-> 전역변수
-> 모든 클라이언트들이 공유하지는 않는다
2. 배열
$MyArray[N] (one-dimensional array)
$MyMultiArray[N,N] (multidimensional array)
$MyMultiArrayM_N (multidimensional array)
- 토크엔진에서 모든 변수는 문자열로 해석된다
- 또한 해석이 진행되는 동안 꺽쇠괄호( [, ] ) 는 제거되고 콤마( , )는 underbar( _ ) 로 변환된다
$TestVarEDO = 10;
$substring = EDO;
echo ($substring); // prints EDO
echo ($TestVar[$substring]); // prints 10
-> square brackets(꺾쇠괄호 []) are removed
- $a 와 $a[0] 는 다른 변수이다
- $MyArray0 와 $MyArray[0] 는 같다 // 꺽쇠괄호( [, ] ) 가 제거되므로..
3. 벡터
- 토크스크립트는 포인터나 레퍼런스를 지원하지 않는다
ex)
$srcRay = "1.0 0.0 1.0";
$destRay = "1.0 6.0";
echo ( VectorAdd($srcRay, $destRay) );
4. 연산자
- 토크스크립트 대부분의 문법은 C와 비슷하다고 보면된다
- 연산자도 마찬가지로 일반적인 프로그래밍 언어에서 사용하는 것들과 별반 차이가 없으나..
- 몇가지 주의할 점은 후위연산자는 동작하지 않는다는 것..
ex)
$a = 15;
echo ($a++); // Prints 16
- 그리고 문자열을 비교할 때는 == , != 대신 $=, !$= 을 사용한다
$= (string equal to operator)
!$= (string not equal to operator)
5. 문자열 연산자(String Operators)
- @ : 두 문자열을 연결(concatenates two strings)
- TAB : 탭 (concatenation with tab)
- SPC : 공백 (concatenation with space)
- NL : 개행 (newline)
ex)
echo ("Hi" @ "there.");
echo ("Hi" TAB "there."); // Note : TAB prints as ^ in console
echo ("Hi" SPC "there.");
echo ("Hi" NL "there.");
6. 제어문(Control Statements)
- 일반적인 문법을 따른다
if ( expression ) {
statements;
} else {
alternate statements;
}
switch(expression) {
case value0:
statements;
break;
case value1:
statements;
break;
...
case valueN:
statements;
break;
default:
statements;
}
for ( expression0; expression1; expression2 ) {
statement(s);
}
while ( expression) {
statement(s);
}
7. 함수
- 기본적으로 토크스크립트에서 함수는 아래와 같이 정의한다.
function func_name ( [args0], ..., [argn] ) {
statements;
[return val;]
}
8. 참고사이트
http://www.garagegames.com
http://tdn.garagegames.com
%local_var = value1;
-> 지역변수
$globl_var = value2;
-> 전역변수
-> 모든 클라이언트들이 공유하지는 않는다
2. 배열
$MyArray[N] (one-dimensional array)
$MyMultiArray[N,N] (multidimensional array)
$MyMultiArrayM_N (multidimensional array)
- 토크엔진에서 모든 변수는 문자열로 해석된다
- 또한 해석이 진행되는 동안 꺽쇠괄호( [, ] ) 는 제거되고 콤마( , )는 underbar( _ ) 로 변환된다
$TestVarEDO = 10;
$substring = EDO;
echo ($substring); // prints EDO
echo ($TestVar[$substring]); // prints 10
-> square brackets(꺾쇠괄호 []) are removed
- $a 와 $a[0] 는 다른 변수이다
- $MyArray0 와 $MyArray[0] 는 같다 // 꺽쇠괄호( [, ] ) 가 제거되므로..
3. 벡터
- 토크스크립트는 포인터나 레퍼런스를 지원하지 않는다
ex)
$srcRay = "1.0 0.0 1.0";
$destRay = "1.0 6.0";
echo ( VectorAdd($srcRay, $destRay) );
4. 연산자
- 토크스크립트 대부분의 문법은 C와 비슷하다고 보면된다
- 연산자도 마찬가지로 일반적인 프로그래밍 언어에서 사용하는 것들과 별반 차이가 없으나..
- 몇가지 주의할 점은 후위연산자는 동작하지 않는다는 것..
ex)
$a = 15;
echo ($a++); // Prints 16
- 그리고 문자열을 비교할 때는 == , != 대신 $=, !$= 을 사용한다
$= (string equal to operator)
!$= (string not equal to operator)
5. 문자열 연산자(String Operators)
- @ : 두 문자열을 연결(concatenates two strings)
- TAB : 탭 (concatenation with tab)
- SPC : 공백 (concatenation with space)
- NL : 개행 (newline)
ex)
echo ("Hi" @ "there.");
echo ("Hi" TAB "there."); // Note : TAB prints as ^ in console
echo ("Hi" SPC "there.");
echo ("Hi" NL "there.");
6. 제어문(Control Statements)
- 일반적인 문법을 따른다
if ( expression ) {
statements;
} else {
alternate statements;
}
switch(expression) {
case value0:
statements;
break;
case value1:
statements;
break;
...
case valueN:
statements;
break;
default:
statements;
}
for ( expression0; expression1; expression2 ) {
statement(s);
}
while ( expression) {
statement(s);
}
7. 함수
- 기본적으로 토크스크립트에서 함수는 아래와 같이 정의한다.
function func_name ( [args0], ..., [argn] ) {
statements;
[return val;]
}
8. 참고사이트
http://www.garagegames.com
http://tdn.garagegames.com