Click here to Skip to main content
15,881,559 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
This code is for an online emulator, and the syntax is driving me up a wall. No matter how I try to rearrange it, I always get errors with something or another.

C#
m_ResHue = 0;
               m_ResAmount = 0;
               m_System = craftSystem;

               if (IsQuantityType(types))
               {
                   index = ConsumeQuantity(ourPack, types, amounts);
               }
               else if (IsPlantHueType(types))
               {
                   index = ConsumeQuantityByPlantHue(from, craftSystem, ourPack, types, amounts);
               }
               else
               {
                   index = ourPack.ConsumeTotalGrouped(types, amounts, true, ResourceValidator, OnResourceConsumed, CheckHueGrouping);
               }

               resHue = m_ResHue;
           }
           else if
           // ConstumeType.None ( it's basicaly used to know if the crafter has enough resource before starting the process )
           (
               index = -1)


               if (IsQuantityType(types))
               {
                   for (int i = 0; i < types.Length; i++)
                   {
                       if (GetQuantity(ourPack, types[i]) < amounts[i])
                       {
                           // UNIVERSAL STORAGE KEYS BEGIN
                           if (BaseStoreKey.CraftWithdraw(ourPack, types[i], amounts[i]))
                           {
                               continue;
                           }
                           // UNIVERSAL STORAGE KEYS END
                           index = i;
                           break;
                       }
                   }
               }
               else if
               (
                   for (int i = 0; i < types.Length; i++)
                   {
                       if (ourPack.GetBestGroupAmount(types[i], true, CheckHueGrouping) < amounts[i])
                       {
                           // UNIVERSAL STORAGE KEYS START
                           //perform a scan and withdraw of the requested resource if it is found.  If not, then let the standard
                           //operation continue
                           if (BaseStoreKey.CraftWithdraw(ourPack, types[i], amounts[i]))
                           {
                               //this overrides the failure condition and lets the thread continue on with the next type in the
                                //types list
                               continue;
                           }
                           //otherwise, report not found and abort
                           // UNIVERSAL STORAGE KEYS END
                           index = i;
                           break;
                       }
                   }


What I have tried:

I've tried everything I can think of to rearrange the syntax. Please tell me what I'm doing wrong and how to fix it!
Posted
Updated 18-Dec-20 23:22pm

1 solution

We really can't help you with that limited a fragment and no error message: if I copy'n'paste that code into a new method, I get 141 errors, starting with
CS1519	Invalid token 'else' in class, struct, or interface member declaration
because the if condition above that code is missing.

But ... it's quite likely that if you look at your error message, it'll tell you what teh problem is, as the second error is:
CS8124	Tuple must contain at least two elements.

Looking at the line it dislikes gives an obvious error:
else if
// ConstumeType.None ( it's basicaly used to know if the crafter has enough resource before starting the process )
(    <<<<----- This should be a open curly bracket.
    index = -1)


    if (IsQuantityType(types))
Change that, and see if it helps at all...
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900