I'm encountering a bug where a package is activated during exec and then in-game the code inside the package doesn't work. Then when I deActivatePackage and activatePackage again through the console, it works perfectly.
Anyone run into this before?
Here is the package:
package FoodMenu
{
function Armor::onTrigger(%this, %player, %slot, %val)
{
if(isObject(%player.getMountedImage(0)) && %player.getMountedImage(0).getName()$="rawFoodBagImage")
{
if(%slot == 4 && %val)
{
if(%player.client.maxRawFoodOptions $= 1)
return;
if(%player.client.currRawFoodSelection $= %player.client.lastRawFoodItem)
{
for(%i = 1; 21 > %i; %i++)
{
if(%player.client.rawFood[%i] != 0)
{
%player.client.currRawFoodSelection = %i;
break;
}
}
%player.playThread(0,plant);
updateRawFoodUI(%player.client);
return;
}
else
{
%player.client.currRawFoodSelection = nextAvailableRawFoodSelection(%player.client);
%player.playThread(0,plant);
updateRawFoodUI(%player.client);
return;
}
}
updateRawFoodUI(%player.client);
}
else Parent::onTrigger(%this, %player, %slot, %val);
}
};
activatePackage(FoodMenu);
And the function called within:
function updateRawFoodUI(%client)
{
%client.maxRawFoodOptions = getMaxRawFoodOptions(%client);
%firstTime = 1;
%foodCount = 0;
for(%i = %client.currRawFoodSelection; 21 > %i; %i++) //cycle through the player owned foods to create the list
{
if(%firstTime)
{
%list = "\c6" @ getRawFoodItem(%i) SPC "x" SPC %client.rawFood[%i] @ "\n";
%foodCount++;
%firstTime = 0;
continue;
}
if(%foodCount $= 3) //stop once we have 3 items for the current list
break;
%foodItem = %client.rawFood[%i];
if(%foodItem !$= 0) //if the player has the food, add it to the list
{
%list = %list @ "\c7" @ getRawFoodItem(%i) SPC "x" SPC %client.rawFood[%i] @ "\n";
%foodCount++;
%client.lastRawFoodItem = %i;
}
}
if(%client.maxRawFoodOptions == 1 && %foodCount == 1) //if they have 1 item, don't show the scroll option
{
commandToClient(%client,'centerPrint',"<font:impact:64>\c3Raw Food\n<font:impact:32>\c6" @ %list,-1);
return;
}
if(%foodCount $= 0 || %client.maxRawFoodOptions == 0) //no raw food
commandToClient(%client,'centerPrint',"<font:impact:64>\c3Raw Food\n<font:impact:32>\n\c6You have no raw food packed in your bag.",-1);
if(%foodCount $= 1 && %client.maxRawFoodOptions > 1) //they're at the end of the list but have more options in the list
commandToClient(%client,'centerPrint',"<font:impact:64>\c3Raw Food\n<font:impact:32>\c6" @ %list @ "\n\n\c0\\/ \c6Right click to scroll",-1);
if(%foodCount $= 2) //special case to make sure the scroll UI isn't higher up when there's less options
commandToClient(%client,'centerPrint',"<font:impact:64>\c3Raw Food\n<font:impact:32>\c6" @ %list @ "\n\c0\\/ \c6Right click to scroll",-1);
if(%foodCount $= 3) //standard UI
commandToClient(%client,'centerPrint',"<font:impact:64>\c3Raw Food\n<font:impact:32>\c6" @ %list @ "\c0\\/ \c6Right click to scroll",-1);
}