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 :)