See site in english Voir le site en francais
Website skin:
home  download  forum  link  contact

Welcome, Guest. Please login or register.
Did you miss your activation email?

Login with username, password and session length

Author Topic: UCGO SDK Question "EatCloserCargoByType"  (Read 2415 times)

0 Members and 1 Guest are viewing this topic.

Offline Buzz313th

  • Jr. Member
  • **
  • Posts: 31
  • Karma: 0
10 February 2010, 01:16:12
Can this function be used with a negative argument to actually load resources into a cargo?

JB


Offline DanSteph

  • Administrator
  • Legend
  • *****
  • Posts: 15407
  • Karma: 256
  • Hein, quoi !?
    • FsPassengers
Reply #1 - 10 February 2010, 01:40:53
Mhhh usually I always but safety on parameters, you might try but I doubt it work.

Dan

« Last Edit: 10 February 2010, 04:13:08 by DanSteph »

Offline Buzz313th

  • Jr. Member
  • **
  • Posts: 31
  • Karma: 0
Reply #2 - 10 February 2010, 03:02:25
Ok, can I ask you one more question please.

And I am appologising ahead of time for my ignorance in C++ as I just started learning it a week ago with no code
experience prior.

Can you tell me whats wrong with this code.  I can't get it to check the argument in the if statement.  I have a feeling
I am not stating the "none" parameter correctly.

         // After cueing action area "0" connect/disconnect battery
         char *CargoGrappled = hUcgo.GetCargoDescriptionString(0);
         if (CargoGrappled == "none")
         {
            sprintf (oapiDebugString(), "none");
         }
         else
         sprintf (oapiDebugString(), CargoGrappled);

« Last Edit: 10 February 2010, 04:13:08 by Buzz313th »

Offline DanSteph

  • Administrator
  • Legend
  • *****
  • Posts: 15407
  • Karma: 256
  • Hein, quoi !?
    • FsPassengers
Reply #3 - 10 February 2010, 03:17:02
you cannot compare two string with "==" you should use string comparison function like strcmp (string compare) strstr (string
search)  highlight one function and hit F1 for help.

Also I urge you to name your variable in a correct way, always the type first (f=float d=double i=int etc) then a
comprehensive name.

Exemple:
Code: [Select]
int iNbrOfCrewAboard;
double dAltitudeAboveGround;
float fO2TankLevel;

When you reach 2-5'000 lines of code incorrect variable name is a major reason of project crashing because the code become
unreadable.


In your case char * is a character pointer so:

Code: [Select]
// After cueing action area "0" connect/disconnect battery
char *cPtrCargoDescription = hUcgo.GetCargoDescriptionString(0);
if (strcmp(cPtrCargoDescription ,"none")==0)
{
        strcpy(oapiDebugString(), "none");
}
else
{
     strcpy(oapiDebugString(), cPtrCargoDescription );
}

Hope this help ?

Dan



Message modifié ( 10-02-2010 03:22 )

« Last Edit: 10 February 2010, 04:13:08 by DanSteph »

Offline Buzz313th

  • Jr. Member
  • **
  • Posts: 31
  • Karma: 0
Reply #4 - 10 February 2010, 03:38:12
Holy smokes..  it worked.  Thanks.  :)

I can't believe how lost I am..   I know I will get this done, but after clawing and scratching at the code for a few
weeks...  

I hope you don't mind other questions sometime..

JB

« Last Edit: 10 February 2010, 04:13:08 by Buzz313th »

Offline DanSteph

  • Administrator
  • Legend
  • *****
  • Posts: 15407
  • Karma: 256
  • Hein, quoi !?
    • FsPassengers
Reply #5 - 10 February 2010, 04:13:08
Quote
Buzz313th a écrit:
I hope you don't mind other questions sometime..
JB

My pleasure is to pass my knowledge, I've made a few tutorials and API about C++ but unfortunately they are in french...
Maybe with a translater ? :wonder:
http://orbiter.dansteph.com/forum/index.php?topic=6335.msg95352#msg95352

Now I have a big pleasure to teach my knowledge when I feel it's usefull: the guy is gifted and have a great learning curve.
If it's not the case it's probably useless anyway.

(Picto one user have wrote on big vessel dll after a few questions and reading the tutorials)

Learning a language is not having a big memory, it's only knowing a few logical principes, a few functions (say 10-15 to be
able to read code /execute it in head) AND knowing WHERE to search the other informations.

I explain the "method" here:
http://orbiter.dansteph.com/forum/index.php?topic=6337.msg95356#msg95356
unfortunately it's in french and unfortunately again my english is too bad to rewrite it in english.


Knowing the big picture and how/where to search is the key. A good programmer is a good detective first.

Keep up the good work ;)

Dan



Message modifié ( 10-02-2010 04:15 )

« Last Edit: 10 February 2010, 04:13:08 by DanSteph »