Author Topic: Scripting a Mana Potion  (Read 282 times)

I was using Bob's Potions as a reference for the most part, but I just wanted to instead of it calling a function to give health back, give energy to function like a mana potion, but when I tested it, nothing happened, it just made the item go away. I'm not really much of a coder but I can understand a tiny bit of it, but can someone just tell me what to do here since I'm loving this up. Lmao


Quote
function ManaPotionImage::onFire(%data, %obj, %slot)
{
   %obj.addEnergy(50);
   %obj.playThread(0, shiftUp);

   if(isObject(%client = %obj.client))
   {
      %obj.tool[%obj.currTool] = 0;
      %obj.weaponCount--;
      messageClient(%client, 'MsgItemPickup', '', %obj.currTool, 0, 1);
      serverCmdUnUseTool(%client);
   }

}

addenergy is not a function
Code: [Select]
%obj.setEnergyLevel(%obj.getEnergyLevel() + 50);you can also make it a % to fit datablocks with differing energy amounts
Code: [Select]
%obj.setEnergyLevel(%obj.getEnergyLevel() + (%obj.getDatablock().maxEnergy * 0.5));
« Last Edit: July 27, 2019, 02:50:00 PM by maxymax13 »

Fixed ^
%obj.setEnergyLevel(%obj.getEnergyLevel() + 50)

i swear to god i completely forgot it was a method woops. anyways yeah addenergy isn't a thing