Calling a function in a function from the same class page

Forum
Last Post
Threads / Messages

Hwona

Member
Member
Joined
Mar 1, 2013
Messages
620
Points
0
Mysidian Dollar
31,589
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.
 
Last edited:
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:
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.
 
Last edited:
Re

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

Similar threads

Users who are viewing this thread

  • Forum Contains New Posts
  • Forum Contains No New Posts

Forum statistics

Threads
4,277
Messages
33,118
Members
1,602
Latest member
BerrieMilk
BETA

Latest Threads

Top