I'd appreciate if you would. I think I understand what the issue is that you're pointing out, but it does go slightly above my head, and I don't have any experience using aliases or how they really work. This entire project has been built so far from just taking apart existing things I've found in the default Essentials script, and teaching myself how to put them back together in a way that suits my ideas. So I'm not exactly well versed on the technical end on problems like this.
Basically what im getting from you is that by making my overwrites to PokeBattle_Pokemon, it somehow omits something that allows Pokemon to spawn naturally in forms other than the default form 0. And that this can be fixed most efficiently by utilizing an alias as to not break other scripts that rely on the untouched version of the PokeBattle_Pokemon script. Is this correct?
Yeah, what you said is basically right. I'll break down what
alias does real quick.
Essentially all alias itself does it copy method a to method b, meaning that you have two methods that do the exact same. It's usually written as
alias newmethod oldmethod. You can then call the oldmethod method with newmethod as well. Example:
Code:
def say_hi
p "Hi!"
end
say_hi # Prints "Hi"
say_hello # Undefined method say_hello, obviously
# This copies say_hi to say_hello
alias say_hello say_hi
say_hello # Prints "Hi!"
What this allows you to do is to
add code to a method without needing to overwrite the whole entire method, like so:
Code:
def greet
p "Greetings"
end
greet # Prints "Greetings"
alias oldgreet greet
def greet
p "Welcome"
oldgreet
end
greet
#This now first prints "Welcome", and then prints "Greetings" after because it's calling that "oldgreet" alias. That method is still what the "greet" method USED to be, without the welcome part.[/code]
And this oldgreet stuff is essentially what Essentials itself does in its own script. If you then completely overwrite/redefine the method, you lose all those aliases because the method is just completely overwritten.
Code:
def greet
p "Greetings"
end
greet # Prints "Greetings"
alias oldgreet greet
def greet
oldgreet
p "Welcome!"
end
greet # Prints "Greetings", then "Welcome!"
# Now this is what your script does:
def greet
p "Greetings"
# Custom functionality
end
greet # Prints "Greetings"
So as you can see in this example, you lose the
p "Welcome!" code because it was overwritten. Now imagine the p "whatever" statements is actual code which is of importance such as setting the Pokémon's form upon creation, you lose that code. So either you could add that code yourself by simply copy-pasting what was in the alias like below:
Code:
def greet
p "Greetings"
p "Welcome!"
p # Custom functionality
end
That would be one way to fix it. "Greetings" being the old code, "Welcome" being the aliased code, and then your custom logic. However, you could also use an alias which automatically also has the other changes made to the method with other aliases:
Code:
alias oldgreet greet
def greet
oldgreet # This would be "Greetings" and "Welcome!"
# Custom functionality
end
This way you don't need to copy any other code and you keep support for other custom scripts (and even all Essentials-native scripts).
I hope this has made it a little more clear. If not, you could try looking at what alias is and how it's used online. I also have a detailed Ruby basics tutorial if you need any more clarification about methods:
https://www.pokecommunity.com/threads/410026