Game Development Community

If problem

by CodingChris · in Torque Game Engine · 09/24/2007 (10:16 am) · 4 replies

Hi,
I know it's a silly misstake, but I cannot see it:
if (pref::Player::Car = "") 
   {
   pref::Player::Car = "buggy";
   }
 if ($pref::player::wheels = "") {
 $pref::player::wheels = "wheel01";
 }
  if ($pref::lenkung = "") {
$pref::lenkung = "0.5";
 }
  if ($pref::distanz = "") {
$pref::distanz = "5";
 }
 if ($pref::Geschwindigkeit = "") {
$pref::Geschwindigkeit = "1.6";
 }
  if ($pref::masse = "") {
$pref::masse = "380";
 }
  if ($pref::motor = "") {
$pref::motor = "5200";
 }
   if ($pref::bremse = "") {
$pref::bremse = "5200";
 }
What's wrong here?
Christian

#1
09/24/2007 (10:22 am)
Well, that first one has this '$' missing, and all of them are using equals '=' in the if check itself. So basically you're filling your prefs with nothing, so your checks do nothing. You need to be using equal to '==' or the string version '$='.
#2
09/24/2007 (10:24 am)
You should have $= for string checking... you have = which is an assignment, not a logical check...

Double check the string compare, but I think the above is correct...
#3
09/24/2007 (10:03 pm)
You could also do it this way:
if(!$pref::Player::Car)
      $pref::Player::Car = "buggy";

   if(!$pref::player::wheels)
      $pref::player::wheels = "wheel01";

   if(!$pref::lenkung)
      $pref::lenkung = "0.5";

   if(!$pref::distanz)
      $pref::distanz = "5";

   if(!$pref::Geschwindigkeit)
      $pref::Geschwindigkeit = "1.6";

   if(!$pref::masse)
      $pref::masse = "380";

   if(!$pref::motor)
      $pref::motor = "5200";

   if(!$pref::bremse)
      $pref::bremse = "5200";
You don't need an opening and closing brace for each statement if you're only executing one statement below the if statement.
#4
09/24/2007 (11:15 pm)
Thanks, now I fixed my errors.