RMRK is retiring.
Registration is disabled. The site will remain online, but eventually become a read-only archive. More information.

RMRK.net has nothing to do with Blockchains, Cryptocurrency or NFTs. We have been around since the early 2000s, but there is a new group using the RMRK name that deals with those things. We have nothing to do with them.
NFTs are a scam, and if somebody is trying to persuade you to buy or invest in crypto/blockchain/NFT content, please turn them down and save your money. See this video for more information.
Sidetext

0 Members and 1 Guest are viewing this topic.

**
Rep: +0/-0Level 75
RMRK Junior
In the following script is a mistake:
  • start the script with this command:
    s = $game_temp.sidetext
    i = s.index(nil)
    i = s.size if (i == nil)
    t = "It works!"
    f = true
    w = 120
    c = Color.new(256,16,16)
    s = Sprite_Sidetext.new(t,f,w,c)

    Your text should be red!
  • Then do the same with this:
    s = $game_temp.sidetext
    i = s.index(nil)
    i = s.size if (i == nil)
    t = "No red color!"
    f = false
    w = 120
    c = Color.new(256,16,16)
    s = Sprite_Sidetext.new(t,f,w,c)

    There should be no red color.

The mistake consists of the bold type you change.
If bold is false, there should be red color anyway.

To sum up my questions:
What do I have to do to show up an icon in that sidetext?
Is there a possibility to show or to add that option?
If yes, (and if it is easy) you know what to do ;) .

I have no experience by editing scripts, so is there someone who could look about that script and correct the mistake (and maybe add that option)? ;D
Thanking you in anticipation!

Code: [Select]
#==============================================================================
# ** [STR14] Sidetext (von star) (Version 0.7)
#------------------------------------------------------------------------------
#  Ermöglicht zusätzlichen Text an der linken Seite anzuzeigen.
#==============================================================================

if false
# Das folgenden wird in ein Call Skript geschrieben
s = $game_temp.sidetext
i = s.index(nil)
i = s.size if (i == nil)
t = "Sidetext"           # Text, der angezeigt werden soll
f = true                 # Buchstaben haben Rand? (aus = false)
w = 120                  # Anzeigedauer (in Frames)
c = Color.new(64,32,128) # Farbe des Randes (rot, grün, blau)
s[i] = Sprite_Sidetext.new(t,f,w,c)
#
end

#==============================================================================
# ? Sprite_Sidetext
#==============================================================================
class Sprite_Sidetext < Sprite
  #--------------------------------------------------------------------------
  # ? ?????????
  #--------------------------------------------------------------------------
  def initialize(text, frame = false, wait = 120, c = Color.new(64,32,128))
    super()
    self.x = 16
    num = $game_temp.sidetext.index(nil)
    num = $game_temp.sidetext.size if (num == nil)
    y = 80 + (num * 24)
    self.y = y
    self.z = 200
    bitmap = Bitmap.new(32, 24)
    w = bitmap.text_size(text).width
    bitmap.dispose
    bitmap = Bitmap.new(w, 24)
    if frame
      bitmap.draw_text_f(0, 0, w, 24, text, 0, c)
    else
      bitmap.draw_text(0, 0, w, 24, text)
    end
    self.bitmap = bitmap
    self.opacity = 0
    @wait = wait
  end
  #--------------------------------------------------------------------------
  # ? ??????
  #--------------------------------------------------------------------------
  def update
    if @wait > 0
      self.opacity += 24
      return if self.opacity != 255
      @wait -= 1
    else
      self.x += 4
      self.opacity -= 8
      dispose if self.opacity == 0
    end
  end
end
#==============================================================================
# ? Game_Temp
#==============================================================================
class Game_Temp
  #--------------------------------------------------------------------------
  # ? ??????????
  #--------------------------------------------------------------------------
  attr_accessor :sidetext
  #--------------------------------------------------------------------------
  # ? ?????????
  #--------------------------------------------------------------------------
  alias initialize_str14 initialize
  def initialize
    initialize_str14
    @sidetext = []
  end
end
#==============================================================================
# ? Spriteset_Map
#==============================================================================
class Spriteset_Map
  #--------------------------------------------------------------------------
  # ? S???????
  #--------------------------------------------------------------------------
  def create_sidetext
    $game_temp.sidetext = []
  end
  #--------------------------------------------------------------------------
  # ? S???????
  #--------------------------------------------------------------------------
  def dispose_sidetext
    for i in 0...$game_temp.sidetext.size
      $game_temp.sidetext[i].dispose if $game_temp.sidetext[i] != nil
    end
    $game_temp.sidetext = []
  end
  #--------------------------------------------------------------------------
  # ? S???????
  #--------------------------------------------------------------------------
  def update_sidetext
    for i in 0...$game_temp.sidetext.size
      if $game_temp.sidetext[i] != nil
        $game_temp.sidetext[i].update
        if $game_temp.sidetext[i].disposed?
          $game_temp.sidetext[i] = nil
        end
      end
    end
  end
  #--------------------------------------------------------------------------
  # ? ?????
  #--------------------------------------------------------------------------
  alias create_parallax_str14 create_parallax
  def create_parallax
    create_parallax_str14
    create_sidetext
  end
  alias dispose_str14 dispose
  def dispose
    dispose_sidetext
    dispose_str14
  end
  alias update_str14 update
  def update
    update_str14
    update_sidetext
  end
