Solved PC on the Menu Screen

Posts
53
#1
I want to add a feature that lets you use the PC as an additional option on the Menu like the Pokedex or the Save option. Is there a way to do that?
 

Wonsul

Rookie
Member
Posts
9
#2
I have very limited scripting knowledge but I can still give you the most basic solution.

Assuming you are using Essentials v17, you need to go to the "PScreen_PauseMenu" script and look for that part :

Code:
  def pbStartPokemonMenu
	pbSetViableDexes
	@scene.pbStartScene
	endscene = true
	commands = []
	cmdPokedex  = -1
	cmdPokemon  = -1
	cmdBag	  = -1
	cmdTrainer  = -1
	cmdSave	 = -1
	cmdOption   = -1
	cmdPokegear = -1
	cmdDebug	= -1
	cmdQuit	 = -1
	cmdEndGame  = -1
Now you need to add the PC command to that menu. It is in the order they appear on screen, so if I want it between the "Bag" and "Trainer" options, I go like this :

Code:
  def pbStartPokemonMenu
	pbSetViableDexes
	@scene.pbStartScene
	endscene = true
	commands = []
	cmdPokedex  = -1
	cmdPokemon  = -1
	cmdBag	  = -1
	cmdPC	   = -1 #it makes the "PC" option show in the menu
	cmdTrainer  = -1
	cmdSave	 = -1
	cmdOption   = -1
	cmdPokegear = -1
	cmdDebug	= -1
	cmdQuit	 = -1
	cmdEndGame  = -1
Just a few lines below, you will see this:

Code:
	commands[cmdPokedex = commands.length]  = _INTL("Pokédex") if $Trainer.pokedex && $PokemonGlobal.pokedexViable.length>0
	commands[cmdPokemon = commands.length]  = _INTL("Pokémon") if $Trainer.party.length>0
	commands[cmdBag = commands.length]	  = _INTL("Bag") if !pbInBugContest?
	commands[cmdPokegear = commands.length] = _INTL("Pokégear") if $Trainer.pokegear
	commands[cmdTrainer = commands.length]  = $Trainer.name
You need to add a line, so it looks like this:

Code:
	commands[cmdPokedex = commands.length]  = _INTL("Pokédex") if $Trainer.pokedex && $PokemonGlobal.pokedexViable.length>0
	commands[cmdPokemon = commands.length]  = _INTL("Pokémon") if $Trainer.party.length>0
	commands[cmdBag = commands.length]	  = _INTL("Bag") if !pbInBugContest?
	commands[cmdPC = commands.length] = _INTL("PC") #with that "_INTL("....") part, you decide the name of the option in the menu. Here, it will be called "PC", but you can change it.
	commands[cmdPokegear = commands.length] = _INTL("Pokégear") if $Trainer.pokegear
	commands[cmdTrainer = commands.length]  = $Trainer.name
Finally, still in the same script, look for this part:

