# Change party postion

#### xUMG

##### Hoho-oh?
Member
So, I haven't seen something asked like this before, let me get straight to the point.

So, the title is pretty self explanitory, Is there a way to change a Pokémon's party positon. i.e it checks for a certain species, then, it moves that species into the first party slot. Swapping the first Pokémon in the party, to that certain species's party slot.

I tried to explain it as best that I could I hope you understand.

Last edited:

#### MGriffin

##### Trainer
Member
It seems to me that you should be able to reorder the player's party by changing the order of the elements in $Trainer.party. Isn't it just something like this (completely untested!): Code: i =$Trainer.party.index { |p| p.species == species }
$Trainer.party[0],$Trainer.party[i] = $Trainer.party[i],$Trainer.party[0] if i

#### xUMG

##### Hoho-oh?
Member
It seems to me that you should be able to reorder the player's party by changing the order of the elements in $Trainer.party. Isn't it just something like this (completely untested!): Code: i =$Trainer.party.index { |p| p.species == species }
$Trainer.party[0],$Trainer.party[i] = $Trainer.party[i],$Trainer.party[0] if i

So, where do I place the internal name of the species?

#### MGriffin

##### Trainer
Member
So, where do I place the internal name of the species?
Where do you think you'd put it? Try sticking it in any of the places that seem reasonable. If you want to compare against a particular species you might want to look at how Essentials usually does that, i.e. isConst?(p.species,PBSpecies,:MEW)

#### xUMG

##### Hoho-oh?
Member
Where do you think you'd put it? Try sticking it in any of the places that seem reasonable. If you want to compare against a particular species you might want to look at how Essentials usually does that, i.e. isConst?(p.species,PBSpecies,:MEW)

I've tried that out and it gives off this error.
Code:
---------------------------
Pokémon Rusty
---------------------------
[Pokémon Essentials version 17.2]

Exception: RuntimeError

Message: Script error within event 12 (coords 4,37), map 86 (Pokémon Institute):

Exception: SyntaxError

Message: (eval):2:in pbExecuteScript'compile error
(eval):1: syntax error
= $Trainer.party.index { |p| p.species == KAKUNA } ^ ***Full script: =$Trainer.party.index { |p| p.species == KAKUNA }
$Trainer.party[0],$Trainer.party[i] = $Trainer.party[i],$Trainer.party[0] if i

Interpreter:276:in pbExecuteScript'

Interpreter:1606:in command_355'

Interpreter:494:in execute_command'

Interpreter:193:in update'

Interpreter:106:in loop'

Interpreter:198:in update'

Scene_Map:163:in update'

Scene_Map:161:in loop'

Scene_Map:170:in update'

Scene_Map:234:in main'

This exception was logged in

C:\Users\ACER\Saved Games\Pokémon Rusty\errorlog.txt.

Press Ctrl+C to copy this message to the clipboard.
---------------------------
OK
---------------------------

Sorry I'm not really good at doing this stuff :sweat:.

Last edited:

#### MGriffin

##### Trainer
Member
I think you're missing an "i" to the left of your equals sign?

EDIT: Also I think your comparison probably wants to be isConst?(p.species,PBSpecies,:KAKUNA), but you did identify the right place to make the change :)
EDIT2: Specifically, instead of "p.species == KAKUNA".

Last edited:

#### xUMG

##### Hoho-oh?
Member
I think you're missing an "i" to the left of your equals sign?

EDIT: Also I think your comparison probably wants to be isConst?(p.species,PBSpecies,:KAKUNA), but you did identify the right place to make the change :)
EDIT2: Specifically, instead of "p.species == KAKUNA".

It sounds like I'm stupid, but I don't get it.

#### leilou

##### A wild Minun appeared!
Member
The thing griffin said about KAKUNA is to replace it with PBSpecies::KAKUNA.
(well he said to replace p.species == KAKUNA with isConst?(p.species,PBSpecies,:KAKUNA)

Plus as he said placing the i in front of the first = (3 letters left of the ^)

Last edited:

#### xUMG

##### Hoho-oh?
Member
The thing griffin said about KAKUNA is to replace it with PBSpecies::KAKUNA.
(well he said to replace p.species == KAKUNA with isConst?(p.species,PBSpecies,:KAKUNA)

Plus as he said placing the i in front of the first = (3 letters left of the ^)

So something like this if I understand correctly.
Code:
i = $Trainer.party.index { |p| p.species == PBSpecies::KAKUNA }$Trainer.party[0], $Trainer.party[i] =$Trainer.party[i], $Trainer.party[0] if i But it gives this error. Code: --------------------------- Pokémon Rusty --------------------------- [Pokémon Essentials version 17.2] Exception: RuntimeError Message: Script error within event 12 (coords 4,37), map 86 (Pokémon Institute): Exception: ArgumentError Message: (eval):1:in index'wrong number of arguments(0 for 1) ***Full script: i =$Trainer.party.index { |p| p.species == PBSpecies::KAKUNA }
$Trainer.party[0],$Trainer.party[i] = $Trainer.party[i],$Trainer.party[0] if i

Interpreter:243:in pbExecuteScript'

(eval):1:in pbExecuteScript'

Interpreter:1606:in eval'

Interpreter:243:in pbExecuteScript'

Interpreter:1606:in command_355'

Interpreter:494:in execute_command'

Interpreter:193:in update'

Interpreter:106:in loop'

Interpreter:198:in update'

Scene_Map:163:in update'

Interpreter:276:in pbExecuteScript'

Interpreter:1606:in command_355'

Interpreter:494:in execute_command'

Interpreter:193:in update'

Interpreter:106:in loop'

Interpreter:198:in update'

Scene_Map:163:in update'

Scene_Map:161:in loop'

Scene_Map:170:in update'

Scene_Map:234:in main'

This exception was logged in

C:\Users\ACER\Saved Games\Pokémon Rusty\errorlog.txt.

Press Ctrl+C to copy this message to the clipboard.
---------------------------
OK
---------------------------

#### MGriffin

##### Trainer
Member
Ah, the version of Ruby in RMXP is suuuper old, and doesn't support the version of index I was trying to use.

Maybe try an explicit loop. e.g. something like this (also untested!):

Code:
$Trainer.party.each_index do |i| if isConst?($Trainer.party[i].species,PBSpecies,:KAKUNA)
$Trainer.party[0],$Trainer.party[i] = $Trainer.party[i],$Trainer.party[0]
end
end

EDIT: You might want to have a break inside that loop, or maybe not. Depends what you want to happen if someone happens to have multiple Kakunas.