[VX Ace] Actor Values on Notes

I am in need of answers for my big problem on making the notes being read.

So what I have right now is I am trying to make something about the actor through a note tag. I've read some part of the help file and it seems there's something I need which it doesn't cover. 

What I do to actually read the note on an actor is what I could say a beginner's way.

$data_actors[actor_id].note =~ /<note tag here>/iand somehow I manage to get errors along the way.

What I want:

First off is, I wanted to read integers on notes. For example, I placed a note tag on my actor Eric a note tag <Active: 90>

Now, I wanted to make a round check on all actors. I want to make a class that checks all actor's note tags. Now what happens after that is for it to assign each actor their values for those.

What do I mean with this?

I am adding an extra motion for the character. Such as:

<Active>

<Passive>

abilities. I want it that each actor should be assigned their own Active and Passive Values. 

So for example we have Eric, he has <Active: 80> and <Passive: 80>, we have Natalie with <Active: 80> and <Passive: 90>.

What I request:

I am requesting a big help to anyone who could show me or help me make this scriplet to check each actor's notes and assign them the following values. 

I am still a newb in using .scan and .collect methods as to I only have seen them via tutorials and other professional scripter's work. So I request / beg of you people of the community to please guide me through this.

Thank you in advance and for helping me get through this problem.
You have asked request multiple times already. Not sure what's the point in begging for another one. Haha.

First of all, you need to learn regular expression (regex).

This is an example from my latest public script.

The notetag:

<Ingr>stone: (1,2)wood: (5,12)</Ingr>The reader:

$data_items.each do |item| item.note.split(/[\r\n]+/).each do |nt| case nt when /<(?:ingr?)>/i; @gi = true when /<\/(?:ingr?)>/i; @gi = false else if @gi @pr << $data_items[item.id] unless @pr.include?($data_items[item.id]) $data_items[item.id].get_ingr(nt) end end endendThe following code from above:

item.note.split(/[\r\n]+/) It will split the notetag into lines, and when it encounter, the proper notetag:

when /<(?:ingr?)>/iIt will turn a switch on, for further instruction.

When the switch is on, what you get from the notetag is:

stone: (1,2)wood: (5,12)This is the simplified further instruction

def get_ingr(string) @ingr = Hash.new {|h,k| h[k]=[]} if @ingr.nil? @ingr[string[/.*?(?=[:])/i]] << string[/(?<=[(]).*?(?=[,])/].to_i << string[/(?<=[,]).*?(?=[)])/].to_i endThis following line:

[string[/.*?(?=[:])/i]]Will get the anything up to ":" sign.

This following line:

string[/(?<=[(]).*?(?=[,])/].to_iWill get anything from "(" up to ",", then turn it into integer (base 10)

This following line:

string[/(?<=[,]).*?(?=[)])/].to_iWill get anything from "," up to ")", then turn it into integer (base 10)

so if you were do to:

p the_item_with_the_notetag_above.ingrYou will get:

{"stone" => [1,2], "wood" => [5,12]}And to grab the value from the array, you can do

the_item_with_the_notetag_above.ingr["stone"][0] #=> 1Now, how to use that for your problem:

1. Get all actors

2. Scan and Store data on each actor notetag

3. Use stored data to do magic

For step #1:

$data_actorsStore the info you need.

For step #2:

$data_actors.each { |a| if a.note.match(/<Active:/) #if the notetag has <Active: #do further scanning to store end}This is the class for actor:

class RPG::Actor < RPG::BaseItemYou can insert a method there to read the notetag.

For ex:

class CustomClass def initialize $data_actors.each { |a| if a.note.match(/<Active:/) #if the notetag has <Active: a.getThoseNotetag end } endendclass RPG::Actor < RPG::BaseItem attr_accessor :storing def getThoseNotetag @storing = 0 if @storing.nil? @storing = @note[/(?<=[<Active: ]).*?(?=[>])/].to_i #Grab anything starting from #"<Active: " to ">" and then #turn it into integer endendThen Step #3:

When you want to use it, u can retrieve the data via:

Code:
$data_actors[actor_id_here].storing
What errors?
Okay, I copied the script and tried to test it. When I went into the event and did this:

p $data_actors[1].storingit somehow says nil which should not be since I added the note tag <Active: 90> on my actor. is there something I am missing?
If you simply copied the script, I bet the notetag reading (getThoseNotetag) was never run...

you might want to do it this way (I think a bit similar to how Hime does it, loads them only when needed)

Code:
class RPG::Actor < RPG::BaseItem  def getThoseNotetag    @storing = @note[/(?<=[<Active: ]).*?(?=[>])/].to_i  #Grab anything starting from                                                          #"<Active: " to ">" and then                                                          #turn it into integer    @storing = 0 if @storing.nil?  end  def storing    getThoseNotetag if @storing.nil?    return @storing  endend
or you might actually need to do it this way (on Game_Actor instead of RPG::Actor)
Code:
class Game_Actor  def getThoseNotetag    @storing = @note[/(?<=[<Active: ]).*?(?=[>])/].to_i  #Grab anything starting from                                                          #"<Active: " to ">" and then                                                          #turn it into integer    @storing = 0 if @storing.nil?  end  def storing    getThoseNotetag if @storing.nil?    return @storing  endend
Thanks for clearing that out. But somehow, it only returns me 0. It should have been 90, as to it is what i indicated in the note tag.
then maybe his notetag check is wrong

try this

Code:
class Game_Actor  def getThoseNotetag    @storing = 0    if self.note =~ /<Active:(.*)>/i      @storing = $1.to_i    end  end  def storing    getThoseNotetag if @storing.nil?    return @storing  endend
So I went to PM someone from another forum and he said this part

if self.note =~ /<Active🙁.*)>/ishould be changed with this:

if self.note =~ /<Active:\s?(\d+)>/ihowever, I am still curious as to it somehow does not give me the right value. Am I still missing something?
Did you print out your match results?
Oh, ya, it's 0 due to [] only accept 1. Input.

Change the notetag into this:

@note[/(?<=<Active: ).*?(?=[>])/].to_iEdit:

If you want to check ruby regex, don't trust online compiler / tester yet. Download the ruby library 1.9.2 [that's what Ace is using]. Where to get the 1.9.2? Go to the main ruby website, on the download section, there are mirrors. click them and fine the closest server. If they don't have 1.9.2, try another server.
Online ruby regex parsers are presumably using Ruby. What's wrong with them? I use them all the time.
Final Result:

class RPG::Actor < RPG::BaseItem def getThoseNotetag @storing = @note[/(?<=<Active: ).*?(?=[>])/].to_i #Grab anything starting from #"<Active: " to ">" and then #turn it into integer @storing = 0 if @storing.nil? end def storing getThoseNotetag if @storing.nil? return @storing endendprints me 90 🙂

Thanks to all of you who helped me achieve this. its working now thanks to Mike and Shana. It seems that the only problem was that the note was not being recognized.

Mods can close this now. 😀
@tsukihime

They can be funky on displaying results sometimes, so I prefer to go with the ruby cmd much safer. .-.

Original thread: https://forums.rpgmakerweb.com/threads/vx-ace-actor-values-on-notes.24102/