Code:
	  elsif cmdBag>=0 && command==cmdBag
		item = 0
		pbFadeOutIn(99999){ 
		  scene = PokemonBag_Scene.new
		  screen = PokemonBagScreen.new(scene,$PokemonBag)
		  item = screen.pbStartScreen 
		  (item>0) ? @scene.pbEndScene : @scene.pbRefresh
		}
		if item>0
		  Kernel.pbUseKeyItemInField(item)
		  return
		end
	  elsif cmdPokegear>=0 && command==cmdPokegear
		pbFadeOutIn(99999){
You need to add 2 lines, so it looks like this (it calls the same command that is called when you use the PC in a Pokemon Center) :

Code:
	  elsif cmdBag>=0 && command==cmdBag
		item = 0
		pbFadeOutIn(99999){ 
		  scene = PokemonBag_Scene.new
		  screen = PokemonBagScreen.new(scene,$PokemonBag)
		  item = screen.pbStartScreen 
		  (item>0) ? @scene.pbEndScene : @scene.pbRefresh
		}
		if item>0
		  Kernel.pbUseKeyItemInField(item)
		  return
		end
	  elsif cmdPC>=0 && command==cmdPC #add this line
		pbPokeCenterPC #and add this line too
	  elsif cmdPokegear>=0 && command==cmdPokegear
		pbFadeOutIn(99999){
And that's it! Remember it is VERY basic as it let's you access the PC menu anytime during gameplay, which means you can abuse it to heal your team by depositing and withdrawing them any time... It needs to be adjusted if you want the option to be accessible only at certain times.
 
Posts
53
#3
So what if I make that you can't heal your Pokémon when you switch them around with this feature but it let´s you do it when accessing to the Pokémon Centers' PCs? Is that possible?

Edit: Is it possible to make it like a Pokegear App or an additional Pokédex option?
 
Last edited:

MGriffin

Trainer
Member
Posts
95
#4
So what if I make that you can't heal your Pokémon when you switch them around with this feature but it let´s you do it when accessing to the Pokémon Centers' PCs? Is that possible?
Sure, you'll need to remember whether you came from the start menu or a PC when you start the screen, and then you can guard all the calls to heal with an if statement that checks where you came from. To do the remembering you'd either add a global variable and set/unset where you call pbPokeCenterPC, or change pbPokeCenterPC to take an extra parameter and pass that all the way down into PScreen_PokemonStorage.

Edit: Is it possible to make it like a Pokegear App or an additional Pokédex option?
Instead of adding Wonsul's code to the menu, add it to wherever else you want it to be. I don't see why you wouldn't be allowed to call pbPokeCenterPC from just about anywhere.
 
Posts
53
#5
Sure, you'll need to remember whether you came from the start menu or a PC when you start the screen, and then you can guard all the calls to heal with an if statement that checks where you came from. To do the remembering you'd either add a global variable and set/unset where you call pbPokeCenterPC, or change pbPokeCenterPC to take an extra parameter and pass that all the way down into PScreen_PokemonStorage.
I understand what you said, but I don't know much about scripting so if you could explain step by step how to do it, like Wonsul did, I'de really appreciate it.

Edit: By the way, I'd like it to be a Pokegear app. Please sorry if I'm causing you problems with these changes. :sweat:
 
Last edited:

MGriffin

Trainer
Member
Posts
95
#6
I understand what you said, but I don't know much about scripting so if you could explain step by step how to do it, like Wonsul did, I'de really appreciate it.
I can give you some pointers in the right direction, and then feel free to ask questions when you get stuck.

Wonsul's changes really boil down to one thing: calling pbPokeCenterPC when a menu item is chosen. We're going to extend pbPokeCenterPC so that it knows whether or not to heal Pokémon.

EDIT: This used to say "my additions in green", but it turns out that RC removes all the formatting inside code blocks! :( So now they have a comment.

In PScreen_PC we introduce a parameter is_pc and default it to true (so that everywhere that already calls pbPokeCenterPC doesn't need to change—you could also not default it and pass true explicitly in the existing calls). We pass this parameter all the way down through the individual PC scripts (i.e. TrainerPC and StorageSystemPC).

Code:
def pbPokeCenterPC(is_pc=true) # changed
  Kernel.pbMessage(_INTL("\\se[PC open]{1} booted up the PC.",$Trainer.name))
  loop do
	commands=PokemonPCList.getCommandList
	command=Kernel.pbMessage(_INTL("Which PC should be accessed?"),commands,commands.length)
	break if !PokemonPCList.callCommand(command, is_pc) # changed
  end
  pbSEPlay("PC close")
end
Code:
  def self.callCommand(cmd, is_pc) # changed
	if cmd<0 || cmd>=@@pclist.length
	  return false
	end
	i=0
	for pc in @@pclist
	  if pc.shouldShow?
		if i==cmd
		   pc.access(is_pc) # changed
		   return true
		end
		i+=1
	  end
	end
	return false
  end
Code:
class TrainerPC
  def shouldShow?
	return true
  end
 
  def name
	return _INTL("{1}'s PC",$Trainer.name)
  end
 
  def access(is_pc) # changed
	Kernel.pbMessage(_INTL("\\se[PC access]Accessed {1}'s PC.",$Trainer.name))
	pbTrainerPCMenu
  end
end
Code:
class StorageSystemPC
  def shouldShow?
	return true
  end
 
  def name
	if $PokemonGlobal.seenStorageCreator
	  return _INTL("{1}'s PC",Kernel.pbGetStorageCreator)
	else
	  return _INTL("Someone's PC")
	end
  end
 
  def access(is_pc) # changed
	Kernel.pbMessage(_INTL("\\se[PC access]The Pokémon Storage System was opened."))
	loop do
	  command=Kernel.pbShowCommandsWithHelp(nil,
		 [_INTL("Organize Boxes"),
		 _INTL("Withdraw Pokémon"),
		 _INTL("Deposit Pokémon"),
		 _INTL("See ya!")],
		 [_INTL("Organize the Pokémon in Boxes and in your party."),
		 _INTL("Move Pokémon stored in Boxes to your party."),
		 _INTL("Store Pokémon in your party in Boxes."),
		 _INTL("Return to the previous menu.")],-1
	  )
	  if command>=0 && command<3
		if command==1   # Withdraw
		  if $PokemonStorage.party.length>=6
			Kernel.pbMessage(_INTL("Your party is full!"))
			next
		  end
		elsif command==2   # Deposit
		  count=0
		  for p in $PokemonStorage.party
			count+=1 if p && !p.egg? && p.hp>0
		  end
		  if count<=1
			Kernel.pbMessage(_INTL("Can't deposit the last Pokémon!"))
			next
		  end
		end
		pbFadeOutIn(99999){
		  scene = PokemonStorageScene.new
		  screen = PokemonStorageScreen.new(scene,$PokemonStorage,is_pc) # changed
		  screen.pbStartScreen(command)
		}
	  else
		break
	  end
	end
  end
end
In PScreen_PokemonStorage we store is_pc in initialize (because we passed it as you can see above), and are then free to use it wherever there is a call to heal. Note that instead of storing it as is_pc, I'm instead calling it a slightly more descriptive healpkmn. I'm only showing one example here, you'll have to find the rest of the heals.

Code:
class PokemonStorageScreen
  attr_reader :scene
  attr_reader :storage
  attr_reader :healpkmn # changed
 
  def initialize(scene,storage,healpkmn=true) # changed
	@scene = scene
	@storage = storage
	@healpkmn = healpkmn # changed
	@pbHeldPokemon = nil
  end
Code:
  def pbPlace(selected)
	box = selected[0]
	index = selected[1]
	if @storage[box,index]
	  raise _INTL("Position {1},{2} is not empty...",box,index)
	end
	if box!=-1 && index>=@storage.maxPokemon(box)
	  pbDisplay("Can't place that there.")
	  return
	end
	if box!=-1 && @heldpkmn.mail
	  pbDisplay("Please remove the mail.")
	  return
	end
	if box>=0
	  @heldpkmn.heal if @healpkmn # changed
	  @heldpkmn.formTime = nil if @heldpkmn.respond_to?("formTime") && @heldpkmn.formTime
	end
	@scene.pbPlace(selected,@heldpkmn)
	@storage[box,index] = @heldpkmn
	if box==-1
	  @storage.party.compact!
	end
	@scene.pbRefresh
	@heldpkmn = nil
  end
With these sorts of changes you should be able to call pbPokeCenterPC false in the places where you don't want to allow the player to heal.
 
Posts
53
#7
So I did what you said, I tried it out by lowering my Pokémon's health and then store it using the feature, but it healed it. What did I miss?
 

MGriffin

Trainer
Member
Posts
95
#8
So I did what you said, I tried it out by lowering my Pokémon's health and then store it using the feature, but it healed it. What did I miss?
Did you store it via the deposit menu or via the move feature? My example change only affects moving. Alternatively did you make sure to change "pbPokeCenterPC" to "pbPokeCenterPC false" in the changes that Wonsul suggested?
 
Posts
53
#9
Did you store it via the deposit menu or via the move feature? My example change only affects moving. Alternatively did you make sure to change "pbPokeCenterPC" to "pbPokeCenterPC false" in the changes that Wonsul suggested?
I changed the pbPokeCenterPC to pbPokeCenterPC false on the PScreen_PauseMenu and this showed up:
---------------------------
Pokemon Essentials 17.2
---------------------------
[Pokémon Essentials version 17.2]
Exception: ArgumentError
Message: wrong number of arguments(1 for 0)
PScreen_PauseMenu:199:in `pbPokeCenterPC'
PScreen_PauseMenu:199:in `pbStartPokemonMenu'
PScreen_PauseMenu:144:in `loop'
PScreen_PauseMenu:275:in `pbStartPokemonMenu'
Scene_Map:127:in `call_menu'
Scene_Map:213:in `follow_update'
Follow Pokemon:1551:in `update'
Scene_Map:234:in `main'
Scene_Map:231:in `loop'
Scene_Map:236:in `main'

This exception was logged in
C:\Users\Cristian\Saved Games\Pokemon Essentials 17_2\errorlog.txt.
Press Ctrl+C to copy this message to the clipboard.
---------------------------
OK
---------------------------
Did I have to change it on the PScreen_PC?
Also, I used the Organize Boxes option.
 

MGriffin

Trainer
Member
Posts
95
#10

MGriffin

Trainer
Member
Posts
95
#12
How do I add the argument?
You see all the lines in my message with "# changed" at the end? Find and replace the existing lines (or add in a few circumstances). If you already did all of those then I'm not sure what the problem is, but from the looks of the error I'd say you're at least missing the change to pbPokeCenterPC?

(BTW it's much easier to have a timely conversation if you quote my messages—because I get an alert if you do)
 
Posts
53
#13
You see all the lines in my message with "# changed" at the end? Find and replace the existing lines (or add in a few circumstances). If you already did all of those then I'm not sure what the problem is, but from the looks of the error I'd say you're at least missing the change to pbPokeCenterPC?

(BTW it's much easier to have a timely conversation if you quote my messages—because I get an alert if you do)
What if I try adding "(is_pc=true) in the PScreen_PauseMenu section?

Edit: Nevermind, it did the same error message...
 

MGriffin

Trainer
Member
Posts
95
#16
It looks like this:
Code:
def pbPokeCenterPC(is_pc=true)
Well that's very confusing, because that should prevent you getting an error about the wrong number of arguments (I just tried it myself to confirm). Is it possible that you didn't replace the existing pbPokeCenterPC function—if you didn't (and it's later in the file) it will be (silently!) replacing the version you posted.
 
Posts
53
#17
Well that's very confusing, because that should prevent you getting an error about the wrong number of arguments (I just tried it myself to confirm). Is it possible that you didn't replace the existing pbPokeCenterPC function—if you didn't (and it's later in the file) it will be (silently!) replacing the version you posted.
Well, I tried deleting the "false" on pbPokeCenterPC that you suggested adding in the PScreen_PauseMenu section and the error doesn't show up. The problem is that were're back at the problem of the healing. I move the Pokémon using Organize Boxes and then I withraw it back to the team and it healed, and we don't want that to happen.
 

MGriffin

Trainer
Member
Posts
95
#18
Well, I tried deleting the "false" on pbPokeCenterPC that you suggested adding in the PScreen_PauseMenu section and the error doesn't show up. The problem is that were're back at the problem of the healing. I move the Pokémon using Organize Boxes and then I withraw it back to the team and it healed, and we don't want that to happen.
Yes. That's because you're either calling my edited script with is_pc set to true (i.e. heal), or (what I expect, given the error about extra arguments) you're calling the original version of the script which unconditionally heals.

Are you sure that there isn't a second pbPokeCenterPB defined somewhere? I can't think of what else could lead to the differences between what you're seeing and what I'm seeing.
 
Posts
53
#19
Yes. That's because you're either calling my edited script with is_pc set to true (i.e. heal), or (what I expect, given the error about extra arguments) you're calling the original version of the script which unconditionally heals.

Are you sure that there isn't a second pbPokeCenterPB defined somewhere? I can't think of what else could lead to the differences between what you're seeing and what I'm seeing.
There's a pbPokeCenterPC in the DebugMenu section and a def pbPokeCenterPC in the Following Pokemon script.
 

MGriffin

Trainer
Member
Posts
95
#20
There's a pbPokeCenterPC in the DebugMenu section and a def pbPokeCenterPC in the Following Pokemon script.
Aha! Yeah, it's the def pbPokeCenterPC in the Following Pokémon script—that one overrides all the changes you/I made to that function in PScreen_PC! You'll just need to make some similar changes in there too, i.e. introduce the is_pc parameter and pass it to callCommand. You might want to check if any of the other functions I've suggested changing are also duplicated in Following Pokémon, 'cause you'll need to do a similar thing for each one if so.

Off-topic, Following Pokémon is the bane of my life. It always conflicts with something.
 
Top