Help with what should be a very simple code task.

Please support our C++ advertiser: Intel Parallel Studio Home
Thread Solved

Join Date: Aug 2005
Posts: 15,442
Reputation: Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute 
Solved Threads: 1474
Team Colleague
Featured Poster
Ancient Dragon's Avatar
Ancient Dragon Ancient Dragon is offline Offline
Still Learning

Re: Help with what should be a very simple code task.

 
0
  #11
Jan 3rd, 2009
The case statements are irrelevent -- they do absolutely nothing, so you should just delete them.
  1. if(TFGame.ToggleWarhead == true)
  2. {
  3. SMNameArray[0] = "Shield (50/30)";
  4. SMIndexArray[0] = 1;
  5. SMNameArray[1] = "Protector (200/30)";
  6. SMIndexArray[1] = 2;
  7. SMNameArray[2] = "Portal (200/30)";
  8. SMIndexArray[2] = 3;
  9. SMNameArray[3] = "Armory (200/60)";
  10. SMIndexArray[3] = 4;
  11. SMNameArray[4] = "Generator (300/60)";
  12. SMIndexArray[4] = 5;
  13. SMNameArray[5] = "Outpost (600/90)";
  14. SMIndexArray[5] = 6;
  15. SMArraySize=6;
  16. }
  17. else
  18. {
  19. SMNameArray[0] = "Shield (50/30)";
  20. SMIndexArray[0] = 1;
  21. SMNameArray[1] = "Protector (200/30)";
  22. SMIndexArray[1] = 2;
  23. SMNameArray[2] = "Portal (200/30)";
  24. SMIndexArray[2] = 3;
  25. SMNameArray[3] = "Armory (200/60)";
  26. SMIndexArray[3] = 4;
  27. SMNameArray[4] = "Generator (300/60)";
  28. SMIndexArray[4] = 5;
  29. SMNameArray[5] = "Outpost (600/90)";
  30. SMIndexArray[5] = 6;
  31. SMNameArray[6] = "Warhead (3000/180)";
  32. SMIndexArray[6] = 7;
  33. SMArraySize=7;
  34. }
Don't PM me with questions -- you might get a nasty PM in response. If you have a question then post it in one of the forums.
Reply With Quote Quick reply to this message  
Join Date: Jan 2009
Posts: 8
Reputation: Grimshad is an unknown quantity at this point 
Solved Threads: 0
Grimshad Grimshad is offline Offline
Newbie Poster

Re: Help with what should be a very simple code task.

 
0
  #12
Jan 3rd, 2009
AncientDragon, im sure theres a lot of sloppy code here.

But your comment didn't really help me get closer to my goal, of making the variable ToggleWarhead global so that i can use it in the file i need to use it in as an if statement

Thanks Though
Reply With Quote Quick reply to this message  
Join Date: May 2008
Posts: 560
Reputation: Murtan is a jewel in the rough Murtan is a jewel in the rough Murtan is a jewel in the rough Murtan is a jewel in the rough 
Solved Threads: 90
Murtan Murtan is offline Offline
Posting Pro

Re: Help with what should be a very simple code task.

 
0
  #13
Jan 4th, 2009
The if and else need to be 'inside' the case, and the if block and else block need their own set of braces { }.