end
#==============================================================================
# ? Spriteset_Battle
#==============================================================================
class Spriteset_Battle
  #--------------------------------------------------------------------------
  # ? S???????
  #--------------------------------------------------------------------------
  def create_sidetext
    $game_temp.sidetext = []
  end
  #--------------------------------------------------------------------------
  # ? S???????
  #--------------------------------------------------------------------------
  def dispose_sidetext
    for i in 0...$game_temp.sidetext.size
      $game_temp.sidetext[i].dispose if $game_temp.sidetext[i] != nil
    end
    $game_temp.sidetext = []
  end
  #--------------------------------------------------------------------------
  # ? S???????
  #--------------------------------------------------------------------------
  def update_sidetext
    for i in 0...$game_temp.sidetext.size
      if $game_temp.sidetext[i] != nil
        $game_temp.sidetext[i].update
        if $game_temp.sidetext[i].disposed?
          $game_temp.sidetext[i] = nil
        end
      end
    end
  end
  #--------------------------------------------------------------------------
  # ? ?????
  #--------------------------------------------------------------------------
  alias create_battleback_str14 create_battleback
  def create_battleback
    create_battleback_str14
    create_sidetext
  end
  alias dispose_str14 dispose
  def dispose
    dispose_sidetext
    dispose_str14
  end
  alias update_str14 update
  def update
    update_str14
    update_sidetext
  end
end
#==============================================================================
# ? Bitmap
#==============================================================================
class Bitmap
  #--------------------------------------------------------------------------
  # ? ???????
  #--------------------------------------------------------------------------
  def draw_text_f(x, y, width, height, str, align = 0, color = Color.new(64,32,128))
    shadow = self.font.shadow
    b_color = self.font.color.dup
    font.shadow = false
    font.color = color
    draw_text(x + 1, y, width, height, str, align)
    draw_text(x - 1, y, width, height, str, align)
    draw_text(x, y + 1, width, height, str, align)
    draw_text(x, y - 1, width, height, str, align)
    font.color = b_color
    draw_text(x, y, width, height, str, align)
    font.shadow = shadow
  end
  def draw_text_f_rect(r, str, align = 0, color = Color.new(64,32,128))
    draw_text_f(r.x, r.y, r.width, r.height, str, align = 0, color)
  end
end

***
Rep:
Level 82
aka DigiDeity
Hay.
I edit this script a bit and now it'S working.

Code: [Select]
#==============================================================================
# ** [STR14] Sidetext (von star) (Version 0.7)
#------------------------------------------------------------------------------
#  Ermöglicht zusätzlichen Text an der linken Seite anzuzeigen.
#==============================================================================

if false
# Das folgenden wird in ein Call Skript geschrieben
s = $game_temp.sidetext
i = s.index(nil)
i = s.size if (i == nil)
t = "Sidetext"           # Text, der angezeigt werden soll
f = true                 # Buchstaben haben Rand? (aus = false)
w = 120                  # Anzeigedauer (in Frames)
c = Color.new(64,32,128) # Farbe des Randes (rot, grün, blau)
ii = -1 # Iconid if -1 no icon
s[i] = Sprite_Sidetext.new(t,f,w,c,ii)
#
end

#==============================================================================
# ? Sprite_Sidetext
#==============================================================================
class Sprite_Sidetext < Sprite
  #--------------------------------------------------------------------------
  # ? ?????????
  #--------------------------------------------------------------------------
  def initialize(text, frame = false, wait = 120, c = Color.new(64,32,128),icon_id = -1)
    super()
    self.x = 16
    num = $game_temp.sidetext.index(nil)
    num = $game_temp.sidetext.size if (num == nil)
    y = 80 + (num * 24)
    self.y = y
    self.z = 200
    bitmap = Bitmap.new(32, 24)
    w = bitmap.text_size(text).width
    w = icon_id < 0 ? w : w + 28
    xc = w - bitmap.text_size(text).width
    bitmap.dispose
    bitmap = Bitmap.new(w, 24)
    if frame
      bitmap.draw_text_f(xc, 0, w, 24, text, 0, c)
    else
      bitmap.font.color = c
      bitmap.draw_text(xc, 0, w, 24, text)
    end
    iconset = Cache.system("Iconset")
    rect = Rect.new(icon_id % 16 * 24, icon_id / 16 * 24, 24, 24)
    bitmap.blt(0,0,iconset,rect)
    self.bitmap = bitmap
    self.opacity = 0
    @wait = wait
  end
  #--------------------------------------------------------------------------
  # ? ??????
  #--------------------------------------------------------------------------
  def update
    if @wait > 0
      self.opacity += 24
      return if self.opacity != 255
      @wait -= 1
    else
      self.x += 4
      self.opacity -= 8
      dispose if self.opacity == 0
    end
  end
