Script edit

Hi!
I'd like to ask for another script edit.
This might be a bit of a stretch, but I am currently working on implementing a codex into my game (still need to fix some stuff to make it look better).

But here is what I am running into:

aa1c87cfd90292ea82fc5f0c003edd2e.png


1. There's no scroll down for more info in either the selection part, nor the information part, so if you have more than 14 options, the 15th never shows up.
2. It's using a weird case of line breaks, as in, you need to put \ after every sentence to make it start a new one.
E.g. "Umio named this world based on\nthe idea that Uzume may not be\" which is a bit.. cumbersome.
Would it be possible to have the screen auto-adjust line cut-offs? E.g. if the text goes past a set width, it starts a new line?

I know modern algebra's questjournal has both the scrolling and the automatical text breaking going on. I thought maybe some code could be taken from there and modified? I sadly don't know enough about scripting to do this myself.

As for the scripts itself:

Encyclopedia:

MAlgebra questjournal

Thank you very much for looking into it
I looked into the demo, and I could navigate freely through topics(18 when I activated swich 1). The topic window is slightly altered Window Command. Maybe you edited something in your version that broke it?

About breaking text to lines, you do not really need "\n" character, probably author provided it this way so script looks more neat. Instead you can just press enter inside string, to split the text on many rows, so you can see very easily if a line goes too long.

Scrolling text up and down is doable, although I am not sure I would do it the best way. But even if is not me who doing it, would be helpfull to share how you imagine it to work. Auto scroll? Pressing buttons if no auto scroll? Should there be text that promps the player to press button for scrolling? Where you see that hint text to be in your scene? Such trivial details would help a lot.

Alternatively, you could make some topics to have part 1 and part 2 (two different topics in the script settings), so the text of each fit within the window. This way will not require script edits(at least for the display part, your topic navigation surely needs work).
Well it works but both the column and the tetx drop off the screen:
3f53461ae4405ef6405cacf207a70e05.png


And the tekst in the info box gets cut off.

What I mean by scrolling is this:
09c25a4cdabe056c16bc7482c3d0ce79.gif


E.g. you press on the subject you want, then if the text is too long you can press up or down to scroll
A solution I forged.
Spoiler: Code
Code:
module Nova
  module Encyclopedia
    module SCROLLING_TEXT_SETTINGS
    
    #Author: GGZiron
    #Terms: Free to use and redistribute, only not to claim is yours.
    #Credits: not needed.

# ========================================================
#              Settings for the add on
# ========================================================

  ALL_WINDOWS_CAN_BE_ACTIVATED = false
  #If true, all windows, even those that have fitting text,
  #will allow to be activated.

  AUTO_DETECT_IF_SHOULD_BE_ACTIVATED = true
  #when true, code automatically detects if topic should
  #be able to be selected or no

  #If both settings above are false, you
  #need to add can_scroll in the topic.
  #:can_scroll => true,
  #example topic with such aproach
=begin

                "Oracles" => {
                                  :switch_id => 0,
                                  :category => :extra,
                                  :info => "The leaders of each nation's Basilicom\nwho serves the CPUs. There are different\nconditions for each nation to become an\nOracle. Planeptune's Oracle, Histoire, is\nan artificial being created by an Ancient\nCPU; she also has the role of recording\nPlaneptune's history.",
                                  :image? => true,
                                  :folder => 'Graphics/Encyclopedia/Topics/',
                                  :image_name => 'Oracles',
                                  :icon? => true,
                                  :icon_index => 230,
                                  :can_scroll => true, #The new entry goes here!!
                               },
=end


  TEXT_SCROLLING_SPEED = 8
  #How fast to scroll

  MAX_FITTING_ROWS = 8
  #Used for the auto detection feature. If more than 8 rows, enables
  #topic to be selected.

  LIMIT_SCROLL = 8
  #Determines how down player can scroll.
  #Bigger the number, more restricted is the scroll.
  #Real formula multiplies that number to the line_height, and the result
  #is substracted from the content.height(the bottom of the content bitmap),
  #do determine if reached far enough in the scroll.
  #Leave it default if it works.

# ========================================================
#              End of settings
# ========================================================

    end
  end
end


