A Few Basics
by Christopher Lambert · in Torque Game Engine · 05/09/2006 (9:30 pm) · 1 replies
Ok, I just purchased TGE and i'm having some difficulties figuring out what the context of these scripts are and finding useful documentation on class definitions.
For instance, i'm playing with the idea of "mounting" an object to my player. Looking at the starter.fps reveals an onUse event, but i'm looking for something more simplistic here to get an understanding of how scripting works.
After going through the initial tutorial (where you build a game to collect logo's and invoke a victory condition), my first goal was to try and mount a logo to the player. The server script was:
<>
%client.mountImage(%obj.image, $WeaponSlot);
if (%client)
commandToClient(%client, 'SetMountedWeapon', %obj);
where the msg was changed to a client command call, then on the client side:
function clientCmdSetMountedWeapon(%weapon)
{
%player.mountImage(%weapon.image, $WeaponSlot);
}
Of course, "%player" does not exist ... so heres my first question:
Q1: What namespace does the PlayerShape or Player (I assume former for mounting a shape too) live under and how do I access it from a general client script?
This is probably not the typical way to do it ... I'm guessing theres some Weapon class (WeaponItem?) that you must derive from in your datablock definition of a new weapon and then fire a message back to client .... but i'd like to be able to access objects so that i'm able to do something a bit more dynamic down the road. Which leads me to my second question:
Q2: Where can I find a reference that explains what objects can be accessed from where and their composition?
I'd like to see some simple examples here to get me started, things like:
3. How do I have a button in the gui that when clicked, mounts a weapon to the player?
4. How do I start and force 3rd person?
Theres a couple questions I have for the builders too, like:
5. How do you put a box inside a hill, and make it so the interior is not filled by the terrain (i.e. tunnel through/under a hill).
6. How do you actually apply a texture to an interior?
Anyhow, lots to figure out and any help is appreciated.
TIA
Chris
For instance, i'm playing with the idea of "mounting" an object to my player. Looking at the starter.fps reveals an onUse event, but i'm looking for something more simplistic here to get an understanding of how scripting works.
After going through the initial tutorial (where you build a game to collect logo's and invoke a victory condition), my first goal was to try and mount a logo to the player. The server script was:
<
%client.mountImage(%obj.image, $WeaponSlot);
if (%client)
commandToClient(%client, 'SetMountedWeapon', %obj);
where the msg was changed to a client command call, then on the client side:
function clientCmdSetMountedWeapon(%weapon)
{
%player.mountImage(%weapon.image, $WeaponSlot);
}
Of course, "%player" does not exist ... so heres my first question:
Q1: What namespace does the PlayerShape or Player (I assume former for mounting a shape too) live under and how do I access it from a general client script?
This is probably not the typical way to do it ... I'm guessing theres some Weapon class (WeaponItem?) that you must derive from in your datablock definition of a new weapon and then fire a message back to client .... but i'd like to be able to access objects so that i'm able to do something a bit more dynamic down the road. Which leads me to my second question:
Q2: Where can I find a reference that explains what objects can be accessed from where and their composition?
I'd like to see some simple examples here to get me started, things like:
3. How do I have a button in the gui that when clicked, mounts a weapon to the player?
4. How do I start and force 3rd person?
Theres a couple questions I have for the builders too, like:
5. How do you put a box inside a hill, and make it so the interior is not filled by the terrain (i.e. tunnel through/under a hill).
6. How do you actually apply a texture to an interior?
Anyhow, lots to figure out and any help is appreciated.
TIA
Chris
Torque Owner James Laker (BurNinG)
4) in gameconnection.cc set mFirstPerson = false;
Most of the other questions you can get with a simple search (top right of screen)
Just find tutorials on the different elements.
Question 1 and 2 I'll leave to the cleverer ;) people...