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 Sayned
It was my problem, but now I'm totally dissapointed with another thing. I tried to figure out how "MakePotion" works and now I have no idea what to do if I want to fix it.

What is happening: When I choose a potion to brew, clonk starts brewing, but then nothing happens.
Log:

WARNING: call to MakePotion gives 2 parameters, but only 1 are used (MenuCommand in MagicTimes.ocd\Potions.ocd\AlchemistKit.ocd\Script.c:0:0)

Code:
func ControlUse(object pClonk)
{
  pClonk->CreateMenu(GetID(), this, 1, "Nothing to craft", 0, 0, false);
  var i = 0, obj;
  while (obj = GetDefinition(i++))
  {
    if (!obj->~IsPotion()) continue;
    pClonk->AddMenuItem(Format("Brew a %s", obj->GetName()), "MakePotion", obj);
  }
  return true;
}

func MakePotion(ID)
{
  var pClonk = Contained();
  if (!pClonk) return;
  // remember components to be able to remove them later
  var components = [];
  // check if OK with GetComponents
  var i, ID, potion_ID;
  while (ID = GetComponent(nil, i++, nil, potion_ID))
  {
    var amount_needed = GetComponent(ID, nil, nil, potion_ID);
    var amount_available = pClonk->ContentsCount(potion_ID);
    if (amount_available < amount_needed)
    {
      Message("You need %d %s!", amount_needed, potion_ID->GetName());
      Sound("Error");
      return;
    }
    // add ID X times to the list
    while (amount_needed--)
    PushBack(components, ID); // PushBack adds something to the end of the list
    // everything is ok!
  }
  // remove components
  for (var comp in components)
  pClonk->FindContents(comp)->RemoveObject();
  // start timer to create potion
  var effect = AddEffect("BrewPotion",pClonk,100,4, nil, GetID());
  effect.potion = ID;
  return;
}

func FxBrewPotionTimer(target, effect, time)
{
  // effects...
  target->CreateParticle("MagicFlash",0,0,RandomX(-10,10),RandomX(-10,10),100, RGBa(255,155,0,200));
  if (time > 36*3) // three seconds
  {
  CreateObject(effect.potion);
  return -1;
  }
}

Also, effect will spawn object not in inventory, right?

Or writing like this is not necessary?
  {
  target->CreateContents(effect.potion);
  return -1;
  }

I'm sorry for asking big counts of questions >.<

Powered by mwForum 2.29.7 © 1999-2015 Markus Wichitill