[PARTIALLY SOLVED] "The alternate form 0 does not exist..." when using Alts1 items in 1.3.6

Forum
Last Post
Threads / Messages

clay

Member
Member
Joined
May 2, 2023
Messages
8
Points
3
Age
27
Mysidian Dollar
158
i have an issue on my 1.3.6 site where i can't use Alts1 items to change pets' forms, it throws the error "The alternate form 0 does not exist..."
for example, i tried painting my pet below purple - everything should be in the right place unless i'm misunderstanding the functionality of Alts1 items
5Niwctk.png

rYOjN1k.png

wKfZWX0.png



i think it might have to do with the the "Last Alt Form" text field automatically filling in to 0 even if you delete the number, but i don't know how to troubleshoot past that
yvxmfSb.png
 
it looks like the original code didn't do what i wanted to, so i changed the function of Alts1 items on my site. i use alternates ONLY for different colours of pets to be obtained through items/transformations similar to neopets paintbrushes, not via breeding (i have breeding on my site turned off, so i haven't done any testing with that feature at all).
change model/domainmodel/itemfunction.php's applyAlts1 function to this:

PHP:
    protected function applyAlts1(OwnedItem $item, OwnedAdoptable $adopt){
        $mysidia = Registry::get("mysidia");
       
       
        $alid = $mysidia->db->select("alternates", ["alid"], "adopt = '{$adopt->getSpeciesID()}' AND level = '{$adopt->getCurrentLevel()}' AND item = '{$item->getItem()}'")->fetchColumn();
        $alternate = new AdoptAlternate($alid);
        if($adopt->getSpeciesID() != $alternate->getAdopt() || $adopt->getCurrentLevel() < $alternate->getLevel()){
            throw new ItemException("The item can only be used for adoptable {$alternate->getAdopt('model')->getType()} at level {$alternate->getLevel()} or above...<br>{$adopt->getSpeciesID()} {$alternate->getAdopt()}");
        }
        $adopt->setAlternate($alternate, "update");
        return "Your adoptable {$adopt->getName()} has gotten a new alternate form.";
    }

the only line i touched was "$alid = ...", which is the alternate form's ID. it used to read the value of the item you were using (e.g. a Potion of Blue Cat would turn only a Cat into a Blue Cat with the proper item value). now the alternate form's ID is selected by searching the alternate forms table in your database and selecting a match for the item you're trying to use, the adopt you're trying to use it on, and the level of that adopt. so now, instead of needing potions for every species, you can have paintbrushes or other items to change any pet to blue as long as they exist in the database, not just cats, like the example! :)

edit: this doesn't work after the pet evolves, i'm still trying to get that to work as of yet >.>
 
Last edited:

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