5
« on: January 21, 2013, 04:00:48 PM »
Replace %bot with $bot
As Port mentioned, there are things called variable scopes. %variables can not be referenced outside the function they're created in. These are called local variables. $variables persist through all scopes, meaning you can define it in one function and reference it in another. For example:
function thisWill()
{
%number = 5;
notWork();
}
function notWork()
{
echo(%number + 5);
}
As the names suggest, this will not work because %number is defined inside the scope of thisWill, and notWork is in a different scope. However, if you replaced that variable with its global equivalent ($number) it will work.
It may seem like you should just use global variables all the time because it's easier, but this is generally bad practice. I don't want to overwhelm you, but now that you know what the problem is you can go back to Yola's tutorial and learn more about local and global variables.