Ruby/RGSSx questions that don't deserve their own thread

Definitely an option and very easy to do, but if there was already a built-in function or it's relatively easy to write up, it would give more flexibility and open many other possibilities.

To reiterate the question since it was pushed to the last page:

Is it possible to fade-IN BGS?
Hello, i have an array in this way:

data = [[3,10],[7,20],[15,29]]

The first term is the id player and the second is the quantity of money that he owns.

How can i find, the array position of the id player 7 for example (in this case position 1), considering that i dont know how much money he owns (variable)?
data.index { |value| value[0] == 7 }

Will return nil if there is no element with an id of 7.
Hello, i have an array in this way:

data = [[3,10],[7,20],[15,29]]

The first term is the id player and the second is the quantity of money that he owns.

How can i find, the array position of the id player 7 for example (in this case position 1), considering that i dont know how much money he owns (variable)?
This will return the second value in the array:

Code:
data = [[3,10],[7,20],[15,29]]data.each {|i| return i[1] }
Definitely an option and very easy to do, but if there was already a built-in function or it's relatively easy to write up, it would give more flexibility and open many other possibilities.

To reiterate the question since it was pushed to the last page:

Is it possible to fade-IN BGS?
I would think so. You may need to write your own mini scriptlet for it, but you could probably write something that more or less:

  • opens the file
  • volume set to a variable
  • begins playing, using the volume variable for initial loudness
  • while |the current volume| is not as loud as |the max volume|
  • set a variable equal to the current position in the track (Audio.bgs_pos) <= New in RGSS3, won't work elsewhere.
  • increase volume variable
  • make it play from the position you just recorded above
  • repeat until current volume is the same as max volume.
What would be the best way to create an array containing the averages of all party member stats?

The long way would be something like this:

averages = [0,0,0,0,0,0,0,0]$game_party.all_members.each do |actor|  for i in 0...7    averages += $data_classes[actor.class_id].params  endendfor i in 0...7  averages /= $game_party.all_members.sizeend
The above probably wouldn't work correctly and would need to be tweaked a bit.  But I need the stats without any modifications from weapons or armor.
Is that for Ace or another Maker? I'm asking because I'm not familiar with accessing the actor's current parameters without having to pass their level to the table as well.

Anyway, this is a (terse, relatively-hard-to-understand) version of what you have above that should work with Ace. Of course, I'm... writing this from a computer that doesn't actually have Ace installed on it, so this is completely untested and has a high probability of exploding as a result of that. Take it with about two pounds of salt.

avg = Array.new(7) { 0 }$game_party.all_members.each do |a| avg.size.times { |i| avg += $data_classes[a.class_id].params[i, a.level] }endavg.map! { |e| e / $game_party.all_members.size.to_f }This will give you accurate averages though, unlike your version above (which will perform the division without floating point values, which, of course, rounds the outcome).And just so you know, I don't think that this would perform any better than the version that you've already posted.
"Probably wouldn't work"?

Can you think up some tests to either find bugs or increase your confidence?

It can help to extract the core problem. You know, create a related data structure containing some test data you have crafted. Then calculate in hand what you expect the result to be.

Now you are ready to look into the algorithm where you can obtain fast response. It is of course not all-encompassing, but it usually pretty helpful.

*hugs*

Edit: Didn't noticed you Solistra =o
For the record, what Zeriab just described is basically how I wrote the little bit of Ruby that I just did. From my memory of how Ace uses actors, the party, and classes, the code that I wrote works -- but I built mock classes from memory, so again, take what I wrote with at least two pounds of salt.
Thank you both.  Yes, something like the shortened form you have is exactly what I was after.


