• Our software update is now concluded. You will need to reset your password to log in. In order to do this, you will have to click "Log in" in the top right corner and then "Forgot your password?".
  • Welcome to PokéCommunity! Register now and join one of the best fan communities on the 'net to talk Pokémon and more! We are not affiliated with The Pokémon Company or Nintendo.

[Scripting Question] Needing to know how to do two technical things on my game.

  • 13
    Posts
    7
    Years
    • Seen Jan 27, 2024
    There was not really enough room in the title to be more specific. I apologize for that. I have two technical issues that I cant seem to find solutions to.

    The first this is I want to know how to make devices similar tothe pokedex and pokegear and add them to the start menu. I don't care for the idea of putting everything in one device and want to incorperate multiple devices that do specific things. An example would be adding a pokenav and having the pokenav handle navigation and location functions while the pokegear handles the radio and phone functions.

    My second issue is I need to know how to add new data to parts of the pbs (mostly the trainer pbs) and get the game codes to read the new data for use. By adding data Im reffering to adding new fields to the pbs. An example would be adding a reputation level field that states the reputation required to befriend a trainer and a field to write the current built reputation to so that the code can add reputation as you perform tasks and when the current reputation equals the required you will be able to befriend the trainer. I will be doing stuff more advanced than that of coarse but I need the basics to put me in the right direction.

    Anyone that can help, I would greatly appreciate your advise and help. Even if you could point me to someone who can answer this or a section of the essentials wiki that elaborates on this (I was not able to find any section talking about this).
     
  • 1,682
    Posts
    8
    Years
    • Seen today
    These are both possible, but I'm better versed at the latter than the former.
    Spoiler: Question 1
    I am not going to teach you how to make a new screen, as I don't 100% know how yet. But, to add a new option to the pause menu, you must go to script section PScreen_PauseMenu, and go to line 107 (Should be cmdEndGame = -1). You need to make a variable under it, with a similar naming scheme (not really, but it's nice). I'm going to make it cmdPokenav = -1. Now we need to scroll down to line 118-119 (commands[cmdPokegear=commands.length]=_INTL("Pokégear") if $Trainer.pokegear) and we will add our own option under it.
    Code:
    commands[[B]cmdPokenav[/B]=commands.length]=_INTL("[B]Pokénav[/B]")
    'Course, we want this option to do something, so scroll a little farther to about ~170 (pbLoadRpgxpScene(Scene_Pokegear.new))
    We want to add what our option does under it in an elsif
    Code:
    elsif [B]cmdPokenav[/B]>=0 && command==[B]cmdPokenav[/B]
      #Do stuff here

    Now if you start a new game, you will see your new option. 'Course, if you want the Pokenav to be unlocked, you will need to add a condition to it.
    In PokeBattle_Trainer, under attr_accessor(:language), add attr_accessor(:pokenav), then under @party=[], add @pokenav=false
    Now go back and change this
    Code:
    commands[[B]cmdPokenav[/B]=commands.length]=_INTL("[B]Pokénav[/B]")
    into this
    Code:
    commands[[B]cmdPokenav[/B]=commands.length]=_INTL("[B]Pokénav[/B]") if $Trainer.pokenav
    then when you want to give the Pokenav, just set $Trainer.pokenav=true in an event.

    Spoiler: Question 2
    Slightly confused about the whole befriending thing, because that is less pbs and more other scripts. Trainers don't really store their data, with exception to the player. But I'll explain editing the compiler none the less, using Trainer types, because those are easier to deal with and most of the information applies to the other compilers (Pokemon).
    Go to line 2152 (record=pbGetCsvRecord(line,lineno,[0,"unsUSSSeUS", # ID can be 0) The string is a series of commands, that each have their own effect.
    Spoiler:

    You can add your own command to the string to add an element.
    after that is a series of values. these are the default.
    Code:
    nil,nil,nil,nil,nil,nil,nil,{""=>2,"Male"=>0,"M"=>0,"0"=>0,"Female"=>1,"F"=>1,"1"=>1,"Mixed"=>2,"X"=>2,"2"=>2},nil,nil])
    These match up with the command string from earlier, so add your new default field to where you put the command.
    Finally, what if you want to load up the value later? That's easy. First, under maxValue=0, we need an variable with an empty array (I'm using fvalue=[]). Then we need to edit the record. This is mine:
    Code:
    record=pbGetCsvRecord(line,lineno,[0,"unsUSSSeUS[B]U[/B]", # ID can be 0
            nil,nil,nil,nil,nil,nil,nil,{
            ""=>2,"Male"=>0,"M"=>0,"0"=>0,"Female"=>1,"F"=>1,"1"=>1,"Mixed"=>2,"X"=>2,"2"=>2
            },nil,nil,[B]nil[/B]]
         )
    I added an extra optional positive integer at the end.
    Now under maxValue=[maxValue,record[0]].max, add fvalue[record[0]]=(record[10] ? record[10] : 0). This sets the id of the Trainer type in the array to our optional value or 0 if it's blank/nil.

    Next, under MessageTypes.setMessages(MessageTypes::TrainerTypes,trainernames), add MessageTypes.setMessages(MessageTypes::TrainerFriendValues,fvalue). This will allow us to easily pull these values when we want to. Don't worry too much about the TrainerFriendValues or the name you pick, except that it must start with a capital.

    After that, under code+="\r\ndef self.getName(id)\r\nreturn pbGetMessage(MessageTypes::TrainerTypes,id)\r\nend", add code+="\r\ndef self.getFriendValue(id)\r\nreturn pbGetMessage(MessageTypes::TrainerFriendValues,id)\r\nend". This auto defines code for us, and that gives an easy PBTrainers.getFriendValue(id) instead of pbGetMessage(MessageTypes::TrainerFriendValues,id), which is hard to remember.

    Finally, we need to add a constant. in Intl_Messages, in module MessageTypes on line 509, add a new constant under ScriptTexts = 23. I would make it TrainerFriendValues = 24 as it needs to be different from the rest, and have the same name.

    That's it. now if you want to see the required TrainerFriendValues, you would do PBTrainers.getFriendValue(TrainerTypeid).
     
  • 13
    Posts
    7
    Years
    • Seen Jan 27, 2024
    Thank you so much!! This is what I was needing. Sorry for the confusion on the second part. That was simply one of the uses I had in mind though I intend to use pulling from the pbs for many custom fields.

    Im trying to avoid creating events that pull from switches and variables as much as possible. This game is going to be massive and I will possibly wind up using near the 5000 switch limit. I need to see what the variable limit is. There are other things in game that may draw from custom pbs fields in more than just the trainer pbs. You have helped out alot.

    As far as the adding menus to the start menu to add what Im wanting to add, you have given me the info I was needing to the letter. Im fairly adept with coding so long as I have the basis to build from. I needed the exact guidleines you have provided and now I can move forward with this part of my game.

    Again, you have my thanks! You will recieve credit as well.
     
    Back
    Top