How interact variables of torque script and show it in the GUI?
by PeluChe · in Torque 3D Beginner · 09/08/2010 (10:55 pm) · 4 replies
Hi everyone.
I have some questions of how interact the variables that i define in torque script and display in the GUI.
I have created a GuiTextCtrl and a file with the collision function in that function i need increase the variable score.
$client = %col.client;
$client.score += 1;
commandToClient($client, 'SetScoreCounter', $client.score);
I have read the "commandToClient" its use to communicate the with the GUI, its correct ? o how i can display the value of score?
I have some questions of how interact the variables that i define in torque script and display in the GUI.
I have created a GuiTextCtrl and a file with the collision function in that function i need increase the variable score.
$client = %col.client;
$client.score += 1;
commandToClient($client, 'SetScoreCounter', $client.score);
I have read the "commandToClient" its use to communicate the with the GUI, its correct ? o how i can display the value of score?
#2
in my file /art/datablocks/player.cs
function DefaultPlayerData::onCollision (%this, %obj, %col)
{
echo (" DefaultPlayerData Collision with " @ %col.getName());
if (%col.getName() $= "gol1")
{
%this.Anotacion(%client);
}
}
in my file /scripts/server/player.cs
function DefaultPlayerData::Anotacion (%client)
{
%score += 2;
commandToClient(%client, 'setScoreCounter', %score);
echo( %score) ;
}
Finally i create a file with this file is scripts/client/gameClient.cs and added tu client/init.cs
function clientCmdSetScoreCounter(%client)
{
SetScoreCounter.setText("score " SPC %score) ;
}
I wish you can helpme thx
09/09/2010 (9:21 pm)
Thx, but i still having the same problem.in my file /art/datablocks/player.cs
function DefaultPlayerData::onCollision (%this, %obj, %col)
{
echo (" DefaultPlayerData Collision with " @ %col.getName());
if (%col.getName() $= "gol1")
{
%this.Anotacion(%client);
}
}
in my file /scripts/server/player.cs
function DefaultPlayerData::Anotacion (%client)
{
%score += 2;
commandToClient(%client, 'setScoreCounter', %score);
echo( %score) ;
}
Finally i create a file with this file is scripts/client/gameClient.cs and added tu client/init.cs
function clientCmdSetScoreCounter(%client)
{
SetScoreCounter.setText("score " SPC %score) ;
}
I wish you can helpme thx
#3
09/24/2010 (2:22 am)
function clientCmdSetScoreCounter(%client)should be
function clientCmdSetScoreCounter(%score)
#4
09/26/2010 (3:45 pm)
Also, in your first function you don't have %client defined.
Torque 3D Owner Ted Southard
On server:
function doStuff(%client) { commandToClient(%client, 'makeClientDoStuff', %arg); }On client:
function clientCmdMakeClientDoStuff(%arg) //Note the name { //Do stuff }Hope that helps.