end
#==============================================================================
# ? Game_Temp
#==============================================================================
class Game_Temp
  #--------------------------------------------------------------------------
  # ? ??????????
  #--------------------------------------------------------------------------
  attr_accessor :sidetext
  #--------------------------------------------------------------------------
  # ? ?????????
  #--------------------------------------------------------------------------
  alias initialize_str14 initialize
  def initialize
    initialize_str14
    @sidetext = []
  end
end
#==============================================================================
# ? Spriteset_Map
#==============================================================================
class Spriteset_Map
  #--------------------------------------------------------------------------
  # ? S???????
  #--------------------------------------------------------------------------
  def create_sidetext
    $game_temp.sidetext = []
  end
  #--------------------------------------------------------------------------
  # ? S???????
  #--------------------------------------------------------------------------
  def dispose_sidetext
    for i in 0...$game_temp.sidetext.size
      $game_temp.sidetext[i].dispose if $game_temp.sidetext[i] != nil
    end
    $game_temp.sidetext = []
  end
  #--------------------------------------------------------------------------
  # ? S???????
  #--------------------------------------------------------------------------
  def update_sidetext
    for i in 0...$game_temp.sidetext.size
      if $game_temp.sidetext[i] != nil
        $game_temp.sidetext[i].update
        if $game_temp.sidetext[i].disposed?
          $game_temp.sidetext[i] = nil
        end
      end
    end
  end
  #--------------------------------------------------------------------------
  # ? ?????
  #--------------------------------------------------------------------------
  alias create_parallax_str14 create_parallax
  def create_parallax
    create_parallax_str14
    create_sidetext
  end
  alias dispose_str14 dispose
  def dispose
    dispose_sidetext
    dispose_str14
  end
  alias update_str14 update
  def update
    update_str14
    update_sidetext
  end
end
#==============================================================================
# ? Spriteset_Battle
#==============================================================================
class Spriteset_Battle
  #--------------------------------------------------------------------------
  # ? S???????
  #--------------------------------------------------------------------------
  def create_sidetext
    $game_temp.sidetext = []
  end
  #--------------------------------------------------------------------------
  # ? S???????
  #--------------------------------------------------------------------------
  def dispose_sidetext
    for i in 0...$game_temp.sidetext.size
      $game_temp.sidetext[i].dispose if $game_temp.sidetext[i] != nil
    end
    $game_temp.sidetext = []
  end
  #--------------------------------------------------------------------------
  # ? S???????
  #--------------------------------------------------------------------------
  def update_sidetext
    for i in 0...$game_temp.sidetext.size
      if $game_temp.sidetext[i] != nil
        $game_temp.sidetext[i].update
        if $game_temp.sidetext[i].disposed?
          $game_temp.sidetext[i] = nil
        end
      end
    end
  end
  #--------------------------------------------------------------------------
  # ? ?????
  #--------------------------------------------------------------------------
  alias create_battleback_str14 create_battleback
  def create_battleback
    create_battleback_str14
    create_sidetext
  end
  alias dispose_str14 dispose
  def dispose
    dispose_sidetext
    dispose_str14
  end
  alias update_str14 update
  def update
    update_str14
    update_sidetext
  end
end
#==============================================================================
# ? Bitmap
#==============================================================================
class Bitmap
  #--------------------------------------------------------------------------
  # ? ???????
  #--------------------------------------------------------------------------
  def draw_text_f(x, y, width, height, str, align = 0, color = Color.new(64,32,128))
    shadow = self.font.shadow
    b_color = self.font.color.dup
    font.shadow = false
    font.color = color
    draw_text(x + 1, y, width, height, str, align)
    draw_text(x - 1, y, width, height, str, align)
    draw_text(x, y + 1, width, height, str, align)
    draw_text(x, y - 1, width, height, str, align)
    font.color = b_color
    draw_text(x, y, width, height, str, align)
    font.shadow = shadow
  end
  def draw_text_f_rect(r, str, align = 0, color = Color.new(64,32,128))
    draw_text_f(r.x, r.y, r.width, r.height, str, align = 0, color)
  end
end

The new CallScript is:
s = $game_temp.sidetext
i = s.index(nil)
i = s.size if (i == nil)
t = "Sidetext"           # Text, der angezeigt werden soll
f = true                 # Buchstaben haben Rand? (aus = false)
w = 120                  # Anzeigedauer (in Frames)
c = Color.new(64,32,128) # Farbe des Randes (rot, grün, blau)
ii = -1 # Iconid if -1 no icon
s = Sprite_Sidetext.new(t,f,w,c,ii)

As you mabye can see, ii was added to the callscript. ii means icon_id and if it is lower then 0 no icon will be drawn.

Deity
Greetings
DigiDeity

├Work┤
├Contact┤


**
Rep: +0/-0Level 75
RMRK Junior
Oh yes, it works! Thanks!

One Annotation:
Is it possible to change the position of the icon?
At the end or in the middle of the text?

**
Rep: +0/-0Level 75
RMRK Junior
No ideas? Or do I miss sth.?