class GGZ_SCROLLING_TEXT < Window_Selectable

  include Nova::Encyclopedia
  include Nova::Encyclopedia::SCROLLING_TEXT_SETTINGS

  attr_accessor :back_box
  alias_method :oy_ggz124=, :oy=


  def initialize(x, y, width, height)
    super(x, y, width, height)
    set_contents
    self.windowskin = Cache.system(Info_Main[:windowskin])
    back_sprite
  end

  def set_contents
    self.contents.font.name = Info_Main[:font_name]
    self.contents.font.size = Info_Main[:font_size]
    self.contents.font.color = Info_Main[:font_color]
    self.contents.font.outline = Info_Main[:font_outline]
  end

  def back_sprite
    if Info_Main[:image?]
      self.opacity = 0
      @back_box = Sprite.new
      @back_box.visible = false
      @back_box.z = self.z - 1
      path = Info_Main[:folder]
      name = Info_Main[:name]
      @back_box.bitmap = Bitmap.new(path + name)
      @back_box.ox = Info_Main[:img_ox]
      @back_box.oy = Info_Main[:img_oy]
      @back_box.x = self.x
      @back_box.y = self.y
    end
  end

  def display_info(text)
    self.oy = 0
    lines = text.count("\n") + 1
    self.contents.dispose
    self.contents = Bitmap.new(contents_width, fitting_height(lines) - line_height)
    set_contents
    draw_text_ex(0, 0, text)
  end

#▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬
# ● Dispose
#▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬
  def dispose
    super
    @back_box.bitmap.dispose; @back_box.dispose
  end


  def process_cursor_move
    return unless self.active
    scroll_down  if Input.repeat?(:DOWN)
    scroll_up  if Input.repeat?(:UP)
    #Sound.play_cursor if @index != last_index
  end

  def reset_font_settings; end

  def row_height
    [line_height, contents.font.size].max
  end

  def oy=(int)
    self.oy_ggz124 = int
    if oy > contents.height - row_height * LIMIT_SCROLL
      self.oy_ggz124 = contents.height - row_height * LIMIT_SCROLL
    end
    self.oy_ggz124 = 0 if oy < 0
  end

  def scroll_down
    self.oy += TEXT_SCROLLING_SPEED
  end

  def scroll_up
    self.oy -= TEXT_SCROLLING_SPEED
  end


end


class Encyclopedia < Scene_Base

  include Nova::Encyclopedia::SCROLLING_TEXT_SETTINGS

  alias_method :exec_all_windows_old124, :exec_all_windows
  alias_method :method_information_old124, :method_information


  def exec_all_windows
    exec_all_windows_old124
    @pedia_info.dispose
    px = @pedia_topics.width;   py = Graphics.height * 0.3
    pw = Graphics.width - px;   ph = (Graphics.height - py) - @pedia_help.height
    @pedia_info = GGZ_SCROLLING_TEXT.new(px, py, pw, ph)
    @pedia_info.set_handler(:cancel, method(:activate_topic_window))
    @pedia_topics.set_handler(:ok, method(:activate_text_window))
  end

#Method Overwrite

  def method_information
    return if @pedia_topics.data[@pedia_topics.index].nil?
    condition = @text_index != @pedia_topics.data[@pedia_topics.index][:info]
    can_scroll = @pedia_topics.data[@pedia_topics.index][:can_scroll] || false
    method_information_old124
    if condition
      return @pedia_topics.ok_enabled  = true if ALL_WINDOWS_CAN_BE_ACTIVATED
      if AUTO_DETECT_IF_SHOULD_BE_ACTIVATED
        lines = @text_index.count("\n")
        return  lines > MAX_FITTING_ROWS ?
                             @pedia_topics.ok_enabled = true :
                             @pedia_topics.ok_enabled = false
      end
       @pedia_topics.ok_enabled = can_scroll       
    end
  end


  def activate_text_window
    @pedia_topics.deactivate
    @pedia_info.activate
  end

  def activate_topic_window
    @pedia_topics.activate
    @pedia_info.deactivate
  end


end

class Pedia_Topics < Window_Selectable



  alias_method :initialize_old124, :initialize
  attr_writer :ok_enabled


  def initialize(tx, ty, tw, th)
    initialize_old124(tx, ty, tw, th)
    @ok_enabled = false
  end


  def ok_enabled?
    return @ok_enabled
  end

end
That is add-on to be inserted on the after the script. Add on have some own settings.
Terms are as liberal as they get. Credits not needed. Free to use for any type of project.

Some of the things did the way I did only for the sake my work to be add-on, but not direct edit on the main scrip. That is set to work with version 2.1. Hope it works.
Thank you very much 😀 will post if I run into any issues, but should be okay as far as I can see.

Original thread: https://forums.rpgmakerweb.com/threads/script-edit.121850/