Pulling data from datablock
by Keith Mc Dowell JR · in Torque Game Builder · 12/19/2007 (12:18 pm) · 3 replies
Hello,
Does anyone have a code example of how to pull data from datablock, that now has been placed in datablock.cs file.
Logical I think this would work, but no getting the results.
datablock simDataBlock (Settings)
{
SoundVolume = "";
};
function SoundVolumeSlider::onMouseDrag(%this)
{
%new= %this.value; // obtain the new value
%Settings.SoundVolume=%new; apply the new value
SoundVolumeSlider.setValue(%Settings.SoundVolume); // update settings
}
in echo how do you print the store variable %this.value? Do, I need to getID first from Settings datablock.. little bit confused on this one.
Thanks,
Does anyone have a code example of how to pull data from datablock, that now has been placed in datablock.cs file.
Logical I think this would work, but no getting the results.
datablock simDataBlock (Settings)
{
SoundVolume = "";
};
function SoundVolumeSlider::onMouseDrag(%this)
{
%new= %this.value; // obtain the new value
%Settings.SoundVolume=%new; apply the new value
SoundVolumeSlider.setValue(%Settings.SoundVolume); // update settings
}
in echo how do you print the store variable %this.value? Do, I need to getID first from Settings datablock.. little bit confused on this one.
Thanks,
#2
I'm not 100% clear on your question. However, I can say that when referencing the object "Settings" by name, you don't want to use "%". Otherwise torquescript your using a local variable. In your code above, I would replace "%Settings" with "Settings."
Hope that helps.
12/19/2007 (12:59 pm)
Keith,I'm not 100% clear on your question. However, I can say that when referencing the object "Settings" by name, you don't want to use "%". Otherwise torquescript your using a local variable. In your code above, I would replace "%Settings" with "Settings."
Hope that helps.
#3
The code was what I could remember from memory :) But, I think I following close to the what I had. Ok, it seems I was confused about using the % variable sign and accessing object.. think in C++ code object->yield..
SoundVolumeSlider; is from a slider gui, which is the name I've give it to identify it. I was thinking, since I've give it a name SoundVolumeSlider, that I should make it a function.. The actually class is called GameSettings, but I do not think I can do the following: GameSettings::SoundVolumne::OnMouseDrag(%this), so I drop the class name and just made it a function.
Partick, thanks for the coding tid-bit.. i will make the updates to the code!
Thanks, both for your input.
12/19/2007 (2:33 pm)
Hey, Greg aka Tetraweb and Partrick.The code was what I could remember from memory :) But, I think I following close to the what I had. Ok, it seems I was confused about using the % variable sign and accessing object.. think in C++ code object->yield..
SoundVolumeSlider; is from a slider gui, which is the name I've give it to identify it. I was thinking, since I've give it a name SoundVolumeSlider, that I should make it a function.. The actually class is called GameSettings, but I do not think I can do the following: GameSettings::SoundVolumne::OnMouseDrag(%this), so I drop the class name and just made it a function.
Partick, thanks for the coding tid-bit.. i will make the updates to the code!
Thanks, both for your input.
Torque Owner Tetraweb
Settings.SoundVolume=%new;
in this scenario. Also, you are using SoundVolumeSlider.setValue...
If you are using SoundVolumeSlider as both a class name and a script object name, there is bound to be confusion, if not by TGB then at least by you as you try to look at your code.
Greg