Game Development Community

Question aobut T2 scripts..

by Matthew Shapiro · in Torque Game Engine · 05/09/2001 (12:33 pm) · 12 replies

ARe scripts compiled or are they interpreted? In other words are the finished scripts that we put in our games a text file with the scripts or with code in it?

#1
05/09/2001 (1:40 pm)
Both and Either :)

The engine interprets the scripts and creates a compiled byte code file then executes the byte code. When you ship you can ship the text scripts, text + byte code or just byte code. It is up to you.

--Rick
#2
05/10/2001 (8:10 am)
I take it that it compiles to its own code format (not windows code or anything), right?
#3
05/10/2001 (8:16 am)
Yeah, byte code not native assembly code.
--Rick
#4
05/11/2001 (7:41 am)
So it still interprets it, just doesn't have to with the text(taking extra time), right?
#5
05/11/2001 (8:20 am)
That's indeed what it means. Byte-codes means no parsing/lexing.
#6
05/12/2001 (6:37 am)
So that leaves me wondering how much processing is being used on just script reading.... Enough to make a difference in the speed of your game?
#7
05/14/2001 (1:28 pm)
The scripts just handle the light weight logic not any heavy duty processing like path finding or line of sight, all that stuff is in C/C++ code. So the scripts really don't show up on code profiles.

--Rick
#8
05/14/2001 (1:54 pm)
Is it easy to create a function inside C++ to use from the scripts?
#9
05/14/2001 (2:12 pm)
VERY EASY

ConsoleFunction(strchr,const char *,3,3,"strchr(string,char)")
{
   argc;
   const char *ret = dStrchr(argv[1], argv[2][0]);
   return ret ? ret : "";
}

--Rick
#10
05/14/2001 (6:01 pm)
Hmm..

That's one thing I forgot to ask..

Can we use the package system to "override" built-in (aka hard-coded) functions?
#11
05/14/2001 (7:08 pm)
I will have to research that and get back to you. The package stuff was added after I left Dynamix and I have not had a chance to go over the code yet.

--Rick
#12
05/15/2001 (8:51 am)
Harold, the answer is yes.

For example, I wrote a little script to override the exec function, so that I don't have to keep typing in the scripts/ stuff everytime I want to execute a script in my base/scripts directory.

Josh