I was also just typing from memory, as I didn't have Ace open at the time and had to leave home shortly, so what I wrote was more of a pseudo "this are the steps I should take" for doing it "the long way".  The block format, in particular, was what I knew I'd struggle with.  And the different array methods available (I've never heard of array.map! until now).


I'll give it a go Solistra, and I should be able to work around any remaining issues.

And just so you know, I don't think that this would perform any better than the version that you've already posted.
Very interestng ...
And the different array methods available (I've never heard of array.map! until now).
In that case, use the majority of the code above to get an overall average of the party's total stats with this:

Code:
avg.reduce(:+) / $game_party.all_members.size.to_f
...and remember to giggle when you realize that 🙂+) looks like a face.
I want to know more about note-tags. Can someone dearly explain to me how notetags work? I want to know the best approach on how to actually make and access a notetag, the conditions that you can run to it, or how is it readily available working once you start your game.

Specifically something like this for example:

On the enemies tab, I placed a notetag <type: poisonous>

so the condition I want to happen is that: when an enemy on the database is tagged with <type: poisonous> then whenever you enter the battle, (I don't know if its on BattleManager or Scene_Battle to access it), a chance that that monster's attack is poisonous, say for example 35% chance. I asked this since I really want to learn how it works, and placing state poison on each monster's attack is a bit of pain.

An advanced thank you for the person who would answer this.
Note tags are used in whatever way the scripter wants to use them. You write the script to suit your own requirements. Take a look at a few that use them already to see how they're read, and see if you can adjust it to do what you want.

If you can't do it yourself, then you probably really should be posting a new thread in Script Requests, as you're asking someone to make a system for you (or to help you make it), which means it's deserving of its own thread 😉
#===============================================================================class RPG::BaseItem#=============================================================================== # Base Item is the superclass of ALL database items ! def your_notetag_checking_method  if self.note =~ /<your_note🙁.*)>/i  # (.*) "catches" the information in the notetag eg <your_note: 1> it would get # the info "1"    return $1.to_i # returns the first "caught" information, ie "1".  else   return 0 # default data to return  end end end # You can then access this notetag anywhere, providing you first access the database# item, eg. actors, enemies, classes, skills...# Here is an example of how to check the note when the damage process is being# executed.. #===============================================================================class Game_Battler < Game_BattlerBase#===============================================================================  alias :random_ALIAS_name  :execute_damage  def execute_damage(user)  p "NOTETAG WAS READ FOR #{self}" if self.note_check != 0    random_ALIAS_name(user) # Run original method  endend#===============================================================================class Game_Actor < Game_Battler#===============================================================================  def note_check # Gets database notetag return actor.your_notetag_checking_method  endend#===============================================================================class Game_Enemy < Game_Battler#===============================================================================  def note_check # Gets database notetag return enemy.your_notetag_checking_method  endendput that into your script editor, give the notetag <your_note: 1> to an actor or enemy and deal damage, you will get info displayed in the console window showing that the notetag has been read.

then just change the methods to suit your needs.

There are many many ways of reading / using notetags , yout should try out a few until you are happy with a certain way of doing it.

Personally i pre-load the notetags using methods very similar to yanfly's.

But thats just personal preference...
Do you know why I admire you, @Dekita? You can explain everything by just putting on the codes!

I really appreciate this and I am learning the other syntax I have to, and I just ran on the notes thing and I wanted to know how to make them happen.

I was stressed on getting references from made scripts with notetags because it is already complex that they had this split function. I understand gsub but splitting and other things, not yet ATM.

Again, thank you Dekita 😀
I want to know more about note-tags. Can someone dearly explain to me how notetags work? I want to know the best approach on how to actually make and access a notetag, the conditions that you can run to it, or how is it readily available working once you start your game.
Here is some sort of tutorial: http://himeworks.wordpress.com/2013/04/14/basic-guide-to-working-with-note-tags/
Do you know why I admire you, @Dekita? You can explain everything by just putting on the codes!
funny thing is, a few months ago i was asking a ridiculous amount of questions, i even asked this exact same question

("how do notetags work")

if it wasnt for the people from this and other forums i would still be 100% clueless as to the correct way to do certain things 😛

Also Tsukihime's Tutorial will most probably explain things in much more depth than i did

(pretty sure it was Tsuki and mobychan who helped me understand notetags better ) 😀

edit:

Also, .split(//) method simply splits the nottag in between any character inside the // eg split(/./) would split the note every time a . was found within it. 
Thanks both to Tsukihime and Dekita. Now reading <3
Also, .split(//) method simply splits the nottag in between any character inside the // eg split(/./) would split the note every time a . was found within it.
No, that's just specifying what to split on using regex.You need to write

/\./if you want to split on the .'s since that character is reserved in regex.I also tried

a = "123.456"p a.split(/./)And it printed the empty list for whatever reason.Now I'm not sure why since I told it to split on any character. Maybe it can't decide.

However, doing this

Code:
a = "123.456"p a.split(//)
printed out

Code:
["a", "b", "c", ".", "d", "e", "f"]
That would be because whatever you define in split is removed upon splitting, as it's considered simply a divider. Splitting it with /./ as an argument will *always* return an empty list. As an example:

a = "1,2,3,4"p a.split(/,/)
Would return ["1", "2", "3", "4"]. If I did this:

a = "1, 2, 3, 4"p a.split(/,/)
I would get ["1", " 2", " 3", " 4"]

Your second example, splitting with //, tells it to split when there is no character - essentially after every character in the string.

Original thread: https://forums.rpgmakerweb.com/threads/ruby-rgssx-questions-that-dont-deserve-their-own-thread.150/