Using variable textcodes in Sixth's Biography/Morality System

Status
Not open for further replies.

Bazinioli

Advanced User
Member
Joined
Oct 7, 2014
Messages
26
Reaction score
5
First Language
English
Primarily Uses
So, I've been using the above titled script by Sixth, and it's really perfect for what I need, but I've run into a snag.

The script allows you to add things like age, height, weight, etc. to the biography section, but my problem is that time progresses in my game, and so all of those (particularly age) are liable to need updating throughout the game. I figured it would be easiest to just store the various ages into a variable, but so far I haven't figured out a way to get variables to display correctly. So far I've tried:
:age => "\v[1]",
and
:age => $game_variables[1],

Standard VXA text codes like \v[x] don't work, though, and the second one just crashes the game when trying to start playtest.

As far as I can tell, there's no script calls to update the default data, only ones to add biography pages and check moralities, so I'm not really sure where to go from here. Any help would be greatly appreciated!

EDIT:
changed the thread title from "using variables" to "variable textcodes" as I think the former may have been misleading
 
Last edited:

gundambison

Regular
Regular
Joined
Jun 11, 2014
Messages
142
Reaction score
33
First Language
English
Primarily Uses
when crash.. no error showing ?
 

Roninator2

Gamer
Regular
Joined
May 22, 2016
Messages
5,122
Reaction score
1,502
First Language
English
Primarily Uses
RMVXA
The original data is in a string format so it is not going to change the way you are trying

You can add in a change on line 1441 in the original script.
under def refresh
just above draw_bio_info(:age,Actor_Info_Setup[actor.id][:age])
add in age = (Actor_Info_Setup[actor.id][:age].to_i + $game_variables[3]).to_s
then change the draw age line to draw_bio_info(:age,age)

Change the variable number as you see fit.
This will take the string number and convert it to an integer then add the variable number and convert back to string.
 

Bazinioli

Advanced User
Member
Joined
Oct 7, 2014
Messages
26
Reaction score
5
First Language
English
Primarily Uses
You can add in a change on line 1441 in the original script.
under def refresh
just above draw_bio_info(:age,Actor_Info_Setup[actor.id][:age])
add in age = (Actor_Info_Setup[actor.id][:age].to_i + $game_variables[3]).to_s
then change the draw age line to draw_bio_info(:age,age)

Change the variable number as you see fit.
This will take the string number and convert it to an integer then add the variable number and convert back to string.
Correct me if I'm wrong, but this works by adding the variable's amount to the default defined :age, yeah? That'll work for if a year or so passes at a time, but won't really work for situations where only one or two characters' birthdays have passed. Hence why I was trying to define the variable in the Actor_Info_Setup section (line 976) so that I could use individual variables.

Also, that solution can't be used for things like height/weight/full name, all of which couldn't use integers anyway.

