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: Can't get the function, "EatCloserCargoByType" working, can you help?  (Read 1604 times)

0 Members and 1 Guest are viewing this topic.

Offline Buzz313th

  • Jr. Member
  • **
  • Posts: 31
  • Karma: 0
12 February 2010, 23:48:41
Hi Dan,

Still working on those addons, although I have come to a snag...

I am unable to get the function "EatCloserCargoByType" to remove any weight from the cargo containers.

Heres the code:


// Load closest battery into Cargo into slot 0
// And check slot 0 status
dFullBatteryMass = 80;
switch (hUcgo.GrappleOneCargoByType("battery",0))
{
case 1:
   strcpy(oapiDebugString(),"Ok Cargo Grappled Battery");
   if ((hUcgo.GetCargoSlotMass(0) / dFullBatteryMass) < 0.01)
   {
      hUcgo.ReleaseOneCargo(0);
      strcpy(oapiDebugString(),"Battery has less than 1% charge.  Charge Battery before use");
   }
   else
   {
      //Charge Internal Tanks With Battery Power but leave
      //less than 1% charge in battery
      dBatteryEaten = ((hUcgo.GetCargoSlotMass(0) / dFullBatteryMass) - 0.009);
      hUcgo.EatCloserCargoByType("battery", dBatteryEaten);
      strcpy(oapiDebugString(),"Charging Internal Battery Tanks With External Battery");
   }
   break;



Thanks ahead of time if you can help.

JB

« Last Edit: 13 February 2010, 02:01:22 by Buzz313th »

Offline DanSteph

  • Administrator
  • Legend
  • *****
  • Posts: 15407
  • Karma: 256
  • Hein, quoi !?
    • FsPassengers
Reply #1 - 13 February 2010, 02:01:22
The cargo itself must be declared as ressource. Look at one ressource cargo config.

Dan

« Last Edit: 13 February 2010, 02:01:22 by DanSteph »