Not logged inOpenClonk Forum
Up Topic [QUESTION] Potion brewing

This board is threaded (i.e. has a tree structure). Please use the Reply button of the specific post you are referring to, not just any random button. If you want to reply to the topic in general, use the Post button near the top and bottom of the page.

Post Reply
In Response to Zapper
It's usually good to use clear variable names that you can quickly understand ;)
For example "amount_needed" and "amount_available" instead of "n" and "a";


// check if OK with GetComponents
  var i, component_ID;
  while (component_ID = GetComponent(nil, i++, nil, potion_ID))
  {
    var amount_needed = GetComponent(component_ID, nil, nil, potion_ID);
    var amount_available = pClonk->ContentsCount(component_ID);
    if (amount_available < amount_needed)
    {
      Message("You need %d %s!", amount_needed, component_ID->GetName());
      Sound("Error");
      return;
    }
    // add ID X times to the list
    while (amount_needed--)
    PushBack(components, component_ID); // PushBack adds something to the end of the list
    // everything is ok!
  }


If you really want to use "pID" and "ID", you could replace all "component_ID" by pID and all "potion_ID" by ID in the code above. I hope I didn't get confused on the way and it should work now :)

Powered by mwForum 2.29.7 © 1999-2015 Markus Wichitill