(I should also note that I'm using string variables with the $game_variables[x] = "text" script call, not integer ones like the default control variable uses)
 

Roninator2

Gamer
Regular
Joined
May 22, 2016
Messages
5,122
Reaction score
1,502
First Language
English
Primarily Uses
RMVXA
that solution can't be used for things like height/weight/full name, all of which couldn't use integers anyway.
You were specifying age so that's what I gave you. Why would you use a variable for height? Does the character get their legs chopped off and you have change the height?

Hence why I was trying to define the variable in the Actor_Info_Setup section (line 976)
then we can change the draw section to use variables. that wouldn't be hard, but what data will be in variables? There is no need to have everything in different variables, but if that's what you want then you would change each line to something like this
draw_bio_info(:age,$game_variables[Actor_Info_Setup[actor.id][:age]])
then the data can't be in string format it would have to be an integer
 

Bazinioli

Advanced User
Member
Joined
Oct 7, 2014
Messages
26
Reaction score
5
First Language
English
Primarily Uses
You were specifying age so that's what I gave you. Why would you use a variable for height? Does the character get their legs chopped off and you have change the height?
....Because people get taller as they get older? My actors are teenagers at the beginning of the game. I'd like to be able to track changes like that and have said changes reflected in dialogue and menus.
then we can change the draw section to use variables. that wouldn't be hard, but what data will be in variables? There is no need to have everything in different variables, but if that's what you want then you would change each line to something like this draw_bio_info(:age,$game_variables[Actor_Info_Setup[actor.id][:age]])
then the data can't be in string format it would have to be an integer
Also, I can't interpret how that code you provided would be used? That appears to be very different from what I'm trying to do, so I'll try and re-explain better:

Using the script call I gave earlier ($game_variables[x] = "text"), string can be stored in variables instead of integers. Using that in combination with the textcode \v[x] allows you to display strings of text in dialogue and menus that you stored in the variable. Like so:

1676023855081.png
1676023894498.png
1676023908194.png
This is really convenient as it means that, no matter where/when the variable gets updated, every textbox that mentions this particular character's height will be consistent without needing to use conditionals, alternate textboxes, etc. Age in specific doesn't matter if it's integer or string, but for anything else that may change, like height/weight which have units of measurement (kg, cm, 0'0", etc.), or if someone's name is revealed to be an alias and changes part way through, integer variables don't work.

So if a character's height changes from 5'5" to 5'7", or they have a birthday and go from 17 to 18, you just have to change one variable in either case and it'll update for every textbox it's mentioned in.

So what I'm aiming for is to be able to go from this...
1676025682847.png
1676025375926.png
1676025413133.png
To this...
1676025753942.png
1676025621377.png
1676025606893.png
...By just updating a few variables associated with the character in an event. Using variables like this in dialogue and other menus work fine, but I haven't been able to find a way to use variables in the same fashion in the biography menu, hence this thread was made.

Trying to use the textcodes to display the variables gives this result:
1676026244645.png
1676026351601.png
or this result:
1676026402011.png
1676026425080.png

and putting "$game_variables[1]" in quotation marks predictably just makes it display as-is
1676026517907.png

Granted, I knew :age => game_variables[1], probably wouldn't work, but I'm stumped as to why the \v[1] textcode doesn't work in this instance. It works everywhere else there's text in the game, from what I can tell.
 

Roninator2

Gamer
Regular
Joined
May 22, 2016
Messages
5,122
Reaction score
1,502
First Language
English
Primarily Uses
RMVXA
Ruby:
  def refresh(actor,page)
    contents.clear
    if Show_Data.include?(:portrait) && !$bio[actor.id].port.nil?
      draw_actor_portrait(actor) if $bio[actor.id].port != ""
    end
    draw_bio_info(:custom1,Actor_Info_Setup[actor.id][:custom1])
    draw_bio_info(:age,$game_variables[Actor_Info_Setup[actor.id][:age]].to_s)
    draw_bio_info(:gender,Actor_Info_Setup[actor.id][:gender])
    draw_bio_info(:weight,Actor_Info_Setup[actor.id][:weight])
    draw_bio_info(:height,$game_variables[Actor_Info_Setup[actor.id][:height]].to_s)
    draw_bio_txt_page(actor,page) if Show_Data.include?(:bio_text)
    draw_full_bio_txt(actor,:bio_text,page) if Show_Data.include?(:bio_text)
    draw_morality_bar(actor) if Show_Data.include?(:morality)
    draw_moral_text(actor) if Show_Data.include?(:morality)
  end
Ruby:
  Actor_Info_Setup = { # <-- No touchy-touchy!
    1 => {
      :portrait => ["bust1-A",[325,0],255],
      :pic => ["Actor2test",2],
      :age => 16,
      :gender => "Male",
      :weight => "81 Kg",
      :height => 17,
      :morality => 0,
      :custom1 => "Danny Salrock",
      :bio_text => [
            # 1st page.
             ["Marveck Academy 1st class protic scientist.",
              "He was the one who invented the protic stones.",
              "Despite his invaluable product, the world forgot him.",
              "Currently searching for the legendary Polarities.",
              "Very stubborn person with high level of arrogance.",
              "Food is the only thing that can melt his heart."],
            # 2nd page.
             ["Let's test the second page, alright?",
              "So, apparently, this is the second page.",
              "Third line, etc, etc yadda yadda..."],
        ],
    },
1676031031941.png
1676031229701.png
1676031048002.png
1676031253389.png
line 1294 def draw_bio_info(sym,data=nil,pos2=nil)

add in a line above i = InfoPos_Setup[sym]

data = convert_escape_characters(data)

Then the code as you were trying will work like this
Ruby:
  Actor_Info_Setup = { # <-- No touchy-touchy!
    1 => {
      :portrait => ["bust1-A",[325,0],255],
      :pic => ["Actor2test",2],
      :age => "\\V[16]",
      :gender => "Male",
      :weight => "81 Kg",
      :height => "\\V[17]",
Notice the double \
 
Last edited:

Bazinioli

Advanced User
Member
Joined
Oct 7, 2014
Messages
26
Reaction score
5
First Language
English
Primarily Uses
Ruby:
  def refresh(actor,page)
    contents.clear
    if Show_Data.include?(:portrait) && !$bio[actor.id].port.nil?
      draw_actor_portrait(actor) if $bio[actor.id].port != ""
    end
    draw_bio_info(:custom1,Actor_Info_Setup[actor.id][:custom1])
    draw_bio_info(:age,$game_variables[Actor_Info_Setup[actor.id][:age]].to_s)
    draw_bio_info(:gender,Actor_Info_Setup[actor.id][:gender])
    draw_bio_info(:weight,Actor_Info_Setup[actor.id][:weight])
    draw_bio_info(:height,$game_variables[Actor_Info_Setup[actor.id][:height]].to_s)
    draw_bio_txt_page(actor,page) if Show_Data.include?(:bio_text)
    draw_full_bio_txt(actor,:bio_text,page) if Show_Data.include?(:bio_text)
    draw_morality_bar(actor) if Show_Data.include?(:morality)
    draw_moral_text(actor) if Show_Data.include?(:morality)
  end
Ruby:
  Actor_Info_Setup = { # <-- No touchy-touchy!
    1 => {
      :portrait => ["bust1-A",[325,0],255],
      :pic => ["Actor2test",2],
      :age => 16,
      :gender => "Male",
      :weight => "81 Kg",
      :height => 17,
      :morality => 0,
      :custom1 => "Danny Salrock",
      :bio_text => [
            # 1st page.
             ["Marveck Academy 1st class protic scientist.",
              "He was the one who invented the protic stones.",
              "Despite his invaluable product, the world forgot him.",
              "Currently searching for the legendary Polarities.",
              "Very stubborn person with high level of arrogance.",
              "Food is the only thing that can melt his heart."],
            # 2nd page.
             ["Let's test the second page, alright?",
              "So, apparently, this is the second page.",
              "Third line, etc, etc yadda yadda..."],
        ],
    },
View attachment 252908
View attachment 252910
View attachment 252909
View attachment 252911
Oh wow! Thank you! :)
I wasn't expecting a solution so fast! I was just about to go to bed actually. That works really well though, thank you very much ♡. It doesn't use the textcodes but it's actually bit more streamlined this way I think!

If you don't mind me asking, how did you set a variable to text with the control variables option like that? I've never found a way to do that outside of script calls
 

Roninator2

Gamer
Regular
Joined
May 22, 2016
Messages
5,122
Reaction score
1,502
First Language
English
Primarily Uses
RMVXA
If you don't mind me asking, how did you set a variable to text with the control variables option like that? I've never found a way to do that outside of script calls
You're referring to option 1 or 2?

the "\\V[16]" only works with the added line of code.
The original code does not process the escape characters.
If you look at window_base line 228. the method processes the \v, but when reading text you have to put the extra \ so that it ignores the intended slash. Actually it converts the \\ in to \e then it converts the \ev to the variable.
 

Bazinioli

Advanced User
Member
Joined
Oct 7, 2014
Messages
26
Reaction score
5
First Language
English
Primarily Uses
You're referring to option 1 or 2?

the "\\V[16]" only works with the added line of code.
The original code does not process the escape characters.
If you look at window_base line 228. the method processes the \v, but when reading text you have to put the extra \ so that it ignores the intended slash. Actually it converts the \\ in to \e then it converts the \ev to the variable.
Ohhh, interesting! That's simpler than I thought it would be. I appreciate that explanation, although, I was actually asking how you did this in the editor:
1676083960082.png
For me, it doesn't allow me to type anything but numbers into the Control Variables, typing anything else just forces the input to be 0 once you hit confirm
 

Shaz

Keeper of the Nuts
Global Mod
Joined
Mar 2, 2012
Messages
46,153
Reaction score
16,959
First Language
English
Primarily Uses
RMMV

This thread is being closed, due to being solved. If for some reason you would like this thread re-opened, please report this post and leave a message why. Thank you.

 
Status
Not open for further replies.

Latest Threads

Latest Posts

Latest Profile Posts

MZ_HUD_1.png

Accomplished a longstanding goal: transitioned from windowskin graphics to native canvas drawing for windows. No more window.png or resizing individual mask images; Bitmap and Window classes handle it all seamlessly now.

Same UI, different corner settings:

MZ_HUD_2.png
I haven't check my game DL in a while. So time to see if I get a error 404 message. Because I deleted it due to a lack of space. Or it instantly crashes the second it starts. Or if I end up in some random map because I forgot to reset the start point. Or any combination of them.
ThereseIdleWIP2.gif
Design finished. Onto finishing the entire sprite sheet and alternative colours now
What does it say about you when a mushroom is your best friend?
If a game had a moral-choice system at the beginning 3 chapters where defeating an on-screen encounter grants a "-2" at the end of the level whereas evading it granted "+2" at the end of the chapter, and then each chapter also had a dialogue choice that'd give/take points depending on the answer the player gives, how many points would you expect to gain from the dialogue choices?

Forum statistics

Threads
134,799
Messages
1,250,767
Members
177,596
Latest member
Dimwit_Flathead
Top