Help with understanding TorqueScript vs C
by Ian (Fluxtah) Warwick · in Torque Game Engine Advanced · 05/03/2007 (11:35 am) · 4 replies
Hi, me again :)
Since I am new to this, I am finding it a challenge to learn how Torque is structured, and how it works.
I am busy reading the docs which I am finding very informative, but I still do not feel comfortable to implement anything I have in mind for my first game. I am the kind of guy that needs to read things 2-3 times before it clicks.
I was wondering if someone could help by answering if I would need to write C++, TorqueScript or both for the three features I list, this would really help me understand the limits of scripting (if there are any), And I would be forever in your debt. What I do not want to do is start coding in C++ if its possible to do everything I want in script.
here goes :)
- A mech, where the upper body can be moved independently of moving direction (ie:- walk forward whilst shooting sideways)
- An entity that can be destroyed that also transmits health to nearby players.
- A flying AI supply vehicle that can deliver supplies to requesting players.
I understand I might be able to answer these myself if I had more knowledge of TGEA, I guess I am just eager to know so I can focus my learning in the correct areas to manage my time more efficiently.
cheers!
Ian
Since I am new to this, I am finding it a challenge to learn how Torque is structured, and how it works.
I am busy reading the docs which I am finding very informative, but I still do not feel comfortable to implement anything I have in mind for my first game. I am the kind of guy that needs to read things 2-3 times before it clicks.
I was wondering if someone could help by answering if I would need to write C++, TorqueScript or both for the three features I list, this would really help me understand the limits of scripting (if there are any), And I would be forever in your debt. What I do not want to do is start coding in C++ if its possible to do everything I want in script.
here goes :)
- A mech, where the upper body can be moved independently of moving direction (ie:- walk forward whilst shooting sideways)
- An entity that can be destroyed that also transmits health to nearby players.
- A flying AI supply vehicle that can deliver supplies to requesting players.
I understand I might be able to answer these myself if I had more knowledge of TGEA, I guess I am just eager to know so I can focus my learning in the correct areas to manage my time more efficiently.
cheers!
Ian
#2
If you compare TorqueScript to the driver, and c++ to the vehicle, we can break down how things work relatively logically:
The vehicle is an implementation of a class that the scripter (driver) has an understanding about how to operate, but no understanding of the underlying implementation of things like the ignition sequence for the internal combustion engine, the electrical system that provides gauge readouts, or the process accomplished when the gas is pressed--he just knows that when he turns the key, the engine does "stuff", and finally starts.
The key here is that you need to identify what aspects of your design are "how things happen", and what aspect is "when things happen", and how to correctly implement those points of view. Using your examples:
--"A mech, where the upper body" : You are describing a user input tied to activating a behavior of the object. The behavior of modifying the model itself (rotating the upper chassis, conforming the animations and node positions of the model, etc) is something that would need to be implemented in c++, and then exposed to TorqueScript as a behavior that the scripter can call: "turn upper chassis" would be most likely a c++ ConsoleMethod that performs all of the operations needed, but calling that ConsoleMethod would be done by script.
--"an entity that can be destroyed" : taking damage, as well as having health is something that would probably be implemented in the c++ class, but again TorqueScript would initiate the damage (by calling a console method on the class), as well as "react" to the object being destroyed via a callback handler, assuming that the underlying c++ implementation gave a callback to script when the object was destroyed.
Assuming that you also had a "repair/heal object" console method, you would react to the event of an object being destroyed by searching the simulation for other objects that are nearby in script, and calling the "repair/heal object" console method on each in turn.
--"a flying AI supply vehicle" : same setup: identify the behaviors of the class, and expose them to script. In this particular case, it would depend hugely on gameplay desires, but you would need a console method on your class that allows for "requesting supplies", and then an implementation in c++ and/or script that would carry out the response to that request.
05/03/2007 (11:58 am)
One of the analogies that I use when teaching Torque is the concept of driving a car. If you think about how you operate any vehicle in the real world, it can (mostly) be broken down into a series of actions that a driver initiates, and a set of behaviors and events that the vehicle performs.If you compare TorqueScript to the driver, and c++ to the vehicle, we can break down how things work relatively logically:
The vehicle is an implementation of a class that the scripter (driver) has an understanding about how to operate, but no understanding of the underlying implementation of things like the ignition sequence for the internal combustion engine, the electrical system that provides gauge readouts, or the process accomplished when the gas is pressed--he just knows that when he turns the key, the engine does "stuff", and finally starts.
The key here is that you need to identify what aspects of your design are "how things happen", and what aspect is "when things happen", and how to correctly implement those points of view. Using your examples:
--"A mech, where the upper body" : You are describing a user input tied to activating a behavior of the object. The behavior of modifying the model itself (rotating the upper chassis, conforming the animations and node positions of the model, etc) is something that would need to be implemented in c++, and then exposed to TorqueScript as a behavior that the scripter can call: "turn upper chassis" would be most likely a c++ ConsoleMethod that performs all of the operations needed, but calling that ConsoleMethod would be done by script.
--"an entity that can be destroyed" : taking damage, as well as having health is something that would probably be implemented in the c++ class, but again TorqueScript would initiate the damage (by calling a console method on the class), as well as "react" to the object being destroyed via a callback handler, assuming that the underlying c++ implementation gave a callback to script when the object was destroyed.
Assuming that you also had a "repair/heal object" console method, you would react to the event of an object being destroyed by searching the simulation for other objects that are nearby in script, and calling the "repair/heal object" console method on each in turn.
--"a flying AI supply vehicle" : same setup: identify the behaviors of the class, and expose them to script. In this particular case, it would depend hugely on gameplay desires, but you would need a console method on your class that allows for "requesting supplies", and then an implementation in c++ and/or script that would carry out the response to that request.
#3
05/03/2007 (12:02 pm)
Good analogy Stephen, I like that one.
#4
Something I should really cut and paste to the wiki with your permission.
I guess with the mech I could just subclass from Player, implement the necessary members and expose them to TorqueScript.
Without further speculation of what I could do, I am going to continue reading docs for a while until I feel brave enough to start tinkering with the engine.
Are there ever any bootcamps in the UK or are they just US based? Would be great to attend one of these.
05/03/2007 (12:25 pm)
Ah excellent. Thankyou Scott, and big thankyou Steve for that fantastic analogy.Something I should really cut and paste to the wiki with your permission.
I guess with the mech I could just subclass from Player, implement the necessary members and expose them to TorqueScript.
Without further speculation of what I could do, I am going to continue reading docs for a while until I feel brave enough to start tinkering with the engine.
Are there ever any bootcamps in the UK or are they just US based? Would be great to attend one of these.
Associate Scott Burns
GG Alumni
2) This could be handled entirely with script.
3) Again will involve both source and script, but this one I believe would lean more toward the script side.