Adding info to the Status Scene using Simple Notetags Grabber by Estriole

Bethins

Villager
Member
Joined
Nov 4, 2012
Messages
69
Reaction score
0
First Language
English
Primarily Uses
Here is a pic of what I'm trying to do...

image.jpg

Only instead of "Gender" and "Race", I'd like to display the corresponding info located in the actors Notetag in this picture...

image.jpg

I put this together based on the default scripts...

#==============================================================================# ** Window_Base#------------------------------------------------------------------------------# This is a super class of all windows within the game.#==============================================================================class Window_Base < Window #-------------------------------------------------------------------------- # * Draw Simple Status #-------------------------------------------------------------------------- alias bluemith_draw_actor_simple_status draw_actor_simple_status def draw_actor_simple_status(actor, x, y) bluemith_draw_actor_simple_status(actor, x, y) draw_actor_race(actor, x, y + line_height * 2) draw_actor_gender(actor, x, y + line_height * 3) end def draw_actor_race (actor ,x ,y) @actor_race = "Race" draw_text_ex(x, y, @actor_race) end def draw_actor_gender (actor ,x ,y) @actor_gender = "Gender" draw_text_ex(x, y, @actor_gender) endendWhat I'm struggling with is how to make the script grab the note tag and display the proper information... I'm using this script, www.rpgmakervxace.net/topic/10545-est-simple-notetags-grabber/, but as I am a noob scripter, I just can't figure out how it should be written.Thanks!!

Edit, I have no idea why the editor did that it my code or why it made my pics so blurry...

#==============================================================================

# ** Window_Base

#------------------------------------------------------------------------------

# This is a super class of all windows within the game.

#==============================================================================

class Window_Base < Window

#--------------------------------------------------------------------------

# * Draw Simple Status

#--------------------------------------------------------------------------

alias bluemith_draw_actor_simple_status draw_actor_simple_status

def draw_actor_simple_status(actor, x, y)

bluemith_draw_actor_simple_status(actor, x, y)

draw_actor_race(actor, x, y + line_height * 2)

draw_actor_gender(actor, x, y + line_height * 3)

end

def draw_actor_race (actor ,x ,y)

@actor_race = "Race"

draw_text_ex(x, y, @actor_race)

end

def draw_actor_gender (actor ,x ,y)

@actor_gender = "Gender"

draw_text_ex(x, y, @actor_gender)

end

end
 
Last edited by a moderator:

Evgenij

Veteran
Veteran
Joined
Aug 28, 2013
Messages
349
Reaction score
100
First Language
German
Primarily Uses
N/A
You could try something like this:

class Game_Actor def gender @gender ||= /<gender: *(\w+) *>/i =~ actor.note ? $1 : "" end def race @race ||= /<race: *(\w+) *>/i =~ actor.note ? $1 : "" endendYour draw_actor_gender method would then look like this:

def draw_actor_race(actor ,x ,y)  draw_text_ex(x, y, actor.race)end*edit*

Have not seen that you use a notetag grabber script.

I dont know how you can make it work with that script, since I dont looked at it.
 
Last edited by a moderator:

Bethins

Villager
Member
Joined
Nov 4, 2012
Messages
69
Reaction score
0
First Language
English
Primarily Uses
Excellent!! Could you explain to me how that works? I'm learning as I go and I would love to understand all that means so I can use it for other things in the future.

@gender ||= /<gender: *(\w+) *>/i =~ actor.note ? $1: ""

If you could just explain that line, you will be my hero for the day!
 

Evgenij

Veteran
Veteran
Joined
Aug 28, 2013
Messages
349
Reaction score
100
First Language
German
Primarily Uses
N/A
The expression

||=is short for: 

@gender || @gender = /<gender: *(\w+) *>/i =~ actor.note ? $1: ""# or this:if @gender   @genderelse  @gender = /<gender: *(\w+) *>/i =~ actor.note ? $1: ""endSo it kind of checks if @gender is initialized and if it is it will return @gender otherwise it will initialize @gender

This line is a ternary operator(condition ? true_case : false_case):

/<gender: *(\w+) *>/i =~ actor.note ? $1 : ""can be translated to this:

if /<gender: *(\w+) *>/i =~ actor.note  return $1else  return ""endThis is a regular expression:

/<gender: *(\w+) *>/iGoogle it to understand what the expression means, you can use rubular.com to experiment with expressions.

And this line:

/<gender: *(\w+) *>/i =~ actor.noteWill search the actors note for this: <gender: text> and will save the result in $1.

So you can write the whole line(@gender ||= /<gender: *(\w+) *>/i =~ actor.note ? $1 : "") like this:

Code:
if @gender  return @genderelsif /<gender: *(\w+) *>/i =~ actor.note  @gender = $1else # if the regular expression dont find a match  @gender = ""end
 
Last edited by a moderator:

Bethins

Villager
Member
Joined
Nov 4, 2012
Messages
69
Reaction score
0
First Language
English
Primarily Uses
That's amazing! Thanks :)

How would I modify this to read a Notetag with a space? <race: Half Elf>
 

Evgenij

Veteran
Veteran
Joined
Aug 28, 2013
Messages
349
Reaction score
100
First Language
German
Primarily Uses
N/A
You could use these expressions for example:

/<gender: *([a-zA-Z ]+) *>/i/<gender: *(.+) *>/iThe first one would be able to catch unlimited words with whitespaces between "<gender:" and ">"

The second one would catch everything between  "<gender:" and ">"

So something like this:

<gender: hero$12>

would only work with the second expression,
 

Bethins

Villager
Member
Joined
Nov 4, 2012
Messages
69
Reaction score
0
First Language
English
Primarily Uses
That's awesome! Thanks a ton! You have opened up quite a few doors for me.
 

Users Who Are Viewing This Thread (Users: 0, Guests: 1)

Latest Threads

Latest Profile Posts

tomorrow I'ma go on a cruise for the first time ever... lets hope I'll survive the experience!
Omg! 8 years in this forum :o
Ksi
Streaming the last of the RMN Valentiny event games so feel free to drop on by and watch me cry (whether that's from laughter, rage or sheer pain, who knows?)
Today I went to sleep without setting an alarm, so I could sleep more than 2 hours. I woke up after 2 hours.
Sigh :( ... displaying numbers representing the stats of the PCs for a custom menu in rm2k3 is haaaaaaaarrrd!!! DX

Forum statistics

Threads
94,306
Messages
919,804
Members
124,054
Latest member
stevechtrs
Top