if (test) { // code } else { // more code }
  1. case SMS_Construction:
  2. if(tfgame.ToggleWarhead == true)
  3. {
  4. SMNameArray[0] = "Shield (50/30)";
  5. SMIndexArray[0] = 1;
  6. SMNameArray[1] = "Protector (200/30)";
  7. SMIndexArray[1] = 2;
  8. SMNameArray[2] = "Portal (200/30)";
  9. SMIndexArray[2] = 3;
  10. SMNameArray[3] = "Armory (200/60)";
  11. SMIndexArray[3] = 4;
  12. SMNameArray[4] = "Generator (300/60)";
  13. SMIndexArray[4] = 5;
  14. SMNameArray[5] = "Outpost (600/90)";
  15. SMIndexArray[5] = 6;
  16. SMArraySize=6;
  17. }
  18. else
  19. {
  20. SMNameArray[0] = "Shield (50/30)";
  21. SMIndexArray[0] = 1;
  22. SMNameArray[1] = "Protector (200/30)";
  23. SMIndexArray[1] = 2;
  24. SMNameArray[2] = "Portal (200/30)";
  25. SMIndexArray[2] = 3;
  26. SMNameArray[3] = "Armory (200/60)";
  27. SMIndexArray[3] = 4;
  28. SMNameArray[4] = "Generator (300/60)";
  29. SMIndexArray[4] = 5;
  30. SMNameArray[5] = "Outpost (600/90)";
  31. SMIndexArray[5] = 6;
  32. SMNameArray[6] = "Warhead (3000/180)";
  33. SMIndexArray[6] = 7;
  34. SMArraySize=7;
  35. }

But this should work too and be a lot smaller:

  1. case SMS_Construction:
  2. SMNameArray[0] = "Shield (50/30)";
  3. SMIndexArray[0] = 1;
  4. SMNameArray[1] = "Protector (200/30)";
  5. SMIndexArray[1] = 2;
  6. SMNameArray[2] = "Portal (200/30)";
  7. SMIndexArray[2] = 3;
  8. SMNameArray[3] = "Armory (200/60)";
  9. SMIndexArray[3] = 4;
  10. SMNameArray[4] = "Generator (300/60)";
  11. SMIndexArray[4] = 5;
  12. SMNameArray[5] = "Outpost (600/90)";
  13. SMIndexArray[5] = 6;
  14. SMArraySize=6;
  15. if(tfgame.ToggleWarhead == true)
  16. {
  17. SMNameArray[6] = "Warhead (3000/180)";
  18. SMIndexArray[6] = 7;
  19. SMArraySize=7;
  20. }

PS- please use c++ language code tags when posting c++ source
[code=c++]
// your code here
[/code]
Reply With Quote Quick reply to this message  
Join Date: May 2008
Posts: 560
Reputation: Murtan is a jewel in the rough Murtan is a jewel in the rough Murtan is a jewel in the rough Murtan is a jewel in the rough 
Solved Threads: 90
Murtan Murtan is offline Offline
Posting Pro

Re: Help with what should be a very simple code task.

 
0
  #14
Jan 4th, 2009
After a little further searching, I don't see that any of the 'config' values from TFGame.uc (other than the one you are trying to add) are being used in TFMenuConsole anywhere.
Reply With Quote Quick reply to this message  
Join Date: Jan 2009
Posts: 8
Reputation: Grimshad is an unknown quantity at this point 
Solved Threads: 0
Grimshad Grimshad is offline Offline
Newbie Poster

Re: Help with what should be a very simple code task.

 
0
  #15
Jan 4th, 2009
Ok I found out some more info.

All of the other variables listed at the top of TFGame are in this format when being pulled by other files
  1. if(tfgame(level.Game).variable == true)
When i use
  1. if(tfgame(level.Game).ToggleWarhead == true)
the compiler returns
  1. Error, Bad or Missing Expression in 'if'
If i add
  1. local tfgame warhead
to the rest of the locals in TFMenuConsole

and then use
  1. if(warhead.ToggleWarhead == true)
then the code compiles fine, but it doesn't actually do anything in the game. I'm assuming this is because the local object I just created is blank.
Last edited by Grimshad; Jan 4th, 2009 at 1:53 am.
Reply With Quote Quick reply to this message  
Join Date: Jan 2009
Posts: 8
Reputation: Grimshad is an unknown quantity at this point 
Solved Threads: 0
Grimshad Grimshad is offline Offline
Newbie Poster

Re: Help with what should be a very simple code task.

 
0
  #16
Jan 4th, 2009
Ok, first ide like to thank everyone here
second, ide like to say im sorry because I didn't know what i was talking about

third, its fixed

  1. if(class 'TFGame'.default.ToggleWarhead == True)

that worked, cuz there are no global variables in this script
Reply With Quote Quick reply to this message  
Reply

This thread has been marked solved.
Perhaps start a new thread instead?
Message:


Thread Tools Search this Thread



About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC