PDA

View Full Version : Trying to make a marking changer for adopts.


ilrak
11-03-2014, 01:13 PM
So, I'm using a mod similar to the gender change one that Wallie made and breed change mod that kristhasirah made to try and make a marking changer and I'm running into problems.

I want to make it so that each adopt has a "hidden" color that can be brought out by the markings, so a fish that has the colors "Gold/Gold/Black" would not have the black show until the marking is added. When I only have one adopt specified, then it works well.

function items_changecalico($item, $adopt){
$mysidia = Registry:: get("mysidia");
//Let's check if the adoptable is a Common (Gold/Gold/Black).
$type = $mysidia -> db -> select ("owned_adoptables", array("type"), "aid='{$adopt->aid}' and owner ='{$item->owner}'") -> fetchColumn();
if($type == "Common (Gold/Gold/Black)") {
//The adoptable is does not have calico. It's type can be switched to a Common (Gold/Gold/BlackCalico).
switch($adopt->type){
case "$type":
$mysidia -> db -> update("owned_adoptables", array("type" => 'Common (Gold/Gold/BlackCalico)'),"aid='{$adopt->aid}' and owner ='{$item->owner}'");
$note = "Your adoptable {$adopt->name} is now a Common (Gold/Gold/BlackCalico)."; }
//Update item quantity...
$delitem = $item->remove();
$note = "It appears your adoptable can't use the potion."; }
}
return $note;
}

I tried, however, to add in another "if" section with the next color which is all gold (because I want to set up some breed adopts where you can mix the markings), but the breed change didn't work. I didn't realize at the time that you can't have multiple outcomes in a function I guess.

What I'm wondering is if doing an array would work the way that I want it to. If not, are there any other suggestions anyone might have that might work? I'm going to keep tinkering with this on my days off because this is one of the things that I need to fix before I set up the alpha tests on my site.

Hopefully I'm making sense with my questions, too. I'm having one of those weeks where my language skills are off (and I can't blame wedding brain anymore)

Thanks!

Kyttias
11-04-2014, 10:19 AM
Ah, conditional statements (http://www.w3schools.com/php/php_if_else.asp). You should definitely be able to have multiple outcomes! You could try beginning the next statement with 'else if', rather than making another 'if' block - which could get messy if you have a lot of markings, or... perhaps try using switch (http://www.w3schools.com/php/php_switch.asp) statements. Additional info: ( x (http://phpswitch.com/), x (http://php.net/manual/en/control-structures.switch.php) ).

Currently:
1- Your switch statement doesn't break. It's important to break so it leaves the switch statement and continues on with the code properly. You only have one case, though? So why is the switch statement here?
2- Your last closing bracket doesn't follow up with anything, as the function ends before the return goes through. Can you double check the formatting on all that?

Why not make the outer if statement if($type == "Common (Gold/Gold/Black)") a switch statement instead? Are you looking for something like this?



function items_changecalico($item, $adopt){
$mysidia = Registry:: get("mysidia");
$type = $mysidia -> db -> select ("owned_adoptables", array("type"), "aid='{$adopt->aid}' and owner ='{$item->owner}'") -> fetchColumn();
//Let's check the adoptable type.
switch($type) {
case 'Common (Gold/Gold/Black)': // If tertiary is black, make it black calico?
$mysidia -> db -> update("owned_adoptables", array("type" => 'Common (Gold/Gold/BlackCalico)'),"aid='{$adopt->aid}' and owner ='{$item->owner}'");
$note = "Your adoptable {$adopt->name} is now a Common (Gold/Gold/BlackCalico).";
$delitem = $item->remove();
break;
case 'Common (Gold/Gold/Gold)': // If tertiary is gold, make it gold calico?
$mysidia -> db -> update("owned_adoptables", array("type" => 'Common (Gold/Gold/GoldCalico)'),"aid='{$adopt->aid}' and owner ='{$item->owner}'");
$note = "Your adoptable {$adopt->name} is now a Common (Gold/Gold/GoldCalico).";
$delitem = $item->remove();
break;
default: // If tertiary is not listed, do nothing?
$note = "It appears this adoptable cannot become calico.";
}
return $note;
}



*No guarantees that's going to work, but maybe it helped? But I could also be misunderstanding what you want and where (or how) you want the Gold/Gold/Gold to appear...

ilrak
11-04-2014, 01:09 PM
Oh my goodness! That is exactly it! Thank you so so so much!

If you ever need any art or anything in return, let me know! This works perfectly! ^v^

Kyttias
11-04-2014, 03:50 PM
:happycbig: Oh cool, I'm glad! I barely have any idea what you're up to with this, but it certainly sounds fascinating.