Scripting Clarifications
by XzirAubrey · in Torque Game Engine · 03/26/2008 (12:22 pm) · 3 replies
Couple of clarifications about scripting please. First, variables. Variables can be added via torque script but not within a datablock, correct? Second, I keep seeing references to changing .cc and .h. Aren't .cc and .h C++ files that need compiling, or are they just seperate script files?
#2
Variables can also be created within the objects (ie, player.health), but going deeper (player.stats.health) would probably get you some trouble in the scripts. Hope that helps, and if anyone knows more or has knowledge that corrects me, feel free, because this is still a cloudy subject for a lot of us, myself included :)
03/26/2008 (1:33 pm)
@John: The main reason for modifying the source code for variables are for those who wish to use variable player attributes such as RPG's have. You can do this by modifying the source to allow for that, and it would be persistent over the network and be able to be different for each player (ie, different run speeds, etc). I don't use datablocks, but one feature of them I know of is that if you change the value of a datablock variable, that change will affect every instanced object that uses that datablock, so setting the run speed for a player through a variable in a datablock would basically change the run speed for all players.Variables can also be created within the objects (ie, player.health), but going deeper (player.stats.health) would probably get you some trouble in the scripts. Hope that helps, and if anyone knows more or has knowledge that corrects me, feel free, because this is still a cloudy subject for a lot of us, myself included :)
#3
An example where I changed the code today was adding a "brakeBias" setting to my car datablock so I could adjust the proportion of braking torque going to the front and rear tires. Because this is useful on the client's motion models (used for positioning the car between network update packets), I implemented it in the engine code so it was sent over to keep the motion of the clients ghost version of the car matching the server physics as accurately as possible.
03/26/2008 (2:59 pm)
You can add variables to a datablock in script alone (without implementing them in C++ in the engine), and they will be available to the server scripts for use. Datablock variables need to be added to the engine code if they need to be sent across to the client. Sometimes you won't need to do this. An example where I changed the code today was adding a "brakeBias" setting to my car datablock so I could adjust the proportion of braking torque going to the front and rear tires. Because this is useful on the client's motion models (used for positioning the car between network update packets), I implemented it in the engine code so it was sent over to keep the motion of the clients ghost version of the car matching the server physics as accurately as possible.
Employee Michael Perry
ZombieShortbus
In a little confused by your wording of the variable question, but variables can be added to datablocks in script and in C++ code.