• Just a reminder that providing specifics on, sharing links to, or naming websites where ROMs can be accessed is against the rules. If your post has any of this information it will be removed.
  • Ever thought it'd be cool to have your art, writing, or challenge runs featured on PokéCommunity? Click here for info - we'd love to spotlight your work!
  • 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] July Ongoing- Help Would be Awesome Post, tyty community for assistance!

JulyArt

New Developer
  • 69
    Posts
    4
    Years
    • Seen Dec 17, 2021
    ~Thanks for all the help community~


    Solution #3~ Establishing 'Global String Variables' via Auto-run event. Remember that the first 25 variables are utilized already by Essentials. (Through script, will research how to do it when save is loaded later.)

    1. Make new script or add to existing in 'script editor', I named the new thing pbSetStaticVariables
    HTML:
    def pbSetStaticVariables
      $game_variables[50] = "julyart"

    2. Insert new Event Command to execute pbSetStaticVariables somewhere like intro screen on maps event editor.
    HTML:
    pbSetStaticVariables



    Solution #2~ Creating new 'Show Text Event' command with no parameter.

    ^Script>Message>Line 1143
    HTML:
        when "csa"#C.start Global ... dot dot dot pause speed
          msgwindow.textspeed = 30#C.end

    ^Script>Message>Line 1108
    HTML:
      while text[/(?:\\(f|ff|ts|cl|me|se|wt|wtnp|ch)\[([^\]]*)\]|\\(csa|csb|g|cn|wd|wm|op|cl|wu|\.|\||\!|\^))/i]

    To add parameter command, scroll down more to where \ts is located.

    Solution #1~ 'Show Text Event' Nesting variable \v[x] inside \ts[x] functions work because \ts[x] codes allow while \c[x] is different.

    Other Stuff~
    In order to change multiple \c[x] simultaneously, simply create additional \c in ^script>message_config>Line 298, then recall new color via \c[x]
    This is useful i.e. dedicating a \c[x] to an NPC to be their sole dialogue color, then changing Line 298 whenever you'd like to change all designated NPC dialogue color.

    ~Adding BGM to 'Continue' Screen~
    (broken link removed)
     
    Last edited:
    What version of Essentials do you use?
    In my version, nesting \v[X] inside \ts[X] does work ^^"
     
    Essential v18.1

    Oh my stars, I got it working \v[x] inside \ts[x]. Thank-you so much for confirming it does work. Oh dude. I. Thanks so much.

    This is super useful for like, if a character dialogue is always slow due to their 'seriousness' or something, and changing that speed later would be quick.

    I see, it seems \v[x] inside \c[x] doesn't work though is why I thought \v wouldn't work inside \ts

    Thanks again, I tried so much ; ; this definitely gets the job done for me.

    ~~

    If anyone knows how to implement a 'new message script command' such as /ts or /wt, share if have time :) as I think that'd be really useful for me understand why I couldn't get /cs1 working.
     
    If anyone knows how to implement a 'new message script command' such as /ts or /wt, share if have time :) as I think that'd be really useful for me understand why I couldn't get /cs1 working.

    In file Messages, in the function:
    Code:
    def pbMessageDisplay(msgwindow,message,letterbyletter=true,commandProc=nil)
    I think you need to look at the line:
    Code:
      while text[/(?:\\(f|ff|ts|cl|me|se|wt|wtnp|ch)\[([^\]]*)\]|\\(g|cn|wd|wm|op|cl|wu|\.|\||\!|\^))/i]
    It does some "parsing" of the text, and I believe your new command \cs1 was missing here.
     
    You sir, are a legend, tyty. It working now! I also realize I put \cs1 below where it was expecting a parameter, which I never gave it since it's a static command. Thank-you so much, I feel like this simple stuff is super useful in organization.

    If anyone reading, the next thing I'm trying to figure out is which script and where I 'should' place global string variables. Right now, I have an event doing the custom 'pbSetStaticVariables' which runs at intro of game with all the "I"m prof. OAK" and all that. I'm looking for where global string variables should go. With what I'm currently using, the variables won't be updated if the game were to be updated for example since it only triggers at the prof. OAK intro.

    i.e.
    HTML:
    def pbSetStaticVariables
      $game_variables[50] = ["???",
                              "M.Maggie",
                              "Mysterious Voice",
                              "ELIZA",
                              "ABC",]
     
    You sir, are a legend, tyty. It working now! I also realize I put \cs1 below where it was expecting a parameter, which I never gave it since it's a static command. Thank-you so much, I feel like this simple stuff is super useful in organization.
    :)

    If anyone reading, the next thing I'm trying to figure out is which script and where I 'should' place global string variables. Right now, I have an event doing the custom 'pbSetStaticVariables' which runs at intro of game with all the "I"m prof. OAK" and all that. I'm looking for where global string variables should go. With what I'm currently using, the variables won't be updated if the game were to be updated for example since it only triggers at the prof. OAK intro.

    i.e.
    HTML:
    def pbSetStaticVariables
      $game_variables[50] = ["???",
                              "M.Maggie",
                              "Mysterious Voice",
                              "ELIZA",
                              "ABC",]

    I don't have a strict answer to that question.
    If you remember which variable stores what data and in which form it does, then your solution is perfectly fine ^^

    But if you plan to edit that data afterwards, (or just show some values in text) you should avoid storing a list of stuff inside one variable. You can make as many variables as you like. ^^
    Unless this list is supposed to grow over time, I suggest you put simply one name per variable.

    If you stick to the list, maybe you should have some specific functions to access or modify this variable.
     
    The issue I'm having is as follow. "The game should know this information before the game start" is what I'm trying to do. If I start the game and go through intro, the event trigger will assign variables, then I save.
    Issue arise when the the dev. (me) decides to changes a character's name. When I load the save, it won't update due to the event trigger which assigns the variables only occurring at the 'intro' screen with PROF.OAK.
    Like, it would be cool, if I can maybe get it to assign all these variables every time a player loads a save for example would be spectacular. Then along with my current solution, it would cover new game and loads.

    The description above sounds cleaner than assigning all those variables at title screen or something like that, but perhaps that's easier?

    So I'm using variable array 50 for all my characters names. I feel like it's cleaner for long term so I don't have to plan on reserving certain variables range for characters name.
    I'm also using variable array 51 for all character's text speed if they should have a customize one. This way, I can quickly think of alright... array [50][1] and [51][1] goes together. instead of thinking of their corresponding variable number.
     
    The issue I'm having is as follow. "The game should know this information before the game start" is what I'm trying to do. If I start the game and go through intro, the event trigger will assign variables, then I save.
    Issue arise when the the dev. (me) decides to changes a character's name. When I load the save, it won't update due to the event trigger which assigns the variables only occurring at the 'intro' screen with PROF.OAK.
    Like, it would be cool, if I can maybe get it to assign all these variables every time a player loads a save for example would be spectacular. Then along with my current solution, it would cover new game and loads.

    The description above sounds cleaner than assigning all those variables at title screen or something like that, but perhaps that's easier?
    You'll need to use another function (or plain script) to update the game variables, for example in an autorun Event (so that the player is not aware of it) that changes its state after loading (so it doesn't run twice and/or eternally).

    So I'm using variable array 50 for all my characters names. I feel like it's cleaner for long term so I don't have to plan on reserving certain variables range for characters name.
    I'm also using variable array 51 for all character's text speed if they should have a customize one. This way, I can quickly think of alright... array [50][1] and [51][1] goes together. instead of thinking of their corresponding variable number.
    Seems to me that you'd rather make a class to store character information (name, text speed, maybe something else?), and store everything in a list in a $PokemonTemp attribute ^^"
    I cannot test at the moment, but I am pretty sure you can't write \v[50][1] in text and get the second name (if that's what you want to do).
     
    So the issue I'm having now, I'm unsure if there's a simple workaround. I should establish what I'm trying to accomplish clearly. Thank-you so much for having the time to help us newer ruby users out. (I'll definitely research 'class', first I've heard)

    So I think it would be really neat for each major NPC character to have their own (Name Color, Dialogue Color, Text Speed, Windowskin)
    I managed to get the first three, even though it's sort of a new mess, but I'm stuck at Windowskin \w command. (I found a work around, which is just to replace the assign .png itself, but then there's the disadvantage of having duplicate .png if more than 1 char uses the same .png. I know it's a small disadvantage, I just like to be super neat and learn all I can)

    Right now, each show text event for my first character is something like: \ts[v[54]\w[choice 4]\c[14]\v[50]\c[15] the first \c colors the name, the second \c colors the dialogue, the rest does its thing.
    I'm wondering, is there a way I can somehow put "\ts[v[54]\w[choice 4]\c[14]\v[50]\c[15]" inside something, so all I have to do is \v[5] and it gets turn into "\ts[v[54]\w[choice 4]\c[14]\v[50]\c[15]" which would execute correctly?
    If there's not, then it'd just be a lot of tedious copy/paste instead of typing something simple such as \v[5], which is fine. It would just save so much time if there was a magic solution


    Seems to me that you'd rather make a class to store character information (name, text speed, maybe something else?), and store everything in a list in a $PokemonTemp attribute ^^"
    I cannot test at the moment, but I am pretty sure you can't write \v[50][1] in text and get the second name (if that's what you want to do).

    Fortunately I was able to do the following to get array to work
    HTML:
      loop do #C.start Return Array
        last_text = text.clone
        text.gsub!(/\\a\[([0-9]+)\]\[([0-9]+)\]/i) { $game_variables[$1.to_i][$2.to_i] }
        break if text == last_text
      end #C.end

    In which \a[x][x] properly works as I'd like. There was a small issue as even though \ts[a[x][x] works, I couldn't figure out how to subtext the second [x] (which would show in text) with "" (blank)
    I worked around that by doing the following

    HTML:
    loop do #Custom Char. Dialogue Speed
        last_text = text.clone
        text.gsub!(/\\s\[([0-9]+)\]/i) { ($game_variables[51][$1.to_i]) }
        break if text == last_text
      end #C.end

    now when I write \ts[s[1] it works.

    Issue: \w[v[1] unfortunately does not work. the \w seems to trigger, as it shows no windowskin, but it can't seem to understand the string "choice 4" that is within \v[1]

    I've located I think where the \w command is written

    Script>Message>Line 1021

    HTML:
     ### Text replacement
      text.gsub!(/\\sign\[([^\]]*)\]/i) {   # \sign[something] gets turned into
        next "\\op\\cl\\ts[]\\w["(+$1+)"]"  # \op\cl\ts[]\w[something]
      }
      text.gsub!(/\\\\/,"\5")
      text.gsub!(/\\1/,"\1")
      if $game_actors
        text.gsub!(/\\n\[([1-8])\]/i) {
          m = $1.to_i
          next $game_actors[m].name
        }
      end
     
    Last edited:
    I managed to get the first three, even though it's sort of a new mess, but I'm stuck at Windowskin \w command. (I found a work around, which is just to replace the assign .png itself, but then there's the disadvantage of having duplicate .png if more than 1 char uses the same .png. I know it's a small disadvantage, I just like to be super neat and learn all I can)
    What doesn't work?
    From what I read in the pbMessageDisplay code, you can set the window skin with "\w[speech hgss 17]" ^^
    (Check the speech frames in PScreen_Options).

    Right now, each show text event for my first character is something like: \ts[v[54]\w[choice 4]\c[14]\v[50]\c[15] the first \c colors the name, the second \c colors the dialogue, the rest does its thing.
    I'm wondering, is there a way I can somehow put "\ts[v[54]\w[choice 4]\c[14]\v[50]\c[15]" inside something, so all I have to do is \v[5] and it gets turn into "\ts[v[54]\w[choice 4]\c[14]\v[50]\c[15]" which would execute correctly?
    If there's not, then it'd just be a lot of tedious copy/paste instead of typing something simple such as \v[5], which is fine. It would just save so much time if there was a magic solution
    I wonder if you can put a "\char[X]" keyword, that you parse at the start of the pbMessageDisplay function, before anything else is parsed.
    Maybe a function that does this: if it detects \char[X], it replaces \char[X] with the complete formatting string corresponding to character number X in the list.


    Fortunately I was able to do the following to get array to work
    HTML:
      loop do #C.start Return Array
        last_text = text.clone
        text.gsub!(/\\a\[([0-9]+)\]\[([0-9]+)\]/i) { $game_variables[$1.to_i][$2.to_i] }
        break if text == last_text
      end #C.end

    In which \a[x][x] properly works as I'd like. There was a small issue as even though \ts[a[x][x] works, I couldn't figure out how to subtext the second [x] (which would show in text) with "" (blank)
    I worked around that by doing the following

    HTML:
    loop do #Custom Char. Dialogue Speed
        last_text = text.clone
        text.gsub!(/\\s\[([0-9]+)\]/i) { ($game_variables[51][$1.to_i]) }
        break if text == last_text
      end #C.end

    now when I write \ts[s[1] it works.

    Issue: \w[v[1] unfortunately does not work. the \w seems to trigger, as it shows no windowskin, but it can't seem to understand the string "choice 4" that is within \v[1]

    I've located I think where the \w command is written

    Script>Message>Line 1021

    HTML:
     ### Text replacement
      text.gsub!(/\\sign\[([^\]]*)\]/i) {   # \sign[something] gets turned into
        next "\\op\\cl\\ts[]\\w["(+$1+)"]"  # \op\cl\ts[]\w[something]
      }
      text.gsub!(/\\\\/,"\5")
      text.gsub!(/\\1/,"\1")
      if $game_actors
        text.gsub!(/\\n\[([1-8])\]/i) {
          m = $1.to_i
          next $game_actors[m].name
        }
      end

    In the rest of your post, I wonder whether it's a typo or not, but you always write: \ts[a[x][x] instead of \ts[a[x][x]]. So I am not sure if this error appears in this post only or if it explains why your code doesn't work?
     
    It functions properly as /ts[a[x][x] if I put another ] , it'll show in the text thing. I'm guessing this has to do with how /ts is formulated.

    What I still can't get to work is /w[var1]] for example. Thus I can't place a permanent static variable onto a specific character window frame in which I may choose to alter later.

    /w activates properly, as it replaces the window with no window . e.g. /w[var1]] /w function for some reason can't read [var1] which is "choice 4"

    I'm pretty sure it has to do with how \w treats its parameter, but when I look at how \w works, my skills aren't high enough to identify why it won't read the string "choice 4" within \v[1] properly
     
    It functions properly as /ts[a[x][x] if I put another ] , it'll show in the text thing. I'm guessing this has to do with how /ts is formulated.

    The way your \ts works is a bit strange, and as a mathematician and a computer scientist, I find this imbalance in parentheses really disturbing... lol. But if that works, ok.

    What I still can't get to work is /w[var1]] for example. Thus I can't place a permanent static variable onto a specific character window frame in which I may choose to alter later.

    /w activates properly, as it replaces the window with no window . e.g. /w[var1]] /w function for some reason can't read [var1] which is "choice 4"

    I'm pretty sure it has to do with how \w treats its parameter, but when I look at how \w works, my skills aren't high enough to identify why it won't read the string "choice 4" within \v[1] properly

    Well, actually, there is no trick ^^
    It's just that in the function
    Code:
    def pbMessageDisplay(msgwindow,message,letterbyletter=true,commandProc=nil)
    the command \w is treated first and then \v is treated:
    Code:
      # This part is for Window skin (\w command)
      text.gsub!(/\\[Ww]\[([^\]]*)\]/) {
        w = $1.to_s
        if w==""
          msgwindow.windowskin = nil
        else
          msgwindow.setSkin("Graphics/Windowskins/#{w}",false)
        end
        next ""
      }
      isDarkSkin = isDarkWindowskin(msgwindow.windowskin)
      text.gsub!(/\\[Cc]\[([0-9]+)\]/) {
        m = $1.to_i
        next getSkinColor(msgwindow.windowskin,m,isDarkSkin)
      }
      # And this part is for variables.
      loop do
        last_text = text.clone
        text.gsub!(/\\v\[([0-9]+)\]/i) { $game_variables[$1.to_i] }
        break if text == last_text
      end
    So \w[X] can't get the value stored in \v[X] because \v[X] is treated after \w[X].
    And easy way to solve this would be to switch places between the \v part and the \w part. I don't think it will break anything here.
     
    thank-you so much, I see I see. I really enjoy understanding 'why'. After it make sense, it's like that lesson is forever in ways.

    I was hesitant to write any dialogue without having this figure out so I don't have to go back and do a bunch of copy/paste. Excitement now I can continue.

    edit update: darn, it still no work. but your suggestion definitely stillwould have to happen in conjunction to whatever else is causing the issue.

    it's likely

    Code:
      text.gsub!(/\\sign\[([^\]]*)\]/i) {   # \sign[something] gets turned into
        next "\\op\\cl\\ts[]\\w["+$1+"]"    # \op\cl\ts[]\w[something]
      }
      text.gsub!(/\\\\/,"\5")
      text.gsub!(/\\1/,"\1")
      if $game_actors
        text.gsub!(/\\n\[([1-8])\]/i) {
          m = $1.to_i
          next $game_actors[m].name
        }
      end

    or this one
    Code:
      text.gsub!(/\\\[([0-9a-f]{8,8})\]/i) { "<c2="+$1+">" }

    however, again. I'm like. looking at it. and it's french. xD I"m just not there yet.

    I've been reading the basic operators and stuff like that, trying to build understanding bit by bit.

    If have time, this one been bugging me long time, as I cannot google, what does the /i do? in the following

    Code:
      text.gsub!(/\\v\[([0-9]+)\]/i) { $game_variables[$1.to_i] }


    Also, this other questions on my mind, you've already done so much, no need to read on

    Regarding 'player(x)' like from pbChangePlayer(0) why is the highest number 7?

    the following quote is from wiki
    pbChangePlayer(X)
    "X" is a number between 0 and 7, corresponding to player characters A through H. This script is called in the game intro, and is one of the two vital things that MUST happen there (along with setting the player's name).
     
    Last edited:
    edit update: darn, it still no work. but your suggestion definitely stillwould have to happen in conjunction to whatever else is causing the issue.

    it's likely

    Code:
      text.gsub!(/\\sign\[([^\]]*)\]/i) {   # \sign[something] gets turned into
        next "\\op\\cl\\ts[]\\w["+$1+"]"    # \op\cl\ts[]\w[something]
      }
      text.gsub!(/\\\\/,"\5")
      text.gsub!(/\\1/,"\1")
      if $game_actors
        text.gsub!(/\\n\[([1-8])\]/i) {
          m = $1.to_i
          next $game_actors[m].name
        }
      end

    or this one
    Code:
      text.gsub!(/\\\[([0-9a-f]{8,8})\]/i) { "<c2="+$1+">" }

    however, again. I'm like. looking at it. and it's french. xD I"m just not there yet.
    The first code would only cause problems if you used "\sign", which you don't according to your previous posts ^^
    The second code lets you match stuff like this: \[112d58ff] (8-digit hexadecimal value). It changes the color of the text right after (this is RGBA hexadecimal value). I don't believe you're triggering this.
    Can you post the code for your function:
    Code:
    def pbMessageDisplay(msgwindow,message,letterbyletter=true,commandProc=nil)
    It would be easier to help you if I know what you are working with ^^


    I've been reading the basic operators and stuff like that, trying to build understanding bit by bit.

    If have time, this one been bugging me long time, as I cannot google, what does the /i do? in the following

    Code:
      text.gsub!(/\\v\[([0-9]+)\]/i) { $game_variables[$1.to_i] }
    The symbol "/i" says "ignore case" (see the Ruby docs).


    Also, this other questions on my mind, you've already done so much, no need to read on

    Regarding 'player(x)' like from pbChangePlayer(0) why is the highest number 7?

    the following quote is from wiki
    pbChangePlayer(X)
    "X" is a number between 0 and 7, corresponding to player characters A through H. This script is called in the game intro, and is one of the two vital things that MUST happen there (along with setting the player's name).
    I think it's arbitrary. They probably wanted to allow different players but didn't want to hard-code more than 8 characters.
     
    Got it working. Man. That was rough. It turned out most of it was from my inexperience with testing the code. It correctly works, but I thought it didn't because I also have a variable in the text which shows. The code below does what it's supposed to, although. the \w[v[x] won't work like \ts[v[x] but \w[\v[x]] does. is a bit worrisome. if have time to figure out why it does that lmk xD at this point though, I think everything is working. I'm ready to move on xD

    Got everything working, and I learnt about 'class' the basic level anyway. Dang. It feels like I just level up a lot since these are everywhere, I just didn't realize.
    now all I have to put in each dialogue is \z[x] and it will do things. I follow that with whatever dialouge. i.e. \z[x] Welcome to the world of PKMN! = PROF.OAK: Welcome to the world of PKMN!
    I terms of organization and recalling, this will definitely be less strenuous on the dev.

    Man, coding is so cool.

    edit#3: So I'm wondering, let's say I have a class and then the game define that object to be = choice 4 via player choice event for example.
    when the player saves the game, quit the game, then loads the game. how does the game knows this class object is = choice 4? like do I need to do something special for the game to remember choice 4 when I load.

    Going to try to get the following to work next so I don't have to painfully see a batch of code within every dialogue text edit. And also research 'class' so many to use those over currently used arrays.
    edit

    I wonder if you can put a "\char[X]" keyword, that you parse at the start of the pbMessageDisplay function, before anything else is parsed.
    Maybe a function that does this: if it detects \char[X], it replaces \char[X] with the complete formatting string corresponding to character number X in the list.


    So I'm like. A LOT CLOSER NOW. it has to do with something that's also affecting why I don't need to do \ts[a[x][x]] and why \ts[a[x][x] works.
    but I'm unsure what's triggering it.

    \w[v[x] won't work like \ts[v[x]] but \w[\v[x]] does. but it leaves behind "Choice 4" string in the show message text screen, it won't delete it.

    The more I think about this, I feel like it'd be easier to write a whole new thing per se, because I don't understand how the current code works to influence it the way I'd like.
    but I feel like i'm very close. I just have to somehow delete "Choice 4" text from the final dialouge screen.


    edit: I think at this point, I should really view some Ruby tutorial so I can understand the language more. haha. My brain is so mush from this simple thing. I had to walk away for a few days work on other things and I'm so close xD

    Code:
    [spoiler]
    def pbMessageDisplay(msgwindow,message,letterbyletter=true,commandProc=nil)
      return if !msgwindow
      oldletterbyletter=msgwindow.letterbyletter
      msgwindow.letterbyletter=(letterbyletter) ? true : false
      ret=nil
      commands=nil
      facewindow=nil
      goldwindow=nil
      coinwindow=nil
      cmdvariable=0
      cmdIfCancel=0
      msgwindow.waitcount=0
      autoresume=false
      text=message.clone
      msgback=nil
      linecount=(Graphics.height>400) ? 3 : 2
      ### Text replacement
      text.gsub!(/\\sign\[([^\]]*)\]/i) {   # \sign[something] gets turned into
        next "\\op\\cl\\ts[]\\w["+$1+"]"    # \op\cl\ts[]\w[something]
      }
      text.gsub!(/\\\\/,"\5")
      text.gsub!(/\\1/,"\1")
      if $game_actors
        text.gsub!(/\\n\[([1-8])\]/i) {
          m = $1.to_i
          next $game_actors[m].name
        }
      end
      loop do #c.edit Placement
        last_text = text.clone
        text.gsub!(/\\v\[([0-9]+)\]/i) { $game_variables[$1.to_i] }
        break if text == last_text
      end
      loop do #C.start Return Array
        last_text = text.clone
        text.gsub!(/\\a\[([0-9]+)\]\[([0-9]+)\]/i) { $game_variables[$1.to_i][$2.to_i] }
        break if text == last_text
      end #C.end
      text.gsub!(/\\pn/i,$Trainer.name) if $Trainer
      text.gsub!(/\\pm/i,_INTL("${1}",$Trainer.money.to_s_formatted)) if $Trainer
      text.gsub!(/\\n/i,"\n")
      text.gsub!(/\\\[([0-9a-f]{8,8})\]/i) { "<c2="+$1+">" }
      text.gsub!(/\\pg/i,"\\b") if $Trainer && $Trainer.male?
      text.gsub!(/\\pg/i,"\\r") if $Trainer && $Trainer.female?
      text.gsub!(/\\pog/i,"\\r") if $Trainer && $Trainer.male?
      text.gsub!(/\\pog/i,"\\b") if $Trainer && $Trainer.female?
      text.gsub!(/\\pg/i,"")
      text.gsub!(/\\pog/i,"")
      #C.takeout text.gsub!(/\\b/i,"<c3=3050C8,D0D0C8>")
      #C.takeout text.gsub!(/\\r/i,"<c3=E00808,D0D0C8>")
      text.gsub!(/\\[Ww]\[([^\]]*)\]/) {
        w = $1.to_s
        if w==""
          msgwindow.windowskin = nil
        else
          msgwindow.setSkin("Graphics/Windowskins/#{w}",false)
        end
        next ""
      }
      isDarkSkin = isDarkWindowskin(msgwindow.windowskin)
      text.gsub!(/\\[Cc]\[([0-9]+)\]/) {
        m = $1.to_i
        next getSkinColor(msgwindow.windowskin,m,isDarkSkin)
      }
      loop do #Custom Main Dialogue Command
        last_text = text.clone
        text.gsub!(/\\d\[([0-9]+)\]/i) { ($game_variables[50][$1.to_i]).to_s + ": " }
        break if text == last_text
      end #C.end
      loop do #Custom Char. Dialogue Speed
        last_text = text.clone
        text.gsub!(/\\s\[([0-9]+)\]/i) { ($game_variables[51][$1.to_i]) }
        break if text == last_text
      end #C.end
      loop do #Custom Char. Dialogue Border Style
        last_text = text.clone
        text.gsub!(/\\b\[([0-9]+)\]/i) { ($game_variables[52][$1.to_i]).to_s }
        break if text == last_text
      end #C.end
      loop do #Custom Main Test
        last_text = text.clone
        text.gsub!(/\\z\[([0-9]+)\]/i) { "/r" + ($game_variables[100][$1.to_i]) }
        break if text == last_text
      end #C.end
      loop do
        last_text = text.clone
        text.gsub!(/\\l\[([0-9]+)\]/i) {
          linecount = [1,$1.to_i].max
          next ""
        }
        break if text == last_text
      end
      colortag = ""
      if ($game_message && $game_message.background>0) ||
         ($game_system && $game_system.respond_to?("message_frame") &&
          $game_system.message_frame != 0)
        colortag = getSkinColor(msgwindow.windowskin,0,true)
      else
        colortag = getSkinColor(msgwindow.windowskin,0,isDarkSkin)
      end
      text = colortag+text
      ### Controls
      textchunks=[]
      controls=[]
      while text[/(?:\\(f|ff|ts|cl|me|se|wt|wtnp|ch)\[([^\]]*)\]|\\(csa|csb|g|cn|wd|wm|op|cl|wu|\.|\||\!|\^))/i]
        textchunks.push($~.pre_match)
        if $~[1]
          controls.push([$~[1].downcase,$~[2],-1])
        else
          controls.push([$~[3].downcase,"",-1])
        end
        text=$~.post_match
      end
      textchunks.push(text)
      for chunk in textchunks
        chunk.gsub!(/\005/,"\\")
      end
      textlen = 0
      for i in 0...controls.length
        control = controls[i][0]
        case control
        when "wt", "wtnp", ".", "|"
          textchunks[i] += "\2"
        when "!"
          textchunks[i] += "\1"
        end
        textlen += toUnformattedText(textchunks[i]).scan(/./m).length
        controls[i][2] = textlen
      end
      text = textchunks.join("")
      unformattedText = toUnformattedText(text)
      signWaitCount = 0
      signWaitTime = Graphics.frame_rate/2
      haveSpecialClose = false
      specialCloseSE = ""
      for i in 0...controls.length
        control = controls[i][0]
        param = controls[i][1]
        case control
        when "csa"#C.start Global ... dot dot dot pause speed
          msgwindow.textspeed = 30#C.end
        when "csb"#C.start Unused
          msgwindow.textspeed = 15#C.end
        when "op"
          signWaitCount = signWaitTime+1
        when "cl"
          text = text.sub(/\001\z/,"")   # fix: '$' can match end of line as well
          haveSpecialClose = true
          specialCloseSE = param
        when "f"
          facewindow.dispose if facewindow
          facewindow = PictureWindow.new("Graphics/Pictures/#{param}")
        when "ff"
          facewindow.dispose if facewindow
          facewindow = FaceWindowVX.new(param)
        when "ch"
          cmds = param.clone
          cmdvariable = pbCsvPosInt!(cmds)
          cmdIfCancel = pbCsvField!(cmds).to_i
          commands = []
          while cmds.length>0
            commands.push(pbCsvField!(cmds))
          end
        when "wtnp", "^"
          text = text.sub(/\001\z/,"")   # fix: '$' can match end of line as well
        when "se"
          if controls[i][2]==0
            startSE = param
            controls[i] = nil
          end
        end
      end
      if startSE!=nil
        pbSEPlay(pbStringToAudioFile(startSE))
      elsif signWaitCount==0 && letterbyletter
        pbPlayDecisionSE()
      end
      ########## Position message window  ##############
      pbRepositionMessageWindow(msgwindow,linecount)
      if $game_message && $game_message.background==1
        msgback = IconSprite.new(0,msgwindow.y,msgwindow.viewport)
        msgback.z = msgwindow.z-1
        msgback.setBitmap("Graphics/System/MessageBack")
      end
      if facewindow
        pbPositionNearMsgWindow(facewindow,msgwindow,:left)
        facewindow.viewport = msgwindow.viewport
        facewindow.z        = msgwindow.z
      end
      atTop = (msgwindow.y==0)
      ########## Show text #############################
      msgwindow.text = text
      Graphics.frame_reset if Graphics.frame_rate>40
      loop do
        if signWaitCount>0
          signWaitCount -= 1
          if atTop
            msgwindow.y = -msgwindow.height*signWaitCount/signWaitTime
          else
            msgwindow.y = Graphics.height-msgwindow.height*(signWaitTime-signWaitCount)/signWaitTime
          end
        end
        for i in 0...controls.length
          next if !controls[i]
          next if controls[i][2]>msgwindow.position || msgwindow.waitcount!=0
          control = controls[i][0]
          param = controls[i][1]
          case control
          when "f"
            facewindow.dispose if facewindow
            facewindow = PictureWindow.new("Graphics/Pictures/#{param}")
            pbPositionNearMsgWindow(facewindow,msgwindow,:left)
            facewindow.viewport = msgwindow.viewport
            facewindow.z        = msgwindow.z
          when "ff"
            facewindow.dispose if facewindow
            facewindow = FaceWindowVX.new(param)
            pbPositionNearMsgWindow(facewindow,msgwindow,:left)
            facewindow.viewport = msgwindow.viewport
            facewindow.z        = msgwindow.z
          when "g"      # Display gold window
            goldwindow.dispose if goldwindow
            goldwindow = pbDisplayGoldWindow(msgwindow)
          when "cn"     # Display coins window
            coinwindow.dispose if coinwindow
            coinwindow = pbDisplayCoinsWindow(msgwindow,goldwindow)
          when "wu"
            msgwindow.y = 0
            atTop = true
            msgback.y = msgwindow.y if msgback
            pbPositionNearMsgWindow(facewindow,msgwindow,:left)
            msgwindow.y = -msgwindow.height*signWaitCount/signWaitTime
          when "wm"
            atTop = false
            msgwindow.y = (Graphics.height-msgwindow.height)/2
            msgback.y = msgwindow.y if msgback
            pbPositionNearMsgWindow(facewindow,msgwindow,:left)
          when "wd"
            atTop = false
            msgwindow.y = Graphics.height-msgwindow.height
            msgback.y = msgwindow.y if msgback
            pbPositionNearMsgWindow(facewindow,msgwindow,:left)
            msgwindow.y = Graphics.height-msgwindow.height*(signWaitTime-signWaitCount)/signWaitTime
          when "ts"     # Change text speed
            msgwindow.textspeed = (param=="") ? -999 : param.to_i
          when "."      # Wait 0.25 seconds
            msgwindow.waitcount += Graphics.frame_rate/4
          when "|"      # Wait 1 second
            msgwindow.waitcount += Graphics.frame_rate
          when "wt"     # Wait X/20 seconds
            param = param.sub(/\A\s+/,"").sub(/\s+\z/,"")
            msgwindow.waitcount += param.to_i*Graphics.frame_rate/20
          when "wtnp"   # Wait X/20 seconds, no pause
            param = param.sub(/\A\s+/,"").sub(/\s+\z/,"")
            msgwindow.waitcount = param.to_i*Graphics.frame_rate/20
            autoresume = true
          when "^"      # Wait, no pause
            autoresume = true
          when "se"     # Play SE
            pbSEPlay(pbStringToAudioFile(param))
          when "me"     # Play ME
            pbMEPlay(pbStringToAudioFile(param))
          end
          controls[i] = nil
        end
        break if !letterbyletter
        Graphics.update
        Input.update
        facewindow.update if facewindow
        if $DEBUG && Input.trigger?(Input::F6)
          pbRecord(unformattedText)
        end
        if autoresume && msgwindow.waitcount==0
          msgwindow.resume if msgwindow.busy?
          break if !msgwindow.busy?
        end
        if Input.trigger?(Input::C) || Input.trigger?(Input::B)
          if msgwindow.busy?
            pbPlayDecisionSE if msgwindow.pausing?
            msgwindow.resume
          else
            break if signWaitCount==0
          end
        end
        pbUpdateSceneMap
        msgwindow.update
        yield if block_given?
        break if (!letterbyletter || commandProc || commands) && !msgwindow.busy?
      end
      Input.update   # Must call Input.update again to avoid extra triggers
      msgwindow.letterbyletter=oldletterbyletter
      if commands
        $game_variables[cmdvariable]=pbShowCommands(msgwindow,commands,cmdIfCancel)
        $game_map.need_refresh = true if $game_map
      end
      if commandProc
        ret=commandProc.call(msgwindow)
      end
      msgback.dispose if msgback
      goldwindow.dispose if goldwindow
      coinwindow.dispose if coinwindow
      facewindow.dispose if facewindow
      if haveSpecialClose
        pbSEPlay(pbStringToAudioFile(specialCloseSE))
        atTop = (msgwindow.y==0)
        for i in 0..signWaitTime
          if atTop
            msgwindow.y = -msgwindow.height*i/signWaitTime
          else
            msgwindow.y = Graphics.height-msgwindow.height*(signWaitTime-i)/signWaitTime
          end
          Graphics.update
          Input.update
          pbUpdateSceneMap
          msgwindow.update
        end
      end
      return ret
    end
    [/spoiler]
     
    Last edited:
    Got it working. Man. That was rough. It turned out most of it was from my inexperience with testing the code. It correctly works, but I thought it didn't because I also have a variable in the text which shows. The code below does what it's supposed to, although. the \w[v[x] won't work like \ts[v[x] but \w[\v[x]] does. is a bit worrisome. if have time to figure out why it does that lmk xD at this point though, I think everything is working. I'm ready to move on xD
    I insist, for me, \ts[\a[X][X] doesn't work, but \ts[\a[X][X]] does ^^"
    What's happening? XD

    Got everything working, and I learnt about 'class' the basic level anyway. Dang. It feels like I just level up a lot since these are everywhere, I just didn't realize.
    now all I have to put in each dialogue is \z[x] and it will do things. I follow that with whatever dialouge. i.e. \z[x] Welcome to the world of PKMN! = PROF.OAK: Welcome to the world of PKMN!
    I terms of organization and recalling, this will definitely be less strenuous on the dev.
    Yes indeed!
    I'm curious though, you were asking really good questions about what I would consider advanced programming, at least considering the average level of the forum, you already had the idea of making your code easy to fix in case you changed your mind in terms of names or whatever, and yet, you've just discovered classes and Object-Oriented Programming? The sequence of events seems to be inverted somehow ^^


    Man, coding is so cool.

    Yes indeed :D


    edit#3: So I'm wondering, let's say I have a class and then the game define that object to be = choice 4 via player choice event for example.
    when the player saves the game, quit the game, then loads the game. how does the game knows this class object is = choice 4? like do I need to do something special for the game to remember choice 4 when I load.

    Every object you manipulate in a script is stored somewhere in the RAM of your computer. It is stored in such a way that the object "knows" what its class is.
    However, be careful. Objects created in scripts are not generally stored when you save the game, because the objects are deleted after the script ends. For example, if you create an object in an Event script.
    So if you want your object to persist throughout the game, you have to store it in a bigger script that runs as the game runs; like the game itself (it's a big script after all). This is what happens when you store something in $game_variables. It's an object of the big script that runs the game, and that only stops when you quit the game.
    If you store the object in $game_variables[X], then the game will save it. (Here I am not sure) I believe that the save directly writes into a file the exact data that is stored in the RAM, so that it knows its class, and most importantly, it's directly accessible, it doesn't have to be created again and re-do all the computation.

    Hope I was clear ^^"
     
    Dang dude, thanks for testing that! I didn't even realize the functionality of \ts changes to work likes it's supposed to as well. All is solid! That was really bothering me, since sometimes, I had to remember to \ts[\a[x][x]] or \ts[a[x][x] depending on which function.

    Also thanks for explaining 'saves'. I read over where the game save/load and how it recalls the text thing. but unsure how I can add my own "Alright, so also save these class objects"
    Like if I define $game_variable[x] it's gonna save that for me. but if I make a new $char1 = "Example" I'm unsure how to get the game to save that for me so it'll load. But i'll figure it out in due time, there's like a priority list of what I should try to figure out first.

    So I'm starting to spend time going over the basics of Ruby, to build from the bottom up instead of building from midway haha.

    I think I'll figure out what I need to do eventually, but if you could see what I'm trying to do in the following code, it'd help a lot since I can't google what I desire as the way google interpret questions/matches.

    Code:
    class CharInfo
      attr_accessor :b
      attr_accessor :s#dialogue speed
      attr_accessor :nc#name color
      attr_accessor :n#name
      attr_accessor :dc#dialogue color
      
      def to_s
        "#{b}#{s}#{nc}#{n}#{dc}"
      end
      
    end
    
    $char1 = CharInfo.new()
    char1.b = "\\w[test4]"
    char1.s = "\\ts[0.77]"
    char1.nc = "\\c[7]"
    char1.n = "M.Maggie"
    char1.dc = "\\c[15]"

    in which char1 returns what it looks like. and the result is a string that is then used to execute the message system properly. (If see a simpler way to join all those string together other than "#{b}#{s}#{nc}#{n}#{dc}", lmk)

    as I found out, I couldn't '.join' an object's values like I could an array.

    so now. the issue is. as follow. and I'm unsure how to resolve, but I know what I desire the code to do.

    so this first line, is correct, it does what it's supposed to cause it's format good
    Code:
    $game_variable[1] = "bob"
     text.gsub!(/\\v\[([0-9]+)\]/i) { $game_variables[$1.to_i] }
    when I do \v[1] returns bob cause [$1.to_i] is interpreting itself as $game_variable's first parameter.

    I cannot get this to work with $char1 however, because it has no parameter. I need something along the line of the below, but idk how to tell the code to 'do the thing'.

    Code:
     text.gsub!(/\\z\[([0-9]+)\]/i) { $char[$1.to_s] }
    returns error (I know why, but idk enough about formatting to get it to how I'd like it. guidance would be much appreciated
    edit#1: I also finally downloaded an editor like Atom, so I can test code easier! haha I know. It's about time.
     
    Last edited:
    Dang dude, thanks for testing that! I didn't even realize the functionality of \ts changes to work likes it's supposed to as well. All is solid! That was really bothering me, since sometimes, I had to remember to \ts[\a[x][x]] or \ts[a[x][x] depending on which function.

    Also thanks for explaining 'saves'. I read over where the game save/load and how it recalls the text thing. but unsure how I can add my own "Alright, so also save these class objects"
    Like if I define $game_variable[x] it's gonna save that for me. but if I make a new $char1 = "Example" I'm unsure how to get the game to save that for me so it'll load. But i'll figure it out in due time, there's like a priority list of what I should try to figure out first.

    To save your new global variables, either you change the way the game is saved to include your custom variables, or you put them in another variable that is already saved. I suggest you do the latter.
    In general, scripters do this.
    • Extend the class PokemonTemp (which is the class, whose instance $PokemonTemp is storing anything you'd use in game, like animations, the complete Pokémon database, moves, etc.)
      Code:
      # Store the custom characters.
      class PokemonTemp
        attr_accessor :character_info
        
        def character_info
          @character_info = [] if !@character_info
          return @character_info
        end 
      end
      The function I'm defining sets the new attribute as a list containing all your instances of CharInfo (otherwise it's nil).

      So when you create a new instance, instead of writing what you did, you can do that instead:
      Code:
      char1 = CharInfo.new()
      char1.b = "\\w[test4]"
      char1.s = "\\ts[0.77]"
      char1.nc = "\\c[7]"
      char1.n = "M.Maggie"
      char1.dc = "\\c[15]"
      $PokemonTemp.character_info.push(char1)
      and then, is you want to access this character, you have to call $PokemonTemp.character_info[0]. Yeah, it's 0, and not 1, because list indices start at 0 and not 1 ^^" So you'll have to substract 1:
      Code:
       text.gsub!(/\\z\[([0-9]+)\]/i) { $PokemonTemp.character_info[$1.to_i - 1] }
      which should solve your problem ^^

      Now, if you allow me, I'd like to give you some good practice.
      1. If you start to write comments to explain your attributes like this:
        Code:
        class CharInfo
          attr_accessor :b
          attr_accessor :s#dialogue speed
          attr_accessor :nc#name color
          attr_accessor :n#name
          attr_accessor :dc#dialogue color
        then maybe you should change the names of your attributes to convey what they're for:
        Code:
        class CharInfo
          attr_accessor :window_skin
          attr_accessor :dialogue_speed
          attr_accessor :name_color
          attr_accessor :name
          attr_accessor :dialogue_color
        In general, you want to keep your code as readable as possible, because I assure you that in a month, you won't remember what you meant.


      2. Then, in a class, you'll also want to set the most information when you create an instance of the class. To do that, use a constructor, which is the special function that is called when you write Class.new(). In your case, you should write:
        Code:
        class CharInfo
          attr_accessor :window_skin
          attr_accessor :dialogue_speed
          attr_accessor :name_color
          attr_accessor :name
          attr_accessor :dialogue_color
          
          def initialize(ws, ds, nc, n, dc)
            @window_skin = ws
            @dialogue_speed = ds
            @name_color = nc
            @name = n
            @dialogue_color = dc
          end 
        end

        This way, instead of writing
        Code:
        char1 = CharInfo.new()
        char1.b = "\\w[test4]"
        char1.s = "\\ts[0.77]"
        char1.nc = "\\c[7]"
        char1.n = "M.Maggie"
        char1.dc = "\\c[15]"
        you would write:
        Code:
        char1 = CharInfo.new("\\w[test4]", "\\ts[0.77]", "\\c[7]", "M.Maggie", "\\c[15]")
        Note that the function is named "initialize" in the class definition but it is called via "new". This is a convention that depends on the language. Python or C++ do differently.


      3. You can also simplify the code for to_s. Computers are made to simplify your life. When you know that you will always write "\\w" for the window skin or "\\ts" for the speed, and only the value will change, maybe you should hide this in a function rather than writing everything yourself. So the constructor should not take the string "\\w[test4]" but rather the value "test4", and similarly for the rest. So when you make a new character, you should write:
        Code:
        char1 = CharInfo.new("test4", 0.77, 7, "M.Maggie", 15)
        Note that three of these values are no longer strings. I'll explain this just after.

        But when should you make the "\\w[]" and such appear? Answer: in the to_s function. You basically wrap all the data inside a string.

        Code:
          def to_s
            s = _INTL("\\w[{1}]", @window_skin)
            s += _INTL("\\ts[{1}]", @dialogue_speed)
            s += _INTL("\\c[{1}]", @name_color)
            s += _INTL("{1}", @name)
            s += _INTL("\\c[{1}]", @dialogue_color)
            return s
          end
        I am splitting the line to make it clear but you could make a one-liner if you want. Basically I am concatenating the different strings by inserting the data stored in the class. For example, the first line:
        Code:
            s = _INTL("\\w[{1}]", @window_skin)
        inserts the value stored in @window_skin in the place of the {1}, so that the result of _INTL("\\w[{1}]", "test4") is the string "\\w[test4]". The function _INTL allows you to turn a value into a string before inserting it in the target string, so you don't have to worry about converting numbers into string before.
        Now something that was also missing in your code, was the keyword "return". When you compute a function, you have to tell it to give you the result. Your function would have returned nothing otherwise. It would have computed something, but then it wouldn't have given you the result. "return" does that.

        For your information, the function to_s can be written in one line like this:
        Code:
          def to_s
            return _INTL("\\w[{1}]\\ts[{2}]\\c[{3}]{4}\\c[{5}]", @window_skin, @dialogue_speed, @name_color, @name, @dialogue_color)
          end
        What this does is it replaces {1} with @window_skin, {2} with @dialogue_speed, annd so on. The number X inside {X} should refer to the X-th argument given in _INTL.

      edit#1: I also finally downloaded an editor like Atom, so I can test code easier! haha I know. It's about time.
      Yes indeed ^^"
      However do you have the scripts accessible to Atom? Or maybe it can already read scripts from RPG Maker?
     
    Last edited:
    Edit#1. I'm trying to wrap my head around 'hash' now, I'm getting that the keys are symbols, and they're simply returning an array like other array. What I don't understand quite yet is the advantages of this besides the simplicity of being able to recall values indirectly via keys with exception like when .fetch

    Wondering if hash are globals. like once a hash is defined in one script, another script below it will also know.

    Edit#2. So I haven't implemented any of the new codes yet, I'm still looking at the possibilities and so on. My wonder at the moment is 'which is better'. to use hash or the class structure for 'this'. perhaps there's no like clear advantage or it's just preference. lmk thoughts if have any.

    I wrote this basic hash to start learning of them, which 'should' kind of do the thing.
    Code:
     char_info = {
      char1: [
        "\\w[test4]",
        "\\ts[0.77]",
        "\\c[7]",
        "M.Maggie",
        "\\c[15]"
      ],
      char2: [
        "\\w[test4]",
        "\\ts[0.77]",
        "\\c[7]",
        "M.Maggie",
        "\\c[15]"
      ]
    }
    print char_info[:char1].join #=>  \w[test4]\ts[0.77]\c[7]M.Maggie\c[15]                    #Success
    Cleaned up a bit more. Thinking I can just use code set with << to add another to the hash, then I'll be able to do the 'test4' without the other modifier.
    Code:
    char_info = {
      char1: [ "\\w[test4]", "\\ts[0.77]", "\\c[7]", "M.Maggie", "\\c[15]"  ],
      char2: [ "\\w[test4]", "\\ts[0.77]", "\\c[7]", "M.Maggie", "\\c[15]"  ],
    }
    print char_info[:char1].join   #=> success
    ~~

    Thanks for being a positive influence within the community regarding how you suggest information and changes. Ofc, all the time it takes to think about and type out those suggestions and so on. Since I think I'll be here a lot. I'd like to skip formality in sense of, I'm very thankful as it's so much easier to be able to interactively ask questions and have answers when it comes to learning something new.

    I've asked for advice on other platforms, and ofc I appreciate every wording. However, it's just a bit disheartening when someone else suggests in a mannerism that's more like "just don't do that, it's bad practice" there's just no information beyond that besides 'I have more experience, just listen to this logic', but I want to know why as that's more along the line of 'teaching a man to fish'.

    You clearly know I'm newer to code, so these huddles are just something most beginners go through. and I'm sure many other in the community appreciate the patience as well.

    I'm going to take the time to digest the new information and test it then come back with more questions 'cause that's the nature of this discipline or any haha.

    So regarding save, I realize I don't need to specifically save char.info, as the script will just generate them again when called, but I really did needed to know how to save my own variables as I plan to do a 'companionship' system in which the game will need to know 'affection' value of NPC in which players have influenced. Although initially, I did think that I needed to save all char.info Good times, good times. I didn't realize 'everything in RUBY is an object/class' yet.

    Definitely appreciate the suggestion on how to make life easier by only having to type 'test4' rather than '//w[test4]' I do the same regarding there's always a ": " before every dialogue so I don't have to spend the meniscal time typing ": " as that's within the code itself. So I was pretty happy when I saw that it can be utilized in this class mannerism as well.

    Rest below are just other irrelevant info.
    Spoiler:
     
    Last edited:
    Edit#1. I'm trying to wrap my head around 'hash' now, I'm getting that the keys are symbols, and they're simply returning an array like other array. What I don't understand quite yet is the advantages of this besides the simplicity of being able to recall values indirectly via keys with exception like when .fetch

    Wondering if hash are globals. like once a hash is defined in one script, another script below it will also know.
    Hashes are not global, they are deleted when the script ends, just like any other object ^^
    The advantage of hashes reside (in my opinion) in the way to access to its content. A hash is basically an array whose indices are strings or numbers (or other stuff). So it's easier to access data if you don't want to have to remember that index 0 is for the professor, index 1 is for the nurse, index 2 is blabla. It's again the difference between having attributes that are called c, s, or n instead of dialogue_color, dialogue_speed or name.
    The main disadvantage hashes have when compared to lists, is they are not "ordered" like a list. If you print a whole hash, you'll get the data in disorder (well, it's an order that makes sense to the computer, but not to humans). So if you add index "prof" and then index "nurse", the hash totally might order them "nurse" and then "prof". (You can check this by running a loop over your hash).


    Edit#2. So I haven't implemented any of the new codes yet, I'm still looking at the possibilities and so on. My wonder at the moment is 'which is better'. to use hash or the class structure for 'this'. perhaps there's no like clear advantage or it's just preference. lmk thoughts if have any.
    Hum, this will depend a lot on what you want to do with your class CharInfo. Your solution works.
    However, if you plan to make many functions around the same object, then you should do a class so as to "factor" the code inside one class, instead of having many separate functions. Besides, classes are made to give a "structure" to your data, and in my opinion, they are far easier to use than lists of data for which you have to remember "ok index 0 is this, index 1 is that" and so on.
    Coding is firstly about algorithmics ("how do I do this and that?") and secondly about readability ("how do I make it understandable?"). That way factorisation and structure are crucial in programming. That's why classes are so useful, and also why I can't code anymore without them! (Like, going back to C or VBA is a torture to me).


    Thanks for being a positive influence within the community regarding how you suggest information and changes. Ofc, all the time it takes to think about and type out those suggestions and so on. Since I think I'll be here a lot. I'd like to skip formality in sense of, I'm very thankful as it's so much easier to be able to interactively ask questions and have answers when it comes to learning something new.

    I've asked for advice on other platforms, and ofc I appreciate every wording. However, it's just a bit disheartening when someone else suggests in a mannerism that's more like "just don't do that, it's bad practice" there's just no information beyond that besides 'I have more experience, just listen to this logic', but I want to know why as that's more along the line of 'teaching a man to fish'.

    You clearly know I'm newer to code, so these huddles are just something most beginners go through. and I'm sure many other in the community appreciate the patience as well.
    :)


    So regarding save, I realize I don't need to specifically save char.info, as the script will just generate them again when called, but I really did needed to know how to save my own variables as I plan to do a 'companionship' system in which the game will need to know 'affection' value of NPC in which players have influenced. Although initially, I did think that I needed to save all char.info Good times, good times. I didn't realize 'everything in RUBY is an object/class' yet.
    Yes, the script will generate them again. Or, what I believe, it will put back into the RAM what was stored before (and I believe the function Marshal.dump simply just takes the data from the RAM and writes it to a file).
    Alos, I wanted to tell you that you should create your instances in a global script that will be run everytime you open the game, but rather, in an event script that will run only once.
    If you write in a script:
    Code:
    $PokemonTemp.character_info.push(CharInfo.new(x,x,x,x,x))
    $PokemonTemp.character_info.push(CharInfo.new(x,x,x,x,x))
    $PokemonTemp.character_info.push(CharInfo.new(x,x,x,x,x))
    then everytime you run the game, is will generate three copies of that value. But as you know now, the game saves what's stored in $PokemonTemp. So you'll stack more copies of the same data. It might be dangerous too, because it's memory usage that you're not aware of.
    It's better to put this in the Intro script (like when Prof Oak greets you), that will be run only once.


    Regarding 'Atom' editor, I downloaded the RUBY package so computer may run .rb extinction file and so Atom may run/understands .rb
    I've been just copy/paste back and forth between RPGxp and Atom, regarding sections of scripts I'd like to edit. As I use Atom, I'm like. Yeah... this is the way to edit. WOW. lol.
    Yes, and you can push it further :)
    I personnally don't use RPG Maker anymore for scripting, and I used to proceed like you do (copying/pasting).
    Now, I got rid of this copy/paste that slowly became annoying. Back-up your Scripts.rxdata, and download the scripts from here (there's a green button called "Code" and you can download the whole project). Merge this new folder with your game folder. I don't know Atom specifically, but there's probably an option to search a bunch of files (like Ctrl+Shift+F in RPG Maker). Now you can search inside the Data/Scripts folder. Now it should be easier to code and search code!
    Basically you are now using (updated) extracted scripts. These scripts are loaded in your game by the unique script that remains in the new Scripts.rxdata, so you don't have to worry about it anymore.

    Github is a repository, where you store and share the current state of a project, the development version of a project (here, Pokémon Essentials). So it's also the place to look if you want updates and bugfixes.


    And about AutoHotKey... I knew you weren't that "new" to coding :)
     
    Back
    Top