Mysidia Adoptables Support Forum

Mysidia Adoptables Support Forum (http://www.mysidiaadoptables.com/forum/index.php)
-   Questions and Supports (http://www.mysidiaadoptables.com/forum/forumdisplay.php?f=18)
-   -   Calling a function in a function from the same class page (http://www.mysidiaadoptables.com/forum/showthread.php?t=4833)

Hwona 04-24-2015 11:42 PM

Calling a function in a function from the same class page
 
Hello, I'm currently trying to edit the code in the class_owned_adoptables files and am trying to call the "getNextLevel" function in another function, but I can't get the function to return a value. Does anyone know a way around this or a way to call the function within a function in the same file? I'm using v1.3.3. Thank you!

The code is something like this in the function that calles the "getNextLevel" function:

public function code{
$nextlevel = $this->getNextLevel();
$document->add(new Comment($nextlevel));
}

No value is returned.

Kyttias 04-25-2015 02:19 AM

Does the pet you are looking at have a next level? For example, the maximum level I have on my test site for pets is level 4. If the pet is level 4, it has no next level, and therefore calling getNextLevel() would make the function, and therefore the variable holding the function, hold the value of FALSE, an empty value.

My recommended use of getNextLevel() would be something like:
PHP Code:

if($this->hasNextLevel()){
    
$level $this->getNextLevel();
    
$levelupClicks $this->getLevelupClicks();
    
$toNext "(LVL ".$level->getLevel()." in ".$levelupClicks." more EXP)"
}
else 
$toNext "(MAX)"

and then returning $toNext. But I'm dealing with v1.3.4, and I'm not sure how different things are. I'm currently doing the above in getStats(), another function in the ownedadoptables class.

Hwona 04-25-2015 08:41 AM

Re
 
Thank you so much Kyttias! For some reason, that works perfectly! :D


All times are GMT -5. The time now is 09:55 PM.

Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2024, vBulletin Solutions Inc.