Show posts

This section allows you to view all posts made by this member. Note that you can only see posts made in areas you currently have access to.

Topics - Wecoc

31
RMXP Script Database / [XP][VX] Multiple Cursor
June 04, 2013, 09:44:00 am
Multiple Cursor
Authors: Wecoc
Version: 1.3
Type: Window Addon
Key Term: Game Utility



Introduction

This script allows you to use a graphic to have a cursor with as many frames as desired.
It works on XP and VX, but if you use it in VX you will have to change a line (read the instructions below)



Features


  • Uses default Windowskins

  • To get the animated cursor you will need to have another graphic on Windowskins folder called like the windowskin + _c , for example 001-Blue01_c.png or Window_c.png on System folder if you use VX.

  • You can use also _cd instead of _c; _c uses the cursor "by default" with corders and not stretched, and _cd uses the cursor stretched

  • If none of both exist, there will be shown the cursor of the Windowskin, not animated.

  • The graphic can have as many frames as you want in columns: Example

  • You can change the speed of frames updating, read below to know how.




Screenshots

Spoiler: ShowHide



Demo

None.


Script

Spoiler: ShowHide

#==============================================================================
# Window Multiple Cursor [XP/VX] v 1.3
# Poccil's Window edit
# Author: Wecoc
#==============================================================================

$cursorvx = false

class WindowCursorRect < Rect
  attr_reader :x,:y,:width,:height

  def initialize(window)
    @window=window
    @x=0
    @y=0
    @width=0
    @height=0
  end

  def empty
    needupdate=@x!=0 || @y!=0 || @width!=0 || @height!=0
    if needupdate
      @x=0
      @y=0
      @width=0
      @height=0
      @window.width=@window.width
    end
  end

  def isEmpty?
    return @x==0 && @y==0 && @width==0 && @height==0
  end

  def set(x,y,width,height)
    needupdate=@x!=x || @y!=y || @width!=width || @height!=height
    if needupdate
      @x=x
      @y=y
      @width=width
      @height=height
      @window.width=@window.width
    end
  end

  def height=(value)
    @height=value; @window.width=@window.width
  end

  def width=(value)
    @width=value; @window.width=@window.width
  end

  def x=(value)
    @x=value; @window.width=@window.width
  end

  def y=(value)
    @y=value; @window.width=@window.width
  end
end

class Window
  attr_reader :tone
  attr_reader :color
  attr_reader :blend_type
  attr_reader :contents_blend_type
  attr_reader :viewport
  attr_reader :contents
  attr_reader :ox
  attr_reader :oy
  attr_reader :x
  attr_reader :y
  attr_reader :z
  attr_reader :width
  attr_reader :active
  attr_reader :pause
  attr_reader :height
  attr_reader :opacity
  attr_reader :back_opacity
  attr_reader :contents_opacity
  attr_reader :visible
  attr_reader :cursor_rect
  attr_reader :openness
  attr_reader :stretch
  attr_reader :cursor_fullback

  def windowskin
    @_windowskin
  end

  def windowskin_cursor
    @_windowskin_cursor
  end

  def initialize(viewport=nil)
    @sprites={}
    @spritekeys=[
      "back",
      "corner0","side0","scroll0",
      "corner1","side1","scroll1",
      "corner2","side2","scroll2",
      "corner3","side3","scroll3",
      "cursor","contents","pause"
    ]
    @sidebitmaps=[nil,nil,nil,nil]
    @cursorbitmap=nil
    @bgbitmap=nil
    @viewport=viewport
    for i in @spritekeys
      @sprites[i]=Sprite.new(@viewport)
    end
    @disposed=false
    @tone=Tone.new(0,0,0)
    @color=Color.new(0,0,0,0)
    @blankcontents=Bitmap.new(1,1)
    @contents=@blankcontents
    @_windowskin=nil
    @_windowskin_cursor=nil
    @x=0
    @y=0
    @width=0
    @openness=255
    @height=0
    @ox=0
    @oy=0
    @z=0
    @stretch=true
    @visible=true
    @active=true
    @blend_type=0
    @contents_blend_type=0
    @opacity=255
    @back_opacity=255
    @contents_opacity=255
    @cursor_rect=WindowCursorRect.new(self)
    @cursor_current_frame=0.0
    @cursor_frames=0
    @cursoropacity=255
    @pause=false
    @pauseopacity=255
    @pauseframe=0
    @cursor_fullback = false
    privRefresh(true)
  end

  def dispose
    if !self.disposed?
      for i in @sprites
        i[1].dispose if i[1]
        @sprites[i[0]]=nil
      end
      for i in 0...@sidebitmaps.length
        @sidebitmaps[i].dispose if @sidebitmaps[i]
        @sidebitmaps[i]=nil
      end
      @blankcontents.dispose
      @cursorbitmap.dispose if @cursorbitmap
      @backbitmap.dispose if @backbitmap
      @sprites.clear
      @sidebitmaps.clear
      @_windowskin=nil
      @_windowskin_cursor=nil
      @_contents=nil
      @disposed=true
    end
  end


  def openness=(value)
    @openness=value
    @openness=0 if @openness<0
    @openness=255 if @openness>255
    privRefresh
  end

  def stretch=(value)
    @stretch=value
    privRefresh(true)
  end

  def visible=(value)
    @visible=value
    privRefresh
  end

  def cursor_fullback=(value)
    @cursor_fullback = value
    privRefresh
  end

  def viewport=(value)
    @viewport=value
    for i in @spritekeys
      @sprites[i].dispose
      if @sprites[i].is_a?(Sprite)
        @sprites[i]=Sprite.new(@viewport)
      elsif @sprites[i].is_a?(Plane)
        @sprites[i]=Plane.new(@viewport)
      else
        @sprites[i]=nil
      end
    end
    privRefresh(true)
  end

  def z=(value)
    @z=value
    privRefresh
  end

  def disposed?
    return @disposed
  end

  def contents=(value)
    @contents=value
    privRefresh
  end

  def windowskin=(value)
    @_windowskin=value
    privRefresh(true)
  end

  def windowskin_cursor=(value)
    @_windowskin_cursor=value
    @_windowskin_cursor=@_windowskin if value == nil
    privRefresh(true)
  end

  def active=(value)
    @active=value
    privRefresh(true)
  end

  def cursor_rect=(value)
    if !value
      @cursor_rect.empty
    else
      @cursor_rect.set(value.x,value.y,value.width,value.height)
    end
  end

  def ox=(value)
    @ox=value
    privRefresh
  end

  def oy=(value)
    @oy=value
    privRefresh
  end

  def width=(value)
    @width=value
    privRefresh(true)
  end

  def height=(value)
    @height=value
    privRefresh(true)
  end

  def pause=(value)
    @pause=value
    @pauseopacity=0 if !value
    privRefresh
  end

  def x=(value)
    @x=value
    privRefresh
  end

  def y=(value)
    @y=value
    privRefresh
  end

  def opacity=(value)
    @opacity=value
    @opacity=0 if @opacity<0
    @opacity=255 if @opacity>255
    privRefresh
  end

  def back_opacity=(value)
    @back_opacity=value
    @back_opacity=0 if @back_opacity<0
    @back_opacity=255 if @back_opacity>255
    privRefresh
  end

  def contents_opacity=(value)
    @contents_opacity=value
    @contents_opacity=0 if @contents_opacity<0
    @contents_opacity=255 if @contents_opacity>255
    privRefresh
  end

  def tone=(value)
    @tone=value
    privRefresh
  end

  def color=(value)
    @color=value
    privRefresh
  end

  def blend_type=(value)
    @blend_type=value
    privRefresh
  end

  def flash(color,duration)
    return if disposed?
    for i in @sprites
      i[1].flash(color,duration)
    end
  end

  def update
    return if disposed?
    mustchange=true

    if @_windowskin == @_windowskin_cursor
      if $cursorvx
        cursorX = 64
      else
        cursorX = 128
      end
      cursorWH = 32
      cursorY = 64
      @cursor_frames = 0
    else
      cursorX = 0
      cursorY = 0
      @cursor_frames = @_windowskin_cursor.width / @_windowskin_cursor.height
      cursorWH = @_windowskin_cursor.height
    end

    if $cursorvx == false
      if @cursor_rect.width < cursorWH
        cursorWH = (cursorWH - @cursor_rect.width) / 2
      end
      if @cursor_rect.height < cursorWH
        cursorWH = (cursorWH - @cursor_rect.height) / 2
      end
    end
   
    if @active
      @cursoropacity=255
      @cursor_current_frame+=0.1
      frame = @cursor_current_frame.truncate
      if frame == @cursor_frames
        @cursor_current_frame = 0.0
        frame = 0
      end
    else
      @cursoropacity=128
      @cursor_current_frame+=0
      frame = 0
    end

    if @cursor_fullback == false
      @side1 = Rect.new(cursorX + frame * cursorWH + (cursorWH/4),
                        cursorY + 0,
                        cursorWH / 2, cursorWH / 2)

      @side2 = Rect.new(cursorX + frame * cursorWH + 0,
                        cursorY + (cursorWH/4),
                        cursorWH / 2, cursorWH / 2)

      @side3 = Rect.new(cursorX + frame * cursorWH + (cursorWH/2),
                        cursorY + (cursorWH/4),
                        cursorWH / 2, cursorWH / 2)
                       
      @side4 = Rect.new(cursorX + frame * cursorWH + (cursorWH/4),
                        cursorY + (cursorWH/2),
                        cursorWH / 2, cursorWH / 2)

      @corner1 = Rect.new(cursorX + frame * cursorWH + 0,
                          cursorY + 0,
                          cursorWH / 2, cursorWH / 2)
                   
      @corner2 = Rect.new(cursorX + frame * cursorWH + (cursorWH/2),
                          cursorY + 0,
                          cursorWH / 2, cursorWH / 2)
                   
      @corner3 = Rect.new(cursorX + frame * cursorWH + 0,
                          cursorY + (cursorWH/2),
                          cursorWH / 2, cursorWH / 2)
                   
      @corner4 = Rect.new(cursorX + frame * cursorWH + (cursorWH/2),
                          cursorY + (cursorWH/2),
                          cursorWH / 2, cursorWH / 2)

      @back = Rect.new(cursorX + frame * cursorWH + (cursorWH/2),
                      cursorY + (cursorWH/2), 1, 1)
    else
      @side1 = Rect.new(0, 0, 0, 0)
      @side2 = Rect.new(0, 0, 0, 0)
      @side3 = Rect.new(0, 0, 0, 0)
      @side4 = Rect.new(0, 0, 0, 0)
      @corner1 = Rect.new(0, 0, 0, 0)
      @corner2 = Rect.new(0, 0, 0, 0)
      @corner3 = Rect.new(0, 0, 0, 0)
      @corner4 = Rect.new(0, 0, 0, 0)
      @back = Rect.new(cursorX + frame * cursorWH, cursorY, cursorWH, cursorWH)
    end
   
    mustchange=true if !@cursor_rect.isEmpty?


    width=@cursor_rect.width
    height=@cursor_rect.height
    if @cursor_fullback == false
      margin= (cursorWH/2)
      fullmargin= cursorWH
    else
      margin= 0
      fullmargin= 0
    end

    @cursorbitmap = ensureBitmap(@cursorbitmap, width, height)
    @cursorbitmap.clear

    @sprites["cursor"].bitmap=@cursorbitmap
    @sprites["cursor"].src_rect.set(0,0,width,height)

    # BACK
    rect = Rect.new(margin,margin,width - fullmargin, height - fullmargin)
    @cursorbitmap.stretch_blt(rect, @_windowskin_cursor, @back)
   
    # CORNER1
    @cursorbitmap.blt(0, 0, @_windowskin_cursor, @corner1)

    # CORNER2
    if @cursor_rect.width < cursorWH and $cursorvx
      @cursorbitmap.fill_rect(width-margin, 0, width-margin, height-margin,
                              Color.new(0,0,0,0))
    end
    @cursorbitmap.blt(width-margin, 0, @_windowskin_cursor, @corner2)
   
    # CORNER3
    if @cursor_rect.height < cursorWH and $cursorvx
      @cursorbitmap.fill_rect(0, height-margin, width-margin, height-margin,
                              Color.new(0,0,0,0))
    end
    @cursorbitmap.blt(0, height-margin, @_windowskin_cursor, @corner3)
   
    # CORNER4
    if @cursor_rect.width < cursorWH and $cursorvx
      @cursorbitmap.fill_rect(width-margin, height-margin,width-margin,height-margin,
                              Color.new(0,0,0,0))
    end
    if @cursor_rect.height < cursorWH and $cursorvx
      @cursorbitmap.fill_rect(width-margin, height-margin,width-margin,height-margin,
                              Color.new(0,0,0,0))
    end
    @cursorbitmap.blt(width-margin, height-margin, @_windowskin_cursor, @corner4)


    # SIDE1
    rect = Rect.new(margin, 0, width - fullmargin, margin)
    @cursorbitmap.stretch_blt(rect, @_windowskin_cursor, @side1)
   
    # SIDE2
    rect = Rect.new(0, margin,margin, height - fullmargin)
    @cursorbitmap.stretch_blt(rect, @_windowskin_cursor, @side2)
   
    # SIDE3
    if @cursor_rect.width < cursorWH and $cursorvx
      @cursorbitmap.fill_rect(width-margin,margin,margin,height-fullmargin,
                              Color.new(0,0,0,0))
    end
    rect = Rect.new(width - margin, margin,margin, height - fullmargin)
    @cursorbitmap.stretch_blt(rect, @_windowskin_cursor, @side3)
   
    # SIDE4
    if @cursor_rect.height < cursorWH and $cursorvx
      @cursorbitmap.fill_rect(margin,height-margin,width-fullmargin,margin,
                              Color.new(0,0,0,0))
    end
    rect = Rect.new(margin, height-margin, width - fullmargin, margin)
    @cursorbitmap.stretch_blt(rect, @_windowskin_cursor, @side4)

    if @pause
      @pauseframe=(Graphics.frame_count / 8) % 4
      @pauseopacity=[@pauseopacity+64,255].min
      mustchange=true
    end
    privRefresh if mustchange
    for i in @sprites
      i[1].update
    end
  end

  private
  def ensureBitmap(bitmap,dwidth,dheight)
    if !bitmap||bitmap.disposed?||bitmap.width<dwidth||bitmap.height<dheight
      bitmap.dispose if bitmap
      bitmap=Bitmap.new([1,dwidth].max,[1,dheight].max)
    end
    return bitmap
  end

  def tileBitmap(dstbitmap,dstrect,srcbitmap,srcrect)
    return if !srcbitmap || srcbitmap.disposed?
    left=dstrect.x
    top=dstrect.y
    y=0;loop do break unless y<dstrect.height
    x=0;loop do break unless x<dstrect.width
      dstbitmap.blt(x+left,y+top,srcbitmap,srcrect)
      x+=srcrect.width
    end
    y+=srcrect.height
    end
  end

  def privRefresh(changeBitmap=false)
    return if self.disposed?
    backopac=self.back_opacity*self.opacity/255
    contopac=self.contents_opacity
    cursoropac=@cursoropacity*contopac/255
    for i in 0...4
      @sprites["corner#{i}"].bitmap=@_windowskin
      @sprites["scroll#{i}"].bitmap=@_windowskin
    end
    @sprites["pause"].bitmap=@_windowskin
    @sprites["contents"].bitmap=@contents
    if @_windowskin && !@_windowskin.disposed?
      for i in 0...4
        @sprites["corner#{i}"].opacity=@opacity
        @sprites["corner#{i}"].tone=@tone
        @sprites["corner#{i}"].color=@color
        @sprites["corner#{i}"].blend_type=@blend_type
        @sprites["corner#{i}"].visible=@visible
        @sprites["side#{i}"].opacity=@opacity
        @sprites["side#{i}"].tone=@tone
        @sprites["side#{i}"].color=@color
        @sprites["side#{i}"].blend_type=@blend_type
        @sprites["side#{i}"].visible=@visible
        @sprites["scroll#{i}"].opacity=@opacity
        @sprites["scroll#{i}"].tone=@tone
        @sprites["scroll#{i}"].blend_type=@blend_type
        @sprites["scroll#{i}"].color=@color
        @sprites["scroll#{i}"].visible=@visible
      end
      for i in ["back","cursor","pause","contents"]
        @sprites[i].color=@color
        @sprites[i].tone=@tone
        @sprites[i].blend_type=@blend_type
      end
      @sprites["contents"].blend_type=@contents_blend_type
      @sprites["back"].opacity=backopac
      @sprites["contents"].opacity=contopac
      @sprites["cursor"].opacity=cursoropac
      @sprites["pause"].opacity=@pauseopacity
      @sprites["back"].visible=@visible
      @sprites["contents"].visible=@visible && @openness==255
      @sprites["pause"].visible=@visible && @pause
      @sprites["cursor"].visible=@visible && @openness==255
      hascontents=(@contents && !@contents.disposed?)
      @sprites["scroll0"].visible = @visible && hascontents && @oy > 0
      @sprites["scroll1"].visible = @visible && hascontents && @ox > 0
      @sprites["scroll2"].visible = @visible && hascontents &&
      (@contents.width - @ox) > @width-32
      @sprites["scroll3"].visible = @visible && hascontents &&
      (@contents.height - @oy) > @height-32
    else
      for i in 0...4
        @sprites["corner#{i}"].visible=false
        @sprites["side#{i}"].visible=false
        @sprites["scroll#{i}"].visible=false
      end
      @sprites["contents"].visible=@visible && @openness==255
      @sprites["contents"].color=@color
      @sprites["contents"].tone=@tone
      @sprites["contents"].blend_type=@contents_blend_type
      @sprites["contents"].opacity=contopac
      @sprites["back"].visible=false
      @sprites["pause"].visible=false
      @sprites["cursor"].visible=false
    end
    for i in @sprites
      i[1].z=@z
    end

    if $cursorvx
      @sprites["cursor"].z=@z
      @sprites["contents"].z=@z
      @sprites["pause"].z=@z
      trimX=64
      trimY=0
      backRect=Rect.new(0,0,64,64)
      blindsRect=Rect.new(0,64,64,64)
    else
      @sprites["cursor"].z=@z+1
      @sprites["contents"].z=@z+2
      @sprites["pause"].z=@z+2
      trimX=128
      trimY=0
      backRect=Rect.new(0,0,128,128)
      blindsRect=nil
    end

    @sprites["corner0"].src_rect.set(trimX,trimY+0,16,16);
    @sprites["corner1"].src_rect.set(trimX+48,trimY+0,16,16);
    @sprites["corner2"].src_rect.set(trimX,trimY+48,16,16);
    @sprites["corner3"].src_rect.set(trimX+48,trimY+48,16,16);
    @sprites["scroll0"].src_rect.set(trimX+24, trimY+16, 16, 8) # up
    @sprites["scroll3"].src_rect.set(trimX+24, trimY+40, 16, 8) # down
    @sprites["scroll1"].src_rect.set(trimX+16, trimY+24, 8, 16) # left
    @sprites["scroll2"].src_rect.set(trimX+40, trimY+24, 8, 16) # right

    sideRects=[
    Rect.new(trimX+16,trimY+0,32,16),
    Rect.new(trimX,trimY+16,16,32),
    Rect.new(trimX+48,trimY+16,16,32),
    Rect.new(trimX+16,trimY+48,32,16)
    ]

    if @width>32 && @height>32
      @sprites["contents"].src_rect.set(@ox,@oy,@width-32,@height-32)
    else
      @sprites["contents"].src_rect.set(0,0,0,0)
    end
    pauseRects=[
    trimX+32,trimY+64,
    trimX+48,trimY+64,
    trimX+32,trimY+80,
    trimX+48,trimY+80,
    ]
    pauseWidth=16
    pauseHeight=16
    @sprites["pause"].src_rect.set(
      pauseRects[@pauseframe*2],
      pauseRects[@pauseframe*2+1],
      pauseWidth,pauseHeight
    )
    @sprites["pause"].x=(@x+(@width/2)-(pauseWidth/2))#+216
    @sprites["pause"].y=(@y+@height-16)#-8

    @sprites["contents"].x=@x+16
    @sprites["contents"].y=@y+16
    @sprites["corner0"].x=@x
    @sprites["corner0"].y=@y
    @sprites["corner1"].x=@x+@width-16
    @sprites["corner1"].y=@y
    @sprites["corner2"].x=@x
    @sprites["corner2"].y=@y+@height-16
    @sprites["corner3"].x=@x+@width-16
    @sprites["corner3"].y=@y+@height-16
    @sprites["side0"].x=@x+16
    @sprites["side0"].y=@y
    @sprites["side1"].x=@x
    @sprites["side1"].y=@y+16
    @sprites["side2"].x=@x+@width-16
    @sprites["side2"].y=@y+16
    @sprites["side3"].x=@x+16
    @sprites["side3"].y=@y+@height-16
    @sprites["scroll0"].x = @x+@width / 2 - 8
    @sprites["scroll0"].y = @y+8
    @sprites["scroll1"].x = @x+8
    @sprites["scroll1"].y = @y+@height / 2 - 8
    @sprites["scroll2"].x = @x+@width - 16
    @sprites["scroll2"].y = @y+@height / 2 - 8
    @sprites["scroll3"].x = @x+@width / 2 - 8
    @sprites["scroll3"].y = @y+@height - 16
    @sprites["back"].x=@x+2
    @sprites["back"].y=@y+2
    @sprites["cursor"].x=@x+16+@cursor_rect.x
    @sprites["cursor"].y=@y+16+@cursor_rect.y
    if changeBitmap && @_windowskin && !@_windowskin.disposed?
      for i in 0..3
        dwidth=(i==0||i==3) ? @width-32 : 16
        dheight=(i==0||i==3) ? 16 : @height-32
        @sidebitmaps[i]=ensureBitmap(@sidebitmaps[i],dwidth,dheight)
        @sprites["side#{i}"].bitmap=@sidebitmaps[i]
        @sprites["side#{i}"].src_rect.set(0,0,dwidth,dheight)
        @sidebitmaps[i].clear
        if sideRects[i].width>0 && sideRects[i].height>0
        @sidebitmaps[i].stretch_blt(@sprites["side#{i}"].src_rect,
          @_windowskin,sideRects[i])
        end
      end
      backwidth=@width-4
      backheight=@height-4
      if backwidth>0 && backheight>0
        @backbitmap=ensureBitmap(@backbitmap,backwidth,backheight)
        @sprites["back"].bitmap=@backbitmap
        @sprites["back"].src_rect.set(0,0,backwidth,backheight)
        @backbitmap.clear
        if @stretch
          @backbitmap.stretch_blt(@sprites["back"].src_rect,@_windowskin,backRect)
        else
          tileBitmap(@backbitmap,@sprites["back"].src_rect,@_windowskin,backRect)
        end
        if blindsRect
          tileBitmap(@backbitmap,@sprites["back"].src_rect,@_windowskin,blindsRect)
        end
      else
        @sprites["back"].visible=false
        @sprites["back"].src_rect.set(0,0,0,0)
      end
    end
    if @openness!=255
      opn=@openness/255.0
      for k in @spritekeys
        sprite=@sprites[k]
        ratio=(@height<=0) ? 0 : (sprite.y-@y)*1.0/@height
        sprite.zoom_y=opn
        sprite.oy=0
        sprite.y=(@y+(@height/2.0)+(@height*ratio*opn)-(@height/2*opn)).floor
      end
    else
      for k in @spritekeys
        sprite=@sprites[k]
        sprite.zoom_y=1.0
      end
    end
    i=0
    for k in @spritekeys
      sprite=@sprites[k]
      y=sprite.y
      sprite.y=i
      sprite.oy=(sprite.zoom_y<=0) ? 0 : (i-y)/sprite.zoom_y
    end
  end
end

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

if $cursorvx

  class Window_Base < Window
    def initialize(x, y, width, height)
      super()
      self.windowskin = Cache.system("Window")
      check_cursor_file
      self.x = x
      self.y = y
      self.width = width
      self.height = height
      self.z = 100
      self.back_opacity = 200
      self.openness = 255
      create_contents
      @opening = false
      @closing = false
    end

    def check_cursor_file
      cb = FileTest.exists?("Graphics/System/Window_cb.png")
      c = FileTest.exists?("Graphics/System/Window_c.png")
      if cb
        self.windowskin_cursor = Cache.system("Window_cb")
        self.cursor_fullback = true
      elsif c
        self.windowskin_cursor = Cache.system("Window_c")
        self.cursor_fullback = false
      else
        self.windowskin_cursor = nil
        self.cursor_fullback = false
      end
    end
  end

else

  class Window_Base < Window
    def initialize(x, y, width, height)
      super()
      @windowskin_name = $game_system.windowskin_name
      self.windowskin = RPG::Cache.windowskin(@windowskin_name)
      check_cursor_file
      self.x = x
      self.y = y
      self.width = width
      self.height = height
      self.z = 100
    end

    def check_cursor_file
      cb = FileTest.exists?("Graphics/Windowskins/"+@windowskin_name+"_cb.png")
      c = FileTest.exists?("Graphics/Windowskins/"+@windowskin_name+"_c.png")
      if cb
        self.windowskin_cursor = RPG::Cache.windowskin(@windowskin_name+"_cb")
        self.cursor_fullback = true
      elsif c
        self.windowskin_cursor = RPG::Cache.windowskin(@windowskin_name+"_c")
        self.cursor_fullback = false
      else
        self.windowskin_cursor = nil
        self.cursor_fullback = false
      end
    end

    def update
      super
      if $game_system.windowskin_name != @windowskin_name
        @windowskin_name = $game_system.windowskin_name
        self.windowskin = RPG::Cache.windowskin(@windowskin_name)
        check_cursor_file
      end
    end
  end

end



Instructions

If you use on VX, you have to change the next line
$cursorvx = false

to
$cursorvx = true


To change the frame speed, search this like
@cursor_current_frame+=0.1

and change the 0.1 for a bigger number for faster and smaller for slower.
That number must be bigger (>) than 0 and smaller (<=) than 1.



Compatibility

Not incompatibility issues known.



Credits and Thanks


  • Poccil - Original Window class script




Author's Notes

You can post if you find any bug.
You can also suggest improvements for the script.
32
Wecoc's Balance Shop System
Authors: Wecoc
Version: 1.0
Type: Custom Shop System
Key Term: Custom Shop System



Introduction

This shop script consists of a balance between selling and buying things. It has configurable parts, using the module BalanceWecoc.
The script requires some pictures to work.



Features


  • Balance with real-time motion

  • Item icons are displayed on the balance

  • Spriteset map is shown under the shop scene (deactivatable)

  • Money also plays in the store, not only the exchange of goods.

  • You can make "just sell for money", "just buy with money" shops and change it with script call.

  • It includes a way to make the gold icon's zoom depending on the amount of money.




Screenshots

Spoiler: ShowHide







Demo

Download Balance Shop v1.0.zip



Instructions

Module BalanceWecoc is on the top of the code.
If you want a shop were you can just sell for money use:
$game_system.just_money_sell = true


If you want a shop were you can just buy with money use:
$game_system.just_money_buy = true


There is no point to use both at the same time.

If you want a shop were you can just interchange items (not money) use:
$game_system.no_money_shop = true


Beware to set them back to 'false', there's a bug with that, you can see more details here:
http://forum.chaos-project.com/index.php/topic,938.0.html



Compatibility

Not compatible with other shop systems but yes with anything else.


Credits and Thanks


  • Wecoc




Author's Notes

If you have any problem don't hestitate to ask.
33
Wecoc's Mosaic Shop System
Authors: Wecoc
Version: 1.0
Type: Custom Shop System
Key Term: Custom Shop System



Introduction

This shop script displays objects as a mosaic and not on a list. It has configurable parts, using the module NewShopWecoc.
The script requires Window_Selectable +


Features


  • Easy configurable with the module

  • The item's price window moves with the cursor

  • Window_ShopNumber can be activated or deactivated




Screenshots

Spoiler: ShowHide






Demo

Not necessary.


Script

Insert them above main

Window_Selectable +
Spoiler: ShowHide

#==============================================================================
# [Scripter's Tool] Window_Selectable +
#------------------------------------------------------------------------------
# This window class contains cursor movement and scroll functions.
# New functions for the class Window_Selectable
# by: Wecoc
#==============================================================================

class Window_Selectable < Window_Base
  attr_reader  :index
  attr_reader  :help_window
  def initialize(x, y, width, height)
    super(x, y, width, height)
    @item_max = 1 # Número máximo de elementos que contiene la ventana.
    @column_max = 1 # Número máximo de columnas
    @index = -1
    @virtualOy=0 # y en la que sale el primer item de la lista. Defecto: 0
    @row_hplus=0 # Viene definido más abajo.
    self.rowHeight=32 # Separación entre filas. Defecto: 32
    @column_spacing=32 # Separación entre columnas. Defecto: 32
  end

  def count # Número de ítems
    return @item_max || 0
  end

  def index=(index)
    if @index!=index
      @index = index
      self.refresh
    end
    if self.active and @help_window != nil
      update_help
    end
    update_cursor_rect
  end

  def rowHeight # Separación entre filas
    return @row_height || 32
  end

  def rowHeight=(value)
    if @row_height != value
      @row_height = [1,value].max
      @row_hplus = (([32,@row_height].max)-32)/2
    # @row_hplus controla mejor la separación para encuadrar los items.
    # No hace falta cambiarlo porque lo hace solo, cuando se cambia @row_height.
    # Nótese que su valor default es 0/2 = 0
      update_cursor_rect
    end
  end

  def columns # Número de columnas
    return @column_max || 1
  end

  def columns=(value)
    if @column_max != value
      @column_max=[1,value].max
      update_cursor_rect
    end
  end

  def columnSpacing # Separación entre columnas
    return @column_spacing || 32
  end

  def columnSpacing=(value)
    if @column_spacing != value
      @column_spacing=[0,value].max
      update_cursor_rect
    end
  end

  def row_max # Número máximo de filas
    return (@item_max + @column_max - 1) / @column_max
  end

  def top_row # El número de fila superior, que se muestra en la ventana, donde
    # 0 es la fila superior de los elementos.
    # Divide la coordenada de origen y por lo que vale el alto de una fila.
    return ((self.oy+@virtualOy) / (@row_height || 32)).to_i
  end

  def top_item # El item correspondiente al top_row, que variará según la columna
    return top_row * @column_max
  end

  def top_row=(row)
    if row > row_max - 1
      row = row_max - 1
    end
    if row < 0
      row = 0
    end
    self.oy = row * @row_height
  end

  def page_row_max # Número máximo de filas que se pueden mostrar a la vez.
    return ((self.height - 32) / @row_height).to_i
  end
  def page_item_max # Número máximo de items que se pueden mostrar a la vez.
    return page_row_max * @column_max
  end

  def help_window=(help_window)
    @help_window = help_window
    if self.active and @help_window != nil
      update_help
    end
  end

  def update_cursor_rect
    if @index < 0
      self.cursor_rect.empty
      return
    end
    row = @index / @column_max
    if row < self.top_row
      self.top_row = row
    end
    if row > self.top_row + (self.page_row_max - 1)
      self.top_row = row - (self.page_row_max - 1)
    end
    cursor_width = self.width / @column_max - 32
    x = @index % @column_max * (cursor_width + @column_spacing)
    y = @index / @column_max * @row_height - self.oy
    self.cursor_rect.set(x, y, cursor_width, @row_height)
  end

  def update
    super
    if self.active and @item_max > 0 and @index >= 0
      if Input.repeat?(Input::DOWN) # Pulsar abajo
        #if (Input.trigger?(Input::DOWN) and (@item_max % @column_max)==0) or
        if (Input.trigger?(Input::DOWN) and (@column_max==1)) or
          @index < @item_max - @column_max
          $game_system.se_play($data_system.cursor_se)
          @index = (@index + @column_max) % @item_max
          update_cursor_rect
        end
      end
      if Input.repeat?(Input::UP) # Pulsar arriba
        if (Input.trigger?(Input::UP) and (@item_max%@column_max)==0) or
          @index >= @column_max
          $game_system.se_play($data_system.cursor_se)
          @index = (@index - @column_max + @item_max) % @item_max
          update_cursor_rect
        end
      end
      if Input.repeat?(Input::RIGHT) # Pulsar Derecha
        if @column_max >= 2 and @index < @item_max - 1
          $game_system.se_play($data_system.cursor_se)
          @index += 1
          update_cursor_rect
        end
      end
      if Input.repeat?(Input::LEFT) # Pulsar Izquierda
        if @column_max >= 2 and @index > 0
          $game_system.se_play($data_system.cursor_se)
          @index -= 1
          update_cursor_rect
        end
      end
      if Input.repeat?(Input::R) # Pulsar R (o RePag)
        if self.top_row + (self.page_row_max - 1) < (self.row_max - 1)
          $game_system.se_play($data_system.cursor_se)
          @index = [@index + self.page_item_max, @item_max - 1].min
          self.top_row += self.page_row_max
          update_cursor_rect
        end
      end
      if Input.repeat?(Input::L) # Pulsar L (o AvPag)
        if self.top_row > 0
          $game_system.se_play($data_system.cursor_se)
          @index = [@index - self.page_item_max, 0].max
          self.top_row -= self.page_row_max
          update_cursor_rect
        end
      end
    end
    if self.active and @help_window != nil
      update_help
    end
    update_cursor_rect
  end
end


Wecoc's Mosaic Shop System
Spoiler: ShowHide

#==============================================================================
# WECOC'S "MOSAIC" SHOP SYSTEM v1.0
#------------------------------------------------------------------------------
# By: Wecoc
#------------------------------------------------------------------------------
# This shop script displays objects as a mosaic and not on a list.
# It has configurable parts, using the module NewShopWecoc.
# I attached some possible options. Hope you like the script.
# The script requires Window_Selectable +

=begin

  ------------------------------
  VERSION 1

  COLUMN_MAX = 4
  ROW_HEIGHT = 64
  SHOW_OWN_BIG = true
  TEXT_SIZE = 16
  TEXT_BOLD = true
  SHOW_BIG_PSTATUS = true
  SHOW_OWN_SMALL = false
  SHOW_SMALL_PSTATUS = false
  SHOW_NUMBER = true
  ------------------------------
  VERSION 2

  COLUMN_MAX = 10
  ROW_HEIGHT = 32
  SHOW_OWN_BIG = false
  TEXT_SIZE = 14
  TEXT_BOLD = true
  SHOW_BIG_PSTATUS = false
  SHOW_OWN_SMALL = true
  SHOW_SMALL_PSTATUS = true
  SHOW_NUMBER = false
  ------------------------------
  VERSION 3

  COLUMN_MAX = 3
  ROW_HEIGHT = 45
  SHOW_OWN_BIG = true
  TEXT_SIZE = 20
  TEXT_BOLD = false
  SHOW_BIG_PSTATUS = false
  SHOW_OWN_SMALL = false
  SHOW_SMALL_PSTATUS = false
  SHOW_NUMBER = false
=end
#==============================================================================

#------------------------------------------------------------------------------
# MODULE GLOBALS
#------------------------------------------------------------------------------

module NewShopWecoc
 
  # -------------------------
  COLUMN_MAX = 4 # Indicates how many columns have Window_Buy and Window_Sell
  ROW_HEIGHT = 64 # Indicates how the cursor measured (row height)
  # -------------------------
 
  # If true, the item's name will appear on the mosaic,
  # and under it how many you own.
  SHOW_OWN_BIG = true
   
    # Text size of the name of the item and "Own: x" and if bold or not
    TEXT_SIZE = 16
    TEXT_BOLD = true
   
    # Only if SHOW_OWN_BIG es activated. If SHOW_BIG_PSTATUS is true, it says
    # if the weapon or armor is better that which actors wear.
    SHOW_BIG_PSTATUS = true
   
      MINUS = Color.new(255,  0,  0)  # Color when it's worse
      EQUAL = Color.new(255, 255,  0) # Color when it's equal
      PLUS  = Color.new(  0, 255,  0) # Color when it's better
      OFF  = Color.new(100, 110, 120) # Color when actor can't wear it
  # -------------------------
  # If true it will display how many items you own with a small number
  SHOW_OWN_SMALL = false
  # If true it says if the weapon or armor is better that which PLAYER wears
  SHOW_SMALL_PSTATUS = false
  # If true, number_window (Window_ShopNumber) works as always.
  # If false it does not work and you can just buy items one by one.
  SHOW_NUMBER = false
end

#------------------------------------------------------------------------------
# Window_ShopBuy
#------------------------------------------------------------------------------

class Window_ShopBuy < Window_Selectable

  # initialize considering COLUMN_MAX y ROW_HEIGHT
  def initialize(shop_goods)
    super(0, 128, 640, 352)
    @column_max = NewShopWecoc::COLUMN_MAX
    self.rowHeight=NewShopWecoc::ROW_HEIGHT
    @shop_goods = shop_goods
    refresh
    self.index = 0
  end

  def item
    return @data[self.index]
  end

  # refresh with @row_height correction
  def refresh
    if self.contents != nil
      self.contents.dispose
      self.contents = nil
    end
    @data = []
    for goods_item in @shop_goods
      case goods_item[0]
      when 0
        item = $data_items[goods_item[1]]
      when 1
        item = $data_weapons[goods_item[1]]
      when 2
        item = $data_armors[goods_item[1]]
      end
      if item != nil
        @data.push(item)
      end
    end
    @item_max = @data.size
    if @item_max > 0
      self.contents = Bitmap.new(width - 32, row_max * @row_height)
      for i in 0...@item_max
        draw_item(i)
      end
    end
  end

  # draw_item (the most configurable part)
  def draw_item(index)
    item = @data[index]
    case item
    when RPG::Item # Item
      number = $game_party.item_number(item.id)
    when RPG::Weapon # Weapon
      number = $game_party.weapon_number(item.id)
      for i in 0...$game_party.actors.size
        number += 1 if $game_party.actors[i].weapon_id == item.id
      end
    when RPG::Armor # Armor
      number = $game_party.armor_number(item.id)
      for i in 0...$game_party.actors.size
        number += 1 if $game_party.actors[i].armor1_id == item.id
        number += 1 if $game_party.actors[i].armor2_id == item.id
        number += 1 if $game_party.actors[i].armor3_id == item.id
        number += 1 if $game_party.actors[i].armor4_id == item.id
      end
    end
    if item.price <= $game_party.gold and number < 99
      self.contents.font.color = normal_color
    else
      self.contents.font.color = disabled_color
    end
   
  if NewShopWecoc::SHOW_OWN_BIG # SHOW_OWN_BIG = true
    cursor_width = 640/NewShopWecoc::COLUMN_MAX-32
    cursor_height = NewShopWecoc::ROW_HEIGHT
    column_max = NewShopWecoc::COLUMN_MAX
   
    x = index % column_max * 640 / column_max
    y = index / column_max * cursor_height
    rect = Rect.new(x, y, self.width - 32, 32)
    self.contents.fill_rect(rect, Color.new(0, 0, 0, 0))
    bitmap = RPG::Cache.icon(item.icon_name)
    opacity = self.contents.font.color == normal_color ? 255 : 128
    self.contents.blt(x+2, y + 4, bitmap, Rect.new(0, 0, 24, 24), opacity)
    self.contents.font.size = NewShopWecoc::TEXT_SIZE #16
    self.contents.font.bold = NewShopWecoc::TEXT_BOLD
    self.contents.draw_text(x + 30, y, 212, 32, item.name, 0)
    self.contents.draw_text(x + 30, y+20, 212, 32, "Own: "+number.to_s, 0)
    self.contents.font.size = 25
    if NewShopWecoc::SHOW_BIG_PSTATUS # SHOW_BIG_PSTATUS = true
      case item
      when RPG::Weapon # Weapon
        for i in 0...$game_party.actors.size
          itemcomp = $game_party.actors[i].weapon_id
          if $game_party.actors[i].equippable?(item)
            if itemcomp == 0 or $data_weapons[itemcomp].price < item.price # PLUS
              if self.contents.font.color != disabled_color
                self.contents.font.color = NewShopWecoc::PLUS
              end
              self.contents.draw_text(x+15+i*30, y+36, 212, 32, "+", 0)
            elsif $data_weapons[itemcomp].price == item.price # EQUAL
              if self.contents.font.color != disabled_color
                self.contents.font.color = NewShopWecoc::EQUAL
              end
              self.contents.draw_text(x+15+i*30, y+36, 212, 32, "=", 0)
            elsif $data_weapons[itemcomp].price > item.price # MINUS
              if self.contents.font.color != disabled_color
                self.contents.font.color = NewShopWecoc::MINUS
              end
              self.contents.draw_text(x+15+i*30, y+36, 212, 32, "-", 0)
            end
          else # You can't equip
            if self.contents.font.color != disabled_color
              self.contents.font.color = NewShopWecoc::OFF
            end
            self.contents.draw_text(x+15+i*30, y+36, 212, 32, "/", 0)
          end
        end
      when RPG::Armor # Armor
        for i in 0...$game_party.actors.size
          case item.kind
            when 0 ; itemcomp = $game_party.actors[i].armor1_id
            when 1 ; itemcomp = $game_party.actors[i].armor2_id
            when 2 ; itemcomp = $game_party.actors[i].armor3_id
            when 3 ; itemcomp = $game_party.actors[i].armor4_id
          end
          if $game_party.actors[i].equippable?(item)
            if itemcomp == 0 or $data_armors[itemcomp].price < item.price # PLUS
              if self.contents.font.color != disabled_color
                self.contents.font.color = NewShopWecoc::PLUS
              end
              self.contents.draw_text(x+15+i*30, y+36, 212, 32, "+", 0)
            elsif $data_armors[itemcomp].price == item.price # EQUAL
              if self.contents.font.color != disabled_color
                self.contents.font.color = NewShopWecoc::EQUAL
              end
              self.contents.draw_text(x+15+i*30, y+36, 212, 32, "=", 0)
            elsif $data_armors[itemcomp].price > item.price # MINUS
              if self.contents.font.color != disabled_color
                self.contents.font.color = NewShopWecoc::MINUS
              end
              self.contents.draw_text(x+15+i*30, y+36, 212, 32, "-", 0)
            end
          else # You can't equip
            if self.contents.font.color != disabled_color
              self.contents.font.color = NewShopWecoc::OFF
            end
            self.contents.draw_text(x+15+i*30, y+36, 212, 32, "/", 0)
          end
        end
      end
    end
    else # SHOW_OWN_BIG = false
      cursor_width = 640/NewShopWecoc::COLUMN_MAX-32
      cursor_height = NewShopWecoc::ROW_HEIGHT
      column_max = NewShopWecoc::COLUMN_MAX
     
      x = index%column_max * 640/column_max + cursor_width/2-12
      y = index/column_max * cursor_height + cursor_height/2-12
      rect = Rect.new(x, y, self.width / @column_max - 32, 32)
      self.contents.fill_rect(rect, Color.new(0, 0, 0, 0))
      bitmap = RPG::Cache.icon(item.icon_name)
      opacity = self.contents.font.color == normal_color ? 255 : 128
      self.contents.blt(x, y, bitmap, Rect.new(0, 0, 24, 24), opacity)
     
      if NewShopWecoc::SHOW_OWN_SMALL # SHOW_OWN_SMALL = true
        self.contents.font.size = NewShopWecoc::TEXT_SIZE # 16
        self.contents.font.bold = NewShopWecoc::TEXT_BOLD
        self.contents.draw_text(x+18, y+5, 32, 32, number.to_s, 0)
      end
      if NewShopWecoc::SHOW_SMALL_PSTATUS # SHOW_SMALL_PSTATUS = true
        self.contents.font.size = NewShopWecoc::TEXT_SIZE # 16
        self.contents.font.bold = NewShopWecoc::TEXT_BOLD
        case item
        when RPG::Weapon # Weapon
          itemcomp = $game_party.actors[0].weapon_id
          if $game_party.actors[0].equippable?(item)
            if itemcomp == 0 or $data_weapons[itemcomp].price < item.price # PLUS
              if self.contents.font.color != disabled_color
                self.contents.font.color = NewShopWecoc::PLUS
              end
              self.contents.draw_text(x+18, y-10, 32, 32, "+", 0)
            elsif $data_weapons[itemcomp].price == item.price # EQUAL
              if self.contents.font.color != disabled_color
                self.contents.font.color = NewShopWecoc::EQUAL
              end
              self.contents.draw_text(x+18, y-10, 32, 32, "=", 0)
            elsif $data_weapons[itemcomp].price > item.price # MINUS
              if self.contents.font.color != disabled_color
                self.contents.font.color = NewShopWecoc::MINUS
              end
              self.contents.draw_text(x+18, y-10, 32, 32, "-", 0)
            end
          end
        when RPG::Armor # Armor
          case item.kind
            when 0 ; itemcomp = $game_party.actors[0].armor1_id
            when 1 ; itemcomp = $game_party.actors[0].armor2_id
            when 2 ; itemcomp = $game_party.actors[0].armor3_id
            when 3 ; itemcomp = $game_party.actors[0].armor4_id
          end
          if $game_party.actors[0].equippable?(item)
            if itemcomp == 0 or $data_armors[itemcomp].price < item.price # PLUS
              if self.contents.font.color != disabled_color
                self.contents.font.color = NewShopWecoc::PLUS
              end
              self.contents.draw_text(x+18, y-10, 32, 32, "+", 0)
            elsif $data_armors[itemcomp].price == item.price # EQUAL
              if self.contents.font.color != disabled_color
                self.contents.font.color = NewShopWecoc::EQUAL
              end
              self.contents.draw_text(x+18, y-10, 32, 32, "=", 0)
            elsif $data_armors[itemcomp].price > item.price # MINUS
              if self.contents.font.color != disabled_color
                self.contents.font.color = NewShopWecoc::MINUS
              end
              self.contents.draw_text(x+18, y-14, 32, 32, "-", 0)
            end
          end
        end
      end     
    end
  end

  def update_help
    @help_window.set_text(self.item == nil ? "" : self.item.description)
  end
end

#------------------------------------------------------------------------------
# Window_ShopSell
#------------------------------------------------------------------------------

class Window_ShopSell < Window_Selectable

  # initialize considering COLUMN_MAX y ROW_HEIGHT
  def initialize
    super(0, 128, 640, 352)
    @column_max = NewShopWecoc::COLUMN_MAX
    self.rowHeight=NewShopWecoc::ROW_HEIGHT
    refresh
    self.index = 0
  end

  def item
    return @data[self.index]
  end

  # refresh with @row_height correction
  def refresh
    if self.contents != nil
      self.contents.dispose
      self.contents = nil
    end
    @data = []
    for i in 1...$data_items.size
      if $game_party.item_number(i) > 0
        @data.push($data_items[i])
      end
    end
    for i in 1...$data_weapons.size
      if $game_party.weapon_number(i) > 0
        @data.push($data_weapons[i])
      end
    end
    for i in 1...$data_armors.size
      if $game_party.armor_number(i) > 0
        @data.push($data_armors[i])
      end
    end
    @item_max = @data.size
    if @item_max > 0
      self.contents = Bitmap.new(width - 32, row_max * @row_height)
      for i in 0...@item_max
        draw_item(i)
      end
    end
  end

  # draw_item (the most configurable part)
  def draw_item(index)
    item = @data[index]
    case item
    when RPG::Item # Item
      number = $game_party.item_number(item.id)
    when RPG::Weapon # Weapon
      number = $game_party.weapon_number(item.id)
    when RPG::Armor # Armor
      number = $game_party.armor_number(item.id)
    end
    if item.price > 0
      self.contents.font.color = normal_color
    else
      self.contents.font.color = disabled_color
    end
   
  if NewShopWecoc::SHOW_OWN_BIG # SHOW_OWN_BIG = true
    cursor_width = 640/NewShopWecoc::COLUMN_MAX-32
    cursor_height = NewShopWecoc::ROW_HEIGHT
    column_max = NewShopWecoc::COLUMN_MAX
   
    x = index % column_max * 640 / column_max
    y = index / column_max * cursor_height
   
    rect = Rect.new(x, y, self.width / @column_max - 32, 32)
    self.contents.fill_rect(rect, Color.new(0, 0, 0, 0))
    bitmap = RPG::Cache.icon(item.icon_name)
    opacity = self.contents.font.color == normal_color ? 255 : 128
    self.contents.blt(x+2, y+4, bitmap, Rect.new(0, 0, 24, 24), opacity)
    self.contents.font.size = NewShopWecoc::TEXT_SIZE #16
    self.contents.font.bold = NewShopWecoc::TEXT_BOLD
    self.contents.draw_text(x + 30, y, 212, 32, item.name, 0)
    self.contents.draw_text(x + 30, y+20, 212, 32, "Own: "+number.to_s, 0)
    self.contents.font.size = 25
    if NewShopWecoc::SHOW_BIG_PSTATUS # SHOW_BIG_PSTATUS = true
      case item
      when RPG::Weapon
        for i in 0...$game_party.actors.size
          itemcomp = $game_party.actors[i].weapon_id
          if $game_party.actors[i].equippable?(item)
            if itemcomp == 0 or $data_weapons[itemcomp].price < item.price # PLUS
              if self.contents.font.color != disabled_color
                self.contents.font.color = NewShopWecoc::PLUS
              end
              self.contents.draw_text(x+15+i*30, y+36, 212, 32, "+", 0)
            elsif $data_weapons[itemcomp].price == item.price # EQUAL
              if self.contents.font.color != disabled_color
                self.contents.font.color = NewShopWecoc::EQUAL
              end
              self.contents.draw_text(x+15+i*30, y+36, 212, 32, "=", 0)
            elsif $data_weapons[itemcomp].price > item.price # MINUS
              if self.contents.font.color != disabled_color
                self.contents.font.color = NewShopWecoc::MINUS
              end
              self.contents.draw_text(x+15+i*30, y+36, 212, 32, "-", 0)
            end
          else # You can't equip
            if self.contents.font.color != disabled_color
              self.contents.font.color = NewShopWecoc::OFF
            end
            self.contents.draw_text(x+15+i*30, y+36, 212, 32, "/", 0)
          end
        end
      when RPG::Armor
        for i in 0...$game_party.actors.size
          case item.kind
            when 0 ; itemcomp = $game_party.actors[i].armor1_id
            when 1 ; itemcomp = $game_party.actors[i].armor2_id
            when 2 ; itemcomp = $game_party.actors[i].armor3_id
            when 3 ; itemcomp = $game_party.actors[i].armor4_id
          end
          if $game_party.actors[i].equippable?(item)
            if itemcomp == 0 or $data_armors[itemcomp].price < item.price # PLUS
              if self.contents.font.color != disabled_color
                self.contents.font.color = NewShopWecoc::PLUS
              end
              self.contents.draw_text(x+15+i*30, y+36, 212, 32, "+", 0)
            elsif $data_armors[itemcomp].price == item.price # EQUAL
              if self.contents.font.color != disabled_color
                self.contents.font.color = NewShopWecoc::EQUAL
              end
              self.contents.draw_text(x+15+i*30, y+36, 212, 32, "=", 0)
            elsif $data_armors[itemcomp].price > item.price # MINUS
              if self.contents.font.color != disabled_color
                self.contents.font.color = NewShopWecoc::MINUS
              end
              self.contents.draw_text(x+15+i*30, y+36, 212, 32, "-", 0)
            end
          else # You can't equip
            if self.contents.font.color != disabled_color
              self.contents.font.color = NewShopWecoc::OFF
            end
            self.contents.draw_text(x+15+i*30, y+36, 212, 32, "/", 0)
          end
        end
      end
    end
    else # SHOW_OWN_BIG = false
      cursor_width = 640/NewShopWecoc::COLUMN_MAX-32
      cursor_height = NewShopWecoc::ROW_HEIGHT
      column_max = NewShopWecoc::COLUMN_MAX
     
      x = index%column_max * 640/column_max + cursor_width/2-12
      y = index/column_max * cursor_height + cursor_height/2-12
      rect = Rect.new(x, y, self.width / @column_max - 32, 32)
      self.contents.fill_rect(rect, Color.new(0, 0, 0, 0))
      bitmap = RPG::Cache.icon(item.icon_name)
      opacity = self.contents.font.color == normal_color ? 255 : 128
      self.contents.blt(x, y, bitmap, Rect.new(0, 0, 24, 24), opacity)
     
      if NewShopWecoc::SHOW_OWN_SMALL # SHOW_OWN_SMALL = true
        self.contents.font.size = NewShopWecoc::TEXT_SIZE # 16
        self.contents.font.bold = NewShopWecoc::TEXT_BOLD
        self.contents.draw_text(x+18, y+5, 32, 32, number.to_s, 0)
      end
      if NewShopWecoc::SHOW_SMALL_PSTATUS # SHOW_SMALL_PSTATUS = true
        self.contents.font.size = NewShopWecoc::TEXT_SIZE # 16
        self.contents.font.bold = NewShopWecoc::TEXT_BOLD
        case item
        when RPG::Weapon # Weapon
          itemcomp = $game_party.actors[0].weapon_id
          if $game_party.actors[0].equippable?(item)
            if itemcomp == 0 or $data_weapons[itemcomp].price < item.price # PLUS
              if self.contents.font.color != disabled_color
                self.contents.font.color = NewShopWecoc::PLUS
              end
              self.contents.draw_text(x+18, y-10, 32, 32, "+", 0)
            elsif $data_weapons[itemcomp].price == item.price # EQUAL
              if self.contents.font.color != disabled_color
                self.contents.font.color = NewShopWecoc::EQUAL
              end
              self.contents.draw_text(x+18, y-10, 32, 32, "=", 0)
            elsif $data_weapons[itemcomp].price > item.price # MINUS
              if self.contents.font.color != disabled_color
                self.contents.font.color = NewShopWecoc::MINUS
              end
              self.contents.draw_text(x+18, y-10, 32, 32, "-", 0)
            end
          end
        when RPG::Armor # Armor
          case item.kind
            when 0 ; itemcomp = $game_party.actors[0].armor1_id
            when 1 ; itemcomp = $game_party.actors[0].armor2_id
            when 2 ; itemcomp = $game_party.actors[0].armor3_id
            when 3 ; itemcomp = $game_party.actors[0].armor4_id
          end
          if $game_party.actors[0].equippable?(item)
            if itemcomp == 0 or $data_armors[itemcomp].price < item.price # PLUS
              if self.contents.font.color != disabled_color
                self.contents.font.color = NewShopWecoc::PLUS
              end
              self.contents.draw_text(x+18, y-10, 32, 32, "+", 0)
            elsif $data_armors[itemcomp].price == item.price # IGUAL
              if self.contents.font.color != disabled_color
                self.contents.font.color = NewShopWecoc::EQUAL
              end
              self.contents.draw_text(x+18, y-10, 32, 32, "=", 0)
            elsif $data_armors[itemcomp].price > item.price # MINUS
              if self.contents.font.color != disabled_color
                self.contents.font.color = NewShopWecoc::MINUS
              end
              self.contents.draw_text(x+18, y-14, 32, 32, "-", 0)
            end
          end
        end
      end     
    end
  end

  def update_help
    @help_window.set_text(self.item == nil ? "" : self.item.description)
  end
end

#------------------------------------------------------------------------------
# Window_ShopGold
#------------------------------------------------------------------------------

class Window_ShopGold < Window_Base

  def initialize
    @buying = true
    super(230,0,120,64)
    self.z = 9980
    self.contents = Bitmap.new(width - 32, height - 32)
  end

  def refresh
    self.contents.clear
    if @item == nil
      return
    end
    case @item
    when RPG::Item
      number = $game_party.item_number(@item.id)
    when RPG::Weapon
      number = $game_party.weapon_number(@item.id)
    when RPG::Armor
      number = $game_party.armor_number(@item.id)
    end

    self.contents.font.color = normal_color
    if @item.price == 0
      self.contents.font.color = disabled_color
    end
    if ($game_party.gold < @item.price) and buying?
      self.contents.font.color = disabled_color
    end
    if number == 99 and buying?
      self.contents.font.color = disabled_color
    end
    if buying?
      gold = $data_system.words.gold
      self.contents.draw_text(0,0,120-32,32,@item.price.to_s+gold,1)
    else
      gold = $data_system.words.gold
      self.contents.draw_text(0,0,120-32,32,(@item.price/2).to_s+gold,1)
    end
  end

  def buying?
    return @buying
  end

  def buying=(value)
    @buying = value
  end

  def item=(value)
    @item=value
  end
end

#==============================================================================
# Scene_Shop
#==============================================================================

class Scene_Shop
  def main
    # Window_Help - Window with the description of each object
    @help_window = Window_Help.new
    # Window_ShopCommand - "Buy", "Sell", "Leave"
    @command_window = Window_ShopCommand.new
   
    # Window_Gold - Window with the money group owns
    @gold_window = Window_Gold.new
    @gold_window.x = 480
    @gold_window.y = 64
   
    # Window_Base - Empty window for when you're not buying or selling
    @dummy_window = Window_Base.new(0, 128, 640, 352)
   
    # Window_ShopBuy - Window with the objects to buy
    @buy_window = Window_ShopBuy.new($game_temp.shop_goods)
    @buy_window.active = false
    @buy_window.visible = false
    @buy_window.help_window = @help_window
   
    # Window_ShopSell - Window with the objects to sell
    @sell_window = Window_ShopSell.new
    @sell_window.active = false
    @sell_window.visible = false
    @sell_window.help_window = @help_window
   
    # Window_ShopNumber - It shows the number of objects to buy or sell
    @number_window = Window_ShopNumber.new
    @number_window.z = 1000
    @number_window.active = false
    @number_window.visible = false

    # Window_ShopGold - Window with the price of each object
    @shopgold_window = Window_ShopGold.new
    @shopgold_window.visible = false

    Graphics.transition
    loop do
      Graphics.update
      Input.update
      update
      if $scene != self
        break
      end
    end
    Graphics.freeze
    @help_window.dispose
    @command_window.dispose
    @gold_window.dispose
    @dummy_window.dispose
    @buy_window.dispose
    @sell_window.dispose
    @shopgold_window.dispose
    @number_window.dispose
  end

  def update
    @help_window.update
    @command_window.update
    @gold_window.update
    @dummy_window.update
    @buy_window.update
    @sell_window.update
    @number_window.update
    if @command_window.active
      update_command
      return
    end
    if @buy_window.active
      update_buy
      return
    end
    if @sell_window.active
      update_sell
      return
    end
    if @number_window.active
      update_number
      return
    end
  end

  def update_command
    if Input.trigger?(Input::B) # Cancel
      $game_system.se_play($data_system.cancel_se)
      $scene = Scene_Map.new
      return
    end
    if Input.trigger?(Input::C) # Accept
      case @command_window.index
      when 0  # Buy
        $game_system.se_play($data_system.decision_se)
        @command_window.active = false
        @dummy_window.visible = false
        @buy_window.active = true
        @buy_window.visible = true
        @buy_window.refresh
       
        @shopgold_window.buying = true
        shopgold_position # Price window position
        @shopgold_window.visible = true
        @shopgold_window.refresh
      when 1  # Sell
        $game_system.se_play($data_system.decision_se)
        @command_window.active = false
        @dummy_window.visible = false
        @sell_window.active = true
        @sell_window.visible = true
        @sell_window.refresh
       
        @shopgold_window.buying = false
        shopgold_position # Price window position
        @shopgold_window.visible = true
        @shopgold_window.refresh
      when 2  # Leave
        $game_system.se_play($data_system.decision_se)
        $scene = Scene_Map.new
      end
      return
    end
  end

  def update_buy
    if Input.press?(Input.dir4) # Moving around the window
      @shopgold_window.buying = true
      shopgold_position # Price window position
      @shopgold_window.visible = true
      @shopgold_window.refresh
    end
    if Input.trigger?(Input::B) # Cancel
      $game_system.se_play($data_system.cancel_se)
      @shopgold_window.visible = false
      @command_window.active = true
      @dummy_window.visible = true
      @buy_window.active = false
      @buy_window.visible = false
      @help_window.set_text("")
      return
    end
    if Input.trigger?(Input::C) # Accept
      @item = @buy_window.item
      if @item == nil or @item.price > $game_party.gold
        $game_system.se_play($data_system.buzzer_se)
        return
      end
      case @item
      when RPG::Item
        number = $game_party.item_number(@item.id)
      when RPG::Weapon
        number = $game_party.weapon_number(@item.id)
      when RPG::Armor
        number = $game_party.armor_number(@item.id)
      end
      if number == 99
        $game_system.se_play($data_system.buzzer_se)
        return
      end
      if NewShopWecoc::SHOW_NUMBER # Number Window
        $game_system.se_play($data_system.decision_se)
        max = @item.price == 0 ? 99 : $game_party.gold / @item.price
        max = [max, 99 - number].min
        @number_window.set(@item, max, @item.price)
        @number_window.active = true
        @number_window.visible = true
        @buy_window.active = false
        @shopgold_window.visible = false
      else
        $game_system.se_play($data_system.shop_se)
        case @item
        when RPG::Item
          $game_party.gain_item(@item.id, 1)
        when RPG::Weapon
          $game_party.gain_weapon(@item.id, 1)
        when RPG::Armor
          $game_party.gain_armor(@item.id, 1)
        end
        $game_party.lose_gold(@item.price)
        @buy_window.refresh
        @gold_window.refresh
        @shopgold_window.refresh
      end
    end
  end

  def update_sell
    if Input.press?(Input.dir4) # Moving around the window
      @shopgold_window.buying = false
      shopgold_position # Price window position
      @shopgold_window.visible = true
      @shopgold_window.refresh
    end
    if Input.trigger?(Input::B)
      $game_system.se_play($data_system.cancel_se)
      @shopgold_window.visible = false
      @command_window.active = true
      @dummy_window.visible = true
      @sell_window.active = false
      @sell_window.visible = false
      @help_window.set_text("")
      return
    end
    if Input.trigger?(Input::C)
      @item = @sell_window.item
      if @item == nil or @item.price == 0
        $game_system.se_play($data_system.buzzer_se)
        return
      end
      if NewShopWecoc::SHOW_NUMBER # Number Window
        $game_system.se_play($data_system.decision_se)
        case @item
        when RPG::Item
          number = $game_party.item_number(@item.id)
        when RPG::Weapon
          number = $game_party.weapon_number(@item.id)
        when RPG::Armor
          number = $game_party.armor_number(@item.id)
        end
        max = number
        @sell_window.active = false
        @shopgold_window.visible = false
        @number_window.set(@item, max, @item.price / 2)
        @number_window.active = true
        @number_window.visible = true
      else
        $game_system.se_play($data_system.shop_se)
        $game_party.gain_gold(@item.price / 2)
        case @item
        when RPG::Item
          $game_party.lose_item(@item.id, 1)
        when RPG::Weapon
          $game_party.lose_weapon(@item.id, 1)
        when RPG::Armor
          $game_party.lose_armor(@item.id, 1)
        end
        @gold_window.refresh
        @sell_window.refresh
        @shopgold_window.item = @sell_window.item
        @shopgold_window.refresh
      end
    end
  end

  def update_number
    if Input.trigger?(Input::B) # Cancel
      $game_system.se_play($data_system.cancel_se)
      @number_window.active = false
      @number_window.visible = false
      case @command_window.index
      when 0  # Buy
        @buy_window.active = true
        @buy_window.visible = true
      when 1  # Sell
        @sell_window.active = true
        @sell_window.visible = true
      end
      return
    end
    if Input.trigger?(Input::C) # Accept
      $game_system.se_play($data_system.shop_se)
      @number_window.active = false
      @number_window.visible = false
      case @command_window.index
      when 0  # Buy
        $game_party.lose_gold(@number_window.number * @item.price)
        case @item
        when RPG::Item
          $game_party.gain_item(@item.id, @number_window.number)
        when RPG::Weapon
          $game_party.gain_weapon(@item.id, @number_window.number)
        when RPG::Armor
          $game_party.gain_armor(@item.id, @number_window.number)
        end
        @gold_window.refresh
        @buy_window.refresh
        @shopgold_window.refresh
       
        @buy_window.active = true
        @shopgold_window.visible = true
      when 1  # Sell
        $game_party.gain_gold(@number_window.number * (@item.price / 2))
        case @item
        when RPG::Item
          $game_party.lose_item(@item.id, @number_window.number)
        when RPG::Weapon
          $game_party.lose_weapon(@item.id, @number_window.number)
        when RPG::Armor
          $game_party.lose_armor(@item.id, @number_window.number)
        end
        @gold_window.refresh
        @sell_window.refresh
        @shopgold_window.item = @sell_window.item
        @shopgold_window.refresh

        @sell_window.active = true
        @shopgold_window.visible = true
      end
      return
    end
  end

  def shopgold_position # Window position (centered with the cursor)
    if @buy_window.visible == true # Buy
      @shopgold_window.item = @buy_window.item
      cursor_width = 640/NewShopWecoc::COLUMN_MAX-32
      cursor_height = NewShopWecoc::ROW_HEIGHT
      column_max = NewShopWecoc::COLUMN_MAX
      window_width = @shopgold_window.width
      index = @buy_window.index
     
      @shopgold_window.x = index%column_max * 640/column_max +
                          cursor_width/2-(window_width/2)+16
      @shopgold_window.x = [@shopgold_window.x, 5].max
      @shopgold_window.x = [@shopgold_window.x, 640-5-@shopgold_window.width].min
      @shopgold_window.y = index/column_max*cursor_height-
                          @buy_window.top_row*cursor_height+76
    else # Sell
      @shopgold_window.item = @sell_window.item
      cursor_width = 640/NewShopWecoc::COLUMN_MAX-32
      cursor_height = NewShopWecoc::ROW_HEIGHT
      column_max = NewShopWecoc::COLUMN_MAX
      window_width = @shopgold_window.width
      index = @sell_window.index
     
      @shopgold_window.x = index%column_max * 640/column_max +
                          cursor_width/2-(window_width/2)+16
      @shopgold_window.x = [@shopgold_window.x, 5].max
      @shopgold_window.x = [@shopgold_window.x, 640-5-@shopgold_window.width].min
      @shopgold_window.y = index/column_max*cursor_height-
                          @sell_window.top_row*cursor_height+76
    end
  end
end



Instructions

Not much to say, module NewShopWecoc is on the top of the code.


Compatibility

Not compatible with other shop systems but yes with anything else.


Credits and Thanks


  • Wecoc




Author's Notes

If you have any problem with that script or with incompatibilities don't hestitate to ask. If you need it I also can make a demo.
34
RMXP Script Database / [XP] Window_InputNumber Edit
February 07, 2013, 12:20:31 am
Window_InputNumber Edit
Authors: Wecoc
Version: 1.1
Type: Message Add-On
Key Term: Message Add-on



Introduction

Today I bring a relatively simple edit of Window_InputNumber.
What it does is allow other characters besides the default numbers.
There are some examples and facts in the script, but you can add those you want at the top of the code.
Examples on the script:
default => default system, 0 to 9
binary => 0 and 1
hexa => 0 to 9 and A to F
upcase_letters => space and UPCASE letters
all_letters => space, UPCASE letters and lowcase letters
all_characters => soace, UPCASE letters, lowcase letters, 0 to 9, +, - , *, /, !, #, $, %, &, @, point, comma, dash



Features


  • Easy configurable

  • Automatic cursor width

  • You can use words too (for example "Hello", "World")




Screenshots

Spoiler: ShowHide






Script

Window_Input Edit 1.1
Spoiler: ShowHide

#==============================================================================
# Window_InputNumber Edit by Wecoc (version 1.1)
#==============================================================================

class Game_Temp
  attr_accessor :input_type
  alias input_type_initialize initialize
  def initialize
    input_type_initialize
    @input_type = "default"
  end
end

class Window_InputNumber < Window_Base
  def initialize(digits_max,type="default")
    case type
    when "default"
      @character_array = ["0","1","2","3","4","5","6","7","8","9"]
    when "binary"
      @character_array = ["0","1"]
    when "hexa"
      @character_array = ["0","1","2","3","4","5","6","7","8","9",
                          "A","B","C","D","E","F"]
    when "upcase_letters"
      @character_array = [" ","A","B","C","D","E","F","G","H","I",
                          "J","K","L","M","N","O","P","Q","R","S",
                          "T","U","V","W","X","Y","Z"]
    when "all_letters"
      @character_array = [" ","A","B","C","D","E","F","G","H","I",
                          "J","K","L","M","N","O","P","Q","R","S",
                          "T","U","V","W","X","Y","Z","a","b","c",
                          "d","e","f","g","h","i","j","k","l","m",
                          "n","o","p","q","r","s","t","u","v","w",
                          "x","y","z"]
    when "all_characters"
      @character_array = [" ","A","B","C","D","E","F","G","H","I",
                          "J","K","L","M","N","O","P","Q","R","S",
                          "T","U","V","W","X","Y","Z","a","b","c",
                          "d","e","f","g","h","i","j","k","l","m",
                          "n","o","p","q","r","s","t","u","v","w",
                          "x","y","z","0","1","2","3","4","5","6",
                          "7","8","9","+","-","*","/","!","#","$",
                          "%","&","@",".",",","-"]
    # when...
    end
    @digits_max = digits_max
    @type = type
    @letter_array = []
    @digits_max.times{@letter_array.push(0)}
    dummy_bitmap = Bitmap.new(32, 32)
   
    @cursor_width = 8
    for i in 0...@character_array.size
      letter_size = dummy_bitmap.text_size(@character_array[i]).width + 8
      @cursor_width = [@cursor_width, letter_size].max
    end
    dummy_bitmap.dispose
    super(0, 0, @cursor_width * @digits_max + 32, 64)
    self.contents = Bitmap.new(width - 32, height - 32)
    self.z += 9999
    self.opacity = 0
    @index = 0
    refresh
    update_cursor_rect
  end

  def letter(index)
    return @character_array[@letter_array[index]]
  end

  def increase_letter_array(index)
    if @letter_array[index] == (@character_array.size-1)
      @letter_array[index] = 0
    else
      @letter_array[index] += 1
    end
  end

  def decrease_letter_array(index)
    if @letter_array[index] == 0
      @letter_array[index] = (@character_array.size-1)
    else
      @letter_array[index] -= 1
    end
  end

  def update_cursor_rect
    self.cursor_rect.set(@index * @cursor_width, 0, @cursor_width, 32)
  end

  def update
    super
    if Input.repeat?(Input::UP)
      $game_system.se_play($data_system.cursor_se)
      increase_letter_array(@index)
      refresh
    end
    if Input.repeat?(Input::DOWN)
      $game_system.se_play($data_system.cursor_se)
      decrease_letter_array(@index)
      refresh
    end
    if Input.repeat?(Input::RIGHT)
      if @digits_max >= 2
        $game_system.se_play($data_system.cursor_se)
        @index = (@index + 1) % @digits_max
      end
    end
    if Input.repeat?(Input::LEFT)
      if @digits_max >= 2
        $game_system.se_play($data_system.cursor_se)
        @index = (@index + @digits_max - 1) % @digits_max
      end
    end
    if Input.trigger?(Input::B)
      @letter_array[@index] = 0
      refresh
    end
    update_cursor_rect
  end

  def refresh
    self.contents.clear
    self.contents.font.color = normal_color
    for i in 0...@digits_max
      self.contents.draw_text(i*@cursor_width,0,@cursor_width,32,letter(i),1)
    end
  end

  def number
    @number = []
    for i in 0...@digits_max
      @number.push(letter(i))
    end
    if @number.to_s.to_i != 0 and @number.to_s != "0"
      return @number.to_s.to_i
    else
      return @number.to_s
    end
  end

  def number=(number)
    if number != 0
      if number.is_a?(Integer)
        num = number.to_s
      else
        num = number
      end
      @array = num.scan(/./)
      if @array.size != @digits_max
        begin
          @array.unshift(@character_array[0])
        end until @array.size == @digits_max
      end
      for i in 0...@digits_max
        for j in 0..@character_array.size
          if @array[i] == @character_array[j]
            @letter_array[i] = j
          end
        end
      end
    end
    refresh
  end
end


Window_Message Edit
Spoiler: ShowHide
#==============================================================================
# ** Window_Message EDIT
#==============================================================================

class Window_Message < Window_Selectable
  def refresh
    self.contents.clear
    self.contents.font.color = normal_color
    x = y = 0
    @cursor_width = 0
    if $game_temp.choice_start == 0
      x = 8
    end
    if $game_temp.message_text != nil
      text = $game_temp.message_text
      begin
        last_text = text.clone
        text.gsub!(/\\[Vv]\[([0-9]+)\]/) { $game_variables[$1.to_i] }
      end until text == last_text
      text.gsub!(/\\[Nn]\[([0-9]+)\]/) do
        $game_actors[$1.to_i] != nil ? $game_actors[$1.to_i].name : ""
      end
      text.gsub!(/\\\\/) { "\000" }
      text.gsub!(/\\[Cc]\[([0-9]+)\]/) { "\001[#{$1}]" }
      text.gsub!(/\\[Gg]/) { "\002" }
      while ((c = text.slice!(/./m)) != nil)
        if c == "\000"
          c = "\\"
        end
        if c == "\001"
          text.sub!(/\[([0-9]+)\]/, "")
          color = $1.to_i
          if color >= 0 and color <= 7
            self.contents.font.color = text_color(color)
          end
          next
        end
        if c == "\002"
          if @gold_window == nil
            @gold_window = Window_Gold.new
            @gold_window.x = 560 - @gold_window.width
            if $game_temp.in_battle
              @gold_window.y = 192
            else
              @gold_window.y = self.y >= 128 ? 32 : 384
            end
            @gold_window.opacity = self.opacity
            @gold_window.back_opacity = self.back_opacity
          end
          next
        end
        if c == "\n"
          if y >= $game_temp.choice_start
            @cursor_width = [@cursor_width, x].max
          end
          y += 1
          x = 0
          if y >= $game_temp.choice_start
            x = 8
          end
          next
        end
        self.contents.draw_text(4 + x, 32 * y, 40, 32, c)
        x += self.contents.text_size(c).width
      end
    end
    if $game_temp.choice_max > 0
      @item_max = $game_temp.choice_max
      self.active = true
      self.index = 0
    end
    ######################### EDIT ############################
    if $game_temp.num_input_variable_id > 0
      digits_max = $game_temp.num_input_digits_max
      number = $game_variables[$game_temp.num_input_variable_id]
      @input_number_window = Window_InputNumber.new(digits_max, $game_temp.input_type)
      @input_number_window.number = number
      @input_number_window.x = self.x + 8
      @input_number_window.y = self.y + $game_temp.num_input_start * 32
    end
    ###########################################################
  end
  def update
    super
    if @fade_in
      self.contents_opacity += 24
      if @input_number_window != nil
        @input_number_window.contents_opacity += 24
      end
      if self.contents_opacity == 255
        @fade_in = false
      end
      return
    end
    ######################### EDIT ############################
    if @input_number_window != nil
      @input_number_window.update
      if Input.trigger?(Input::C)
        if @input_number_window.number.is_a?(Integer)
          input_develop = @input_number_window.number.to_s.gsub(/ /) { nil }
        else
          input_develop = @input_number_window.number.gsub(/ /) { nil }
        end
        if input_develop.empty?
          $game_system.se_play($data_system.buzzer_se)
          return
        end
        $game_system.se_play($data_system.decision_se)
        $game_variables[$game_temp.num_input_variable_id] =
          @input_number_window.number
        $game_map.need_refresh = true
        @input_number_window.dispose
        @input_number_window = nil
        terminate_message
      end
      return
    end
    ###########################################################
    if @contents_showing
      if $game_temp.choice_max == 0
        self.pause = true
      end
      if Input.trigger?(Input::B)
        if $game_temp.choice_max > 0 and $game_temp.choice_cancel_type > 0
          $game_system.se_play($data_system.cancel_se)
          $game_temp.choice_proc.call($game_temp.choice_cancel_type - 1)
          terminate_message
        end
      end
      if Input.trigger?(Input::C)
        if $game_temp.choice_max > 0
          $game_system.se_play($data_system.decision_se)
          $game_temp.choice_proc.call(self.index)
        end
        terminate_message
      end
      return
    end
    if @fade_out == false and $game_temp.message_text != nil
      @contents_showing = true
      $game_temp.message_window_showing = true
      reset_window
      refresh
      Graphics.frame_reset
      self.visible = true
      self.contents_opacity = 0
      if @input_number_window != nil
        @input_number_window.contents_opacity = 0
      end
      @fade_in = true
      return
    end
    if self.visible
      @fade_out = true
      self.opacity -= 48
      if self.opacity == 0
        self.visible = false
        @fade_out = false
        $game_temp.message_window_showing = false
      end
      return
    end
  end
end



Instructions

To call use the the numerical input command as always. If you want to change the type of input_number on game, you have to put this before the input call:
$game_temp.input_type = "(type)" (for example $game_temp.input_type = "upcase_letters")


Compatibility

See Author's Notes.


Credits and Thanks


  • Wecoc




Author's Notes

First script is the principal one and it has no compatibility problems. But second one controls calling (just as an example) and it's not compatible with message scripts. That's why they are separate. If you use some personalized message system, you can get the parts between ##### (edited parts) and paste on your script. If you have any problem with that don't hestitate to ask.

First script is also completely independent of the second one.
35
RMXP Script Database / [XP][VX] Window tone
January 16, 2013, 07:48:59 am
Window Tone
Authors: Wecoc
Version: 1.1
Type: Window Add-On
Key Term: Misc Add-on



Introduction

This is a simple Add-On for XP and VX that allows you to change the Window tones on game (in Ace that function already exists) You can change 'back' tone, 'cursor' tone and 'border' tone separately. I used the Window class from Pokemon Essentials as a base to make this.



Features


  • Red, Green, Blue and Gray are managed separately.

  • Different window sprites ('back', 'cursor' and 'border') are managed separately.

  • get, set and increase(positive or negative) color values.

  • Where are you from? Do you spell gray or grey? It doesn't matter, it supports both.




Screenshots

Spoiler: ShowHide






Script

Spoiler: ShowHide
#==============================================================================
# [XP][VX] Window tone (by Wecoc) v. 1.1
# (Window de Pokemon Essentials)
#==============================================================================
#==============================================================================
# Game_System
#==============================================================================


class Game_System
  attr_accessor :back_r
  attr_accessor :back_g
  attr_accessor :back_b
  attr_accessor :back_s

  attr_accessor :cursor_r
  attr_accessor :cursor_g
  attr_accessor :cursor_b
  attr_accessor :cursor_s

  attr_accessor :border_r
  attr_accessor :border_g
  attr_accessor :border_b
  attr_accessor :border_s

  alias ini initialize unless $@
  def initialize
    ini
    @back_r = 0
    @back_g = 0
    @back_b = 0
    @back_s = 0

    @cursor_r = 0
    @cursor_g = 0
    @cursor_b = 0
    @cursor_s = 0

    @border_r = 0
    @border_g = 0
    @border_b = 0
    @border_s = 0
  end
end

class WindowCursorRect < Rect
  def initialize(window)
    @window=window
    @x=0
    @y=0
    @width=0
    @height=0
  end
  attr_reader :x,:y,:width,:height
  def empty
    needupdate=@x!=0 || @y!=0 || @width!=0 || @height!=0
    if needupdate
    @x=0
    @y=0
    @width=0
    @height=0
    @window.width=@window.width
    end
  end
  def isEmpty?
  return @x==0 && @y==0 && @width==0 && @height==0
  end
  def set(x,y,width,height)
    needupdate=@x!=x || @y!=y || @width!=width || @height!=height
    if needupdate
    @x=x
    @y=y
    @width=width
    @height=height
    @window.width=@window.width
    end
  end
  def height=(value)
    @height=value; @window.width=@window.width
  end
  def width=(value)
    @width=value; @window.width=@window.width
  end
  def x=(value)
    @x=value; @window.width=@window.width
  end
  def y=(value)
    @y=value; @window.width=@window.width
  end
end

#==============================================================================
# Window
#==============================================================================

class Window
attr_reader :tone
attr_reader :color
attr_reader :blend_type
attr_reader :contents_blend_type
attr_reader :viewport
attr_reader :contents
attr_reader :ox
attr_reader :oy
attr_reader :x
attr_reader :y
attr_reader :z
attr_reader :width
attr_reader :active
attr_reader :pause
attr_reader :height
attr_reader :opacity
attr_reader :back_opacity
attr_reader :contents_opacity
attr_reader :visible
attr_reader :cursor_rect
attr_reader :openness
attr_reader :stretch
def windowskin
  @_windowskin
end
def initialize(viewport=nil)
  @sprites={}
  @spritekeys=[
  "back",
  "corner0","side0","scroll0",
  "corner1","side1","scroll1",
  "corner2","side2","scroll2",
  "corner3","side3","scroll3",
  "cursor","contents","pause"
  ]
  @sidebitmaps=[nil,nil,nil,nil]
  @cursorbitmap=nil
  @bgbitmap=nil
  @viewport=viewport
  for i in @spritekeys
  @sprites[i]=Sprite.new(@viewport)
  end
  @disposed=false
  @tone=Tone.new(0,0,0)
  @color=Color.new(0,0,0,0)

  @back_r = $game_system.back_r
  @back_g = $game_system.back_g
  @back_b = $game_system.back_b
  @back_s = $game_system.back_s

  @cursor_r = $game_system.cursor_r
  @cursor_g = $game_system.cursor_g
  @cursor_b = $game_system.cursor_b
  @cursor_s = $game_system.cursor_s

  @border_r = $game_system.border_r
  @border_g = $game_system.border_g
  @border_b = $game_system.border_b
  @border_s = $game_system.border_s

  @blankcontents=Bitmap.new(1,1)
  @contents=@blankcontents
  @_windowskin=nil
  @rpgvx=false
  @x=0
  @y=0
  @width=0
  @openness=255
  @height=0
  @ox=0
  @oy=0
  @z=0
  @stretch=true
  @visible=true
  @active=true
  @blend_type=0
  @contents_blend_type=0
  @opacity=255
  @back_opacity=255
  @contents_opacity=255
  @cursor_rect=WindowCursorRect.new(self)
  @cursorblink=0
  @cursoropacity=255
  @pause=false
  @pauseopacity=255
  @pauseframe=0
  privRefresh(true)
end
def dispose
  if !self.disposed?
  for i in @sprites
    i[1].dispose if i[1]
    @sprites[i[0]]=nil
  end
  for i in 0...@sidebitmaps.length
    @sidebitmaps[i].dispose if @sidebitmaps[i]
    @sidebitmaps[i]=nil
  end
  @blankcontents.dispose
  @cursorbitmap.dispose if @cursorbitmap
  @backbitmap.dispose if @backbitmap
  @sprites.clear
  @sidebitmaps.clear
  @_windowskin=nil
  @_contents=nil
  @disposed=true

  $game_system.back_r = @back_r
  $game_system.back_g = @back_g
  $game_system.back_b = @back_b
  $game_system.back_s = @back_s

  $game_system.cursor_r = @cursor_r
  $game_system.cursor_g = @cursor_g
  $game_system.cursor_b = @cursor_b
  $game_system.cursor_s = @cursor_s

  $game_system.border_r = @border_r
  $game_system.border_g = @border_g
  $game_system.border_b = @border_b
  $game_system.border_s = @border_s
  end
end
def openness=(value)
  @openness=value
  @openness=0 if @openness<0
  @openness=255 if @openness>255
  privRefresh
end
def stretch=(value)
  @stretch=value
  privRefresh(true)
end
def visible=(value)
  @visible=value
  privRefresh
end
def viewport=(value)
  @viewport=value
  for i in @spritekeys
  @sprites[i].dispose
  if @sprites[i].is_a?(Sprite)
    @sprites[i]=Sprite.new(@viewport)
  elsif @sprites[i].is_a?(Plane)
    @sprites[i]=Plane.new(@viewport)
  else
    @sprites[i]=nil
  end
  end
  privRefresh(true)
end
def z=(value)
  @z=value
  privRefresh
end
def disposed?
  return @disposed
end
def contents=(value)
  @contents=value
  privRefresh
end
def windowskin=(value)
  @_windowskin=value
  if value && value.is_a?(Bitmap) && !value.disposed? && value.width==128
    @rpgvx=true
  else
    @rpgvx=false
  end
  privRefresh(true)
end
def ox=(value)
  @ox=value
  privRefresh
end
def active=(value)
  @active=value
  privRefresh(true)
end
def cursor_rect=(value)
  if !value
    @cursor_rect.empty
  else
    @cursor_rect.set(value.x,value.y,value.width,value.height)
  end
end
def oy=(value)
  @oy=value
  privRefresh
end
def width=(value)
  @width=value
  privRefresh(true)
end
def height=(value)
  @height=value
  privRefresh(true)
end
def pause=(value)
  @pause=value
  @pauseopacity=0 if !value
  privRefresh
end
def x=(value)
  @x=value
  privRefresh
end
def y=(value)
  @y=value
  privRefresh
end
def opacity=(value)
  @opacity=value
  @opacity=0 if @opacity<0
  @opacity=255 if @opacity>255
  privRefresh
end
def back_opacity=(value)
  @back_opacity=value
  @back_opacity=0 if @back_opacity<0
  @back_opacity=255 if @back_opacity>255
  privRefresh
end

def get_back_red
  if @back_r == nil
    return 0
  else
    return @back_r
  end
end
def get_back_green
  if @back_g == nil
    return 0
  else
  return @back_g
  end
end
def get_back_blue
  if @back_b == nil
    return 0
  else
  return @back_b
  end
end
def get_back_gray
  if @back_s == nil
    return 0
  else
  return @back_s
  end
end
def get_back_grey
  get_back_gray
end


def set_back_red(value)
  @back_r=value
  @back_r=-255 if @back_r<-255
  @back_r=255 if @back_r>255
end
def set_back_green(value)
  @back_g=value
  @back_g=-255 if @back_g<-255
  @back_g=255 if @back_g>255
end
def set_back_blue(value)
  @back_b=value
  @back_b=-255 if @back_b<-255
  @back_b=255 if @back_b>255
end
def set_back_gray(value)
  @back_s=value
  @back_s=0 if @back_s<0
  @back_s=255 if @back_s>255
end
def set_back_grey(value)
  set_back_gray(value)
end


def increase_back_red(value)
  @back_r+=value
  @back_r=-255 if @back_r<-255
  @back_r=255 if @back_r>255
end
def increase_back_green(value)
  @back_g+=value
  @back_g=-255 if @back_g<-255
  @back_g=255 if @back_g>255
end
def increase_back_blue(value)
  @back_b+=value
  @back_b=-255 if @back_b<-255
  @back_b=255 if @back_b>255
end
def increase_back_gray(value)
  @back_s+=value
  @back_s=0 if @back_s<0
  @back_s=255 if @back_s>255
end
def increase_back_grey(value)
  increase_back_gray(value)
end


def get_cursor_red
  if @cursor_r == nil
    return 0
  else
    return @cursor_r
  end
end
def get_cursor_green
  if @cursor_g == nil
    return 0
  else
  return @cursor_g
  end
end
def get_cursor_blue
  if @cursor_b == nil
    return 0
  else
  return @cursor_b
  end
end
def get_cursor_gray
  if @cursor_s == nil
    return 0
  else
  return @cursor_s
  end
end
def get_cursor_grey
  get_cursor_gray
end

def set_cursor_red(value)
  @cursor_r=value
  @cursor_r=-255 if @cursor_r<-255
  @cursor_r=255 if @cursor_r>255
end
def set_cursor_green(value)
  @cursor_g=value
  @cursor_g=-255 if @cursor_g<-255
  @cursor_g=255 if @cursor_g>255
end
def set_cursor_blue(value)
  @cursor_b=value
  @cursor_b=-255 if @cursor_b<-255
  @cursor_b=255 if @cursor_b>255
end
def set_cursor_gray(value)
  @cursor_s=value
  @cursor_s=0 if @cursor_s<0
  @cursor_s=255 if @cursor_s>255
end
def set_cursor_grey(value)
  set_cursor_gray(value)
end

def increase_cursor_red(value)
  @cursor_r+=value
  @cursor_r=-255 if @cursor_r<-255
  @cursor_r=255 if @cursor_r>255
end
def increase_cursor_green(value)
  @cursor_g+=value
  @cursor_g=-255 if @cursor_g<-255
  @cursor_g=255 if @cursor_g>255
end
def increase_cursor_blue(value)
  @cursor_b+=value
  @cursor_b=-255 if @cursor_b<-255
  @cursor_b=255 if @cursor_b>255
end
def increase_cursor_gray(value)
  @cursor_s+=value
  @cursor_s=0 if @cursor_s<0
  @cursor_s=255 if @cursor_s>255
end
def increase_cursor_grey(value)
  increase_cursor_gray(value)
end

def get_cursor_red
  if @cursor_r == nil
    return 0
  else
    return @cursor_r
  end
end
def get_cursor_green
  if @cursor_g == nil
    return 0
  else
  return @cursor_g
  end
end
def get_cursor_blue
  if @cursor_b == nil
    return 0
  else
  return @cursor_b
  end
end
def get_cursor_gray
  if @cursor_s == nil
    return 0
  else
  return @cursor_s
  end
end
def get_cursor_grey
  get_cursor_gray
end

def set_border_red(value)
  @border_r=value
  @border_r=-255 if @border_r<-255
  @border_r=255 if @border_r>255
end
def set_border_green(value)
  @border_g=value
  @border_g=-255 if @border_g<-255
  @border_g=255 if @border_g>255
end
def set_border_blue(value)
  @border_b=value
  @border_b=-255 if @border_b<-255
  @border_b=255 if @border_b>255
end
def set_border_gray(value)
  @border_s=value
  @border_s=0 if @border_s<0
  @border_s=255 if @border_s>255
end
def set_border_grey(value)
  set_border_gray(value)
end

def increase_border_red(value)
  @border_r+=value
  @border_r=-255 if @border_r<-255
  @border_r=255 if @border_r>255
end
def increase_border_green(value)
  @border_g+=value
  @border_g=-255 if @border_g<-255
  @border_g=255 if @border_g>255
end
def increase_border_blue(value)
  @border_b+=value
  @border_b=-255 if @border_b<-255
  @border_b=255 if @border_b>255
end
def increase_border_gray(value)
  @border_s+=value
  @border_s=0 if @border_s<0
  @border_s=255 if @border_s>255
end
def increase_border_grey(value)
  increase_border_gray(value)
end

def contents_opacity=(value)
  @contents_opacity=value
  @contents_opacity=0 if @contents_opacity<0
  @contents_opacity=255 if @contents_opacity>255
  privRefresh
end

def tone=(value)
  @tone=value
  privRefresh
end
def color=(value)
  @color=value
  privRefresh
end
def blend_type=(value)
  @blend_type=value
  privRefresh
end
def flash(color,duration)
  return if disposed?
  for i in @sprites
  i[1].flash(color,duration)
  end
end
def update
  return if disposed?
  mustchange=false
  if @active
  if @cursorblink==0
    @cursoropacity-=8
    @cursorblink=1 if @cursoropacity<=128
  else
    @cursoropacity+=8
    @cursorblink=0 if @cursoropacity>=255
  end
  mustchange=true if !@cursor_rect.isEmpty?
  else
  mustchange=true if @cursoropacity!=128
  @cursoropacity=128
  end
  if @pause
  @pauseframe=(Graphics.frame_count / 8) % 4
  @pauseopacity=[@pauseopacity+64,255].min
  mustchange=true
  end
  privRefresh if mustchange
  for i in @sprites
  i[1].update
  end
end
private
def ensureBitmap(bitmap,dwidth,dheight)
  if !bitmap||bitmap.disposed?||bitmap.width<dwidth||bitmap.height<dheight
  bitmap.dispose if bitmap
  bitmap=Bitmap.new([1,dwidth].max,[1,dheight].max)
  end
  return bitmap
end
def tileBitmap(dstbitmap,dstrect,srcbitmap,srcrect)
  return if !srcbitmap || srcbitmap.disposed?
  left=dstrect.x
  top=dstrect.y
  y=0;loop do break unless y<dstrect.height
  x=0;loop do break unless x<dstrect.width
    dstbitmap.blt(x+left,y+top,srcbitmap,srcrect)
    x+=srcrect.width
  end
  y+=srcrect.height
  end
end
def privRefresh(changeBitmap=false)
  return if self.disposed?
  backopac=self.back_opacity*self.opacity/255
  contopac=self.contents_opacity
  cursoropac=@cursoropacity*contopac/255
  for i in 0...4
  @sprites["corner#{i}"].bitmap=@_windowskin
  @sprites["scroll#{i}"].bitmap=@_windowskin
  end
  @sprites["pause"].bitmap=@_windowskin
  @sprites["contents"].bitmap=@contents
  if @_windowskin && !@_windowskin.disposed?
  for i in 0...4
    @sprites["corner#{i}"].opacity=@opacity
    @sprites["corner#{i}"].tone=Tone.new(@border_r, @border_g, @border_b, @border_s)
    @sprites["corner#{i}"].color=@color
    @sprites["corner#{i}"].blend_type=@blend_type
    @sprites["corner#{i}"].visible=@visible
    @sprites["side#{i}"].opacity=@opacity
    @sprites["side#{i}"].tone=Tone.new(@border_r, @border_g, @border_b, @border_s)
    @sprites["side#{i}"].color=@color
    @sprites["side#{i}"].blend_type=@blend_type
    @sprites["side#{i}"].visible=@visible
    @sprites["scroll#{i}"].opacity=@opacity
    @sprites["scroll#{i}"].tone=Tone.new(@border_r, @border_g, @border_b, @border_s)
    @sprites["scroll#{i}"].blend_type=@blend_type
    @sprites["scroll#{i}"].color=@color
    @sprites["scroll#{i}"].visible=@visible
  end
  @sprites["back"].color=@color
  @sprites["back"].tone=Tone.new(@back_r, @back_g, @back_b, @back_s)
  @sprites["back"].blend_type=@blend_type

  @sprites["cursor"].color=@color
  @sprites["cursor"].tone=Tone.new(@cursor_r, @cursor_g, @cursor_b, @cursor_s)
  @sprites["cursor"].blend_type=@blend_type

  @sprites["pause"].color=@color
  @sprites["pause"].tone=@tone
  @sprites["pause"].blend_type=@blend_type

  @sprites["contents"].color=@color
  @sprites["contents"].tone=@tone
  @sprites["contents"].blend_type=@blend_type

  @sprites["contents"].blend_type=@contents_blend_type
  @sprites["back"].opacity=backopac
  @sprites["contents"].opacity=contopac
  @sprites["cursor"].opacity=cursoropac
  @sprites["pause"].opacity=@pauseopacity
  @sprites["back"].visible=@visible
  @sprites["contents"].visible=@visible && @openness==255
  @sprites["pause"].visible=@visible && @pause
  @sprites["cursor"].visible=@visible && @openness==255
  hascontents=(@contents && !@contents.disposed?)
  @sprites["scroll0"].visible = @visible && hascontents && @oy > 0
  @sprites["scroll1"].visible = @visible && hascontents && @ox > 0
  @sprites["scroll2"].visible = @visible && hascontents && (@contents.width - @ox) > @width-32
  @sprites["scroll3"].visible = @visible && hascontents && (@contents.height - @oy) > @height-32
  else
  for i in 0...4
    @sprites["corner#{i}"].visible=false
    @sprites["side#{i}"].visible=false
    @sprites["scroll#{i}"].visible=false
  end
  @sprites["contents"].visible=@visible && @openness==255
  @sprites["contents"].color=@color
  @sprites["contents"].tone=@tone
  @sprites["contents"].blend_type=@contents_blend_type
  @sprites["contents"].opacity=contopac
  @sprites["back"].visible=false
  @sprites["pause"].visible=false
  @sprites["cursor"].visible=false
  end
  for i in @sprites
  i[1].z=@z
  end
  if @rpgvx
    @sprites["cursor"].z=@z#+1
    @sprites["contents"].z=@z#+2
    @sprites["pause"].z=@z#+2
  else
    @sprites["cursor"].z=@z+1
    @sprites["contents"].z=@z+2
    @sprites["pause"].z=@z+2
  end
  if @rpgvx
  trimX=64
  trimY=0
  backRect=Rect.new(0,0,64,64)
  blindsRect=Rect.new(0,64,64,64)
  else
  trimX=128
  trimY=0
  backRect=Rect.new(0,0,128,128)
  blindsRect=nil
  end
  @sprites["corner0"].src_rect.set(trimX,trimY+0,16,16);
  @sprites["corner1"].src_rect.set(trimX+48,trimY+0,16,16);
  @sprites["corner2"].src_rect.set(trimX,trimY+48,16,16);
  @sprites["corner3"].src_rect.set(trimX+48,trimY+48,16,16);
  @sprites["scroll0"].src_rect.set(trimX+24, trimY+16, 16, 8) # up
  @sprites["scroll3"].src_rect.set(trimX+24, trimY+40, 16, 8) # down
  @sprites["scroll1"].src_rect.set(trimX+16, trimY+24, 8, 16) # left
  @sprites["scroll2"].src_rect.set(trimX+40, trimY+24, 8, 16) # right
  cursorX=trimX
  cursorY=trimY+64
  sideRects=[
  Rect.new(trimX+16,trimY+0,32,16),
  Rect.new(trimX,trimY+16,16,32),
  Rect.new(trimX+48,trimY+16,16,32),
  Rect.new(trimX+16,trimY+48,32,16)
  ]
  if @width>32 && @height>32
  @sprites["contents"].src_rect.set(@ox,@oy,@width-32,@height-32)
  else
  @sprites["contents"].src_rect.set(0,0,0,0)
  end
  pauseRects=[
  trimX+32,trimY+64,
  trimX+48,trimY+64,
  trimX+32,trimY+80,
  trimX+48,trimY+80,
  ]
  pauseWidth=16
  pauseHeight=16
  @sprites["pause"].src_rect.set(
    pauseRects[@pauseframe*2],
    pauseRects[@pauseframe*2+1],
    pauseWidth,pauseHeight
  )
  @sprites["pause"].x=(@x+(@width/2)-(pauseWidth/2))#+216
  @sprites["pause"].y=(@y+@height-16)#-8
  @sprites["contents"].x=@x+16
  @sprites["contents"].y=@y+16
  @sprites["corner0"].x=@x
  @sprites["corner0"].y=@y
  @sprites["corner1"].x=@x+@width-16
  @sprites["corner1"].y=@y
  @sprites["corner2"].x=@x
  @sprites["corner2"].y=@y+@height-16
  @sprites["corner3"].x=@x+@width-16
  @sprites["corner3"].y=@y+@height-16
  @sprites["side0"].x=@x+16
  @sprites["side0"].y=@y
  @sprites["side1"].x=@x
  @sprites["side1"].y=@y+16
  @sprites["side2"].x=@x+@width-16
  @sprites["side2"].y=@y+16
  @sprites["side3"].x=@x+16
  @sprites["side3"].y=@y+@height-16
  @sprites["scroll0"].x = @x+@width / 2 - 8
  @sprites["scroll0"].y = @y+8
  @sprites["scroll1"].x = @x+8
  @sprites["scroll1"].y = @y+@height / 2 - 8
  @sprites["scroll2"].x = @x+@width - 16
  @sprites["scroll2"].y = @y+@height / 2 - 8
  @sprites["scroll3"].x = @x+@width / 2 - 8
  @sprites["scroll3"].y = @y+@height - 16
  @sprites["back"].x=@x+2
  @sprites["back"].y=@y+2
  @sprites["cursor"].x=@x+16+@cursor_rect.x
  @sprites["cursor"].y=@y+16+@cursor_rect.y
  if changeBitmap && @_windowskin && !@_windowskin.disposed?
  width=@cursor_rect.width
  height=@cursor_rect.height
  if width > 0 && height > 0
      cursorrects=[
      # sides
      Rect.new(cursorX+2, cursorY+0, 28, 2),
      Rect.new(cursorX+0, cursorY+2, 2, 28),
      Rect.new(cursorX+30, cursorY+2, 2, 28),
      Rect.new(cursorX+2, cursorY+30, 28, 2),
      # corners
      Rect.new(cursorX+0, cursorY+0, 2, 2),
      Rect.new(cursorX+30, cursorY+0, 2, 2),
      Rect.new(cursorX+0, cursorY+30, 2, 2),
      Rect.new(cursorX+30, cursorY+30, 2, 2),
      # back
      Rect.new(cursorX+2, cursorY+2, 28, 28)
      ]
      margin=2
      fullmargin=4
       
      @cursorbitmap = ensureBitmap(@cursorbitmap, width, height)
      @cursorbitmap.clear
      @sprites["cursor"].bitmap=@cursorbitmap
      @sprites["cursor"].src_rect.set(0,0,width,height)
      rect = Rect.new(margin,margin,
                      width - fullmargin, height - fullmargin)
      @cursorbitmap.stretch_blt(rect, @_windowskin, cursorrects[8])
      @cursorbitmap.blt(0, 0, @_windowskin, cursorrects[4])# top left
      @cursorbitmap.blt(width-margin, 0, @_windowskin, cursorrects[5]) # top right
      @cursorbitmap.blt(0, height-margin, @_windowskin, cursorrects[6]) # bottom right
      @cursorbitmap.blt(width-margin, height-margin, @_windowskin, cursorrects[7]) # bottom left
      rect = Rect.new(margin, 0,
                      width - fullmargin, margin)
      @cursorbitmap.stretch_blt(rect, @_windowskin, cursorrects[0])
      rect = Rect.new(0, margin,
                      margin, height - fullmargin)
      @cursorbitmap.stretch_blt(rect, @_windowskin, cursorrects[1])
      rect = Rect.new(width - margin, margin,
                      margin, height - fullmargin)
      @cursorbitmap.stretch_blt(rect, @_windowskin, cursorrects[2])
      rect = Rect.new(margin, height-margin,
                      width - fullmargin, margin)
      @cursorbitmap.stretch_blt(rect, @_windowskin, cursorrects[3])
  else
      @sprites["cursor"].visible=false
      @sprites["cursor"].src_rect.set(0,0,0,0)
  end
  for i in 0..3
    dwidth=(i==0||i==3) ? @width-32 : 16
    dheight=(i==0||i==3) ? 16 : @height-32
    @sidebitmaps[i]=ensureBitmap(@sidebitmaps[i],dwidth,dheight)
    @sprites["side#{i}"].bitmap=@sidebitmaps[i]
    @sprites["side#{i}"].src_rect.set(0,0,dwidth,dheight)
    @sidebitmaps[i].clear
    if sideRects[i].width>0 && sideRects[i].height>0
    @sidebitmaps[i].stretch_blt(@sprites["side#{i}"].src_rect,
      @_windowskin,sideRects[i])
    end
  end
  backwidth=@width-4
  backheight=@height-4
  if backwidth>0 && backheight>0
    @backbitmap=ensureBitmap(@backbitmap,backwidth,backheight)
    @sprites["back"].bitmap=@backbitmap
    @sprites["back"].src_rect.set(0,0,backwidth,backheight)
    @backbitmap.clear
    if @stretch
    @backbitmap.stretch_blt(@sprites["back"].src_rect,@_windowskin,backRect)
    else
    tileBitmap(@backbitmap,@sprites["back"].src_rect,@_windowskin,backRect)
    end
    if blindsRect
    tileBitmap(@backbitmap,@sprites["back"].src_rect,@_windowskin,blindsRect)
    end
  else
    @sprites["back"].visible=false
    @sprites["back"].src_rect.set(0,0,0,0)
  end
  end
  if @openness!=255
  opn=@openness/255.0
  for k in @spritekeys
    sprite=@sprites[k]
    ratio=(@height<=0) ? 0 : (sprite.y-@y)*1.0/@height
    sprite.zoom_y=opn
    sprite.oy=0
    sprite.y=(@y+(@height/2.0)+(@height*ratio*opn)-(@height/2*opn)).floor
  end
  else
  for k in @spritekeys
    sprite=@sprites[k]
    sprite.zoom_y=1.0
  end
  end
  i=0
  for k in @spritekeys
  sprite=@sprites[k]
  y=sprite.y
  sprite.y=i
  sprite.oy=(sprite.zoom_y<=0) ? 0 : (i-y)/sprite.zoom_y
  end
end
end



Instructions

The next codes can be used also changing 'back' to 'cursor' or 'border' depending on the situation. I used the 'back' case because it's maybe the most common.

The next controls return the actual red,green,blue or gray tone of the window
@window.get_back_red
@window.get_back_green
@window.get_back_blue
@window.get_back_gray

To manage that you can do it in two ways, the first one to change the color directly (value from -255 to 255 on red/green/blue and 0 to 255 for grey)
@window.set_back_red(value)
@window.set_back_green(value)
@window.set_back_blue(value)
@window.set_back_gray(value)

Or you can change it increasing the value to the actual tone.
@window.increase_back_red(valor)
@window.increase_back_green(valor)
@window.increase_back_blue(valor)
@window.increase_back_gray(valor)


I made an easy example for RMXP, too. You can check it:

#==============================================================================
# [RMXP] Window Tone Example (by Wecoc)
# This scripts changes "Status" to a tone management window.
#==============================================================================

#==============================================================================
# * Scene_Menu edit
#==============================================================================

class Scene_Menu

  def main
    s1 = $data_system.words.item
    s2 = $data_system.words.skill
    s3 = $data_system.words.equip
    s4 = "Color test"
    s5 = "Save"
    s6 = "Quit"
    @command_window = Window_Command.new(160, [s1, s2, s3, s4, s5, s6])
    @command_window.index = @menu_index
    if $game_party.actors.size == 0
      @command_window.disable_item(0)
      @command_window.disable_item(1)
      @command_window.disable_item(2)
      @command_window.disable_item(3)
    end
    if $game_system.save_disabled
      @command_window.disable_item(4)
    end
    @playtime_window = Window_PlayTime.new
    @playtime_window.x = 0
    @playtime_window.y = 224
    @steps_window = Window_Steps.new
    @steps_window.x = 0
    @steps_window.y = 320
    @gold_window = Window_Gold.new
    @gold_window.x = 0
    @gold_window.y = 416
    @status_window = Window_MenuStatus.new
    @status_window.x = 160
    @status_window.y = 0
    Graphics.transition
    loop do
      Graphics.update
      Input.update
      update
      if $scene != self
        break
      end
    end
    Graphics.freeze
    @command_window.dispose
    @playtime_window.dispose
    @steps_window.dispose
    @gold_window.dispose
    @status_window.dispose
  end

  def update_command
    if Input.trigger?(Input::B)
      $game_system.se_play($data_system.cancel_se)
      $scene = Scene_Map.new
      return
    end
    if Input.trigger?(Input::C)
      if $game_party.actors.size == 0 and @command_window.index < 4
        $game_system.se_play($data_system.buzzer_se)
        return
      end
      case @command_window.index
      when 0  # item
        $game_system.se_play($data_system.decision_se)
        $scene = Scene_Item.new
      when 1  # skill
        $game_system.se_play($data_system.decision_se)
        @command_window.active = false
        @status_window.active = true
        @status_window.index = 0
      when 2  # equipment
        $game_system.se_play($data_system.decision_se)
        @command_window.active = false
        @status_window.active = true
        @status_window.index = 0
      when 3  # status
        $game_system.se_play($data_system.decision_se)
        $scene = Scene_ColorWindow.new
      when 4  # save
        if $game_system.save_disabled
          $game_system.se_play($data_system.buzzer_se)
          return
        end
        $game_system.se_play($data_system.decision_se)
        $scene = Scene_Save.new
      when 5  # end game
        $game_system.se_play($data_system.decision_se)
        $scene = Scene_End.new
      end
      return
    end
  end
end


#==========================================================
# * Scene_ColorWindow by Wecoc
#==========================================================

class Scene_ColorWindow
  def main
    s1 = "Red"
    s2 = "Green"
    s3 = "Blue"
    s4 = "Gray"
    @color_window = Window_Command.new(200, [s1, s2, s3, s4])
    @color_window.x = 240
    @color_window.y = 240
    refresh
    Graphics.transition
    loop do
      Graphics.update
      Input.update
      update
      if $scene != self
        break
      end
    end
    Graphics.freeze
    @color_window.dispose
  end

  def refresh
    @r = @color_window.get_back_red
    @g = @color_window.get_back_green
    @b = @color_window.get_back_blue
    @s = @color_window.get_back_gray
    @color_window.refresh
    @color_window.contents.draw_text(64, 0,100,32,@r.to_s,2)
    @color_window.contents.draw_text(64,32,100,32,@g.to_s,2)
    @color_window.contents.draw_text(64,64,100,32,@b.to_s,2)
    @color_window.contents.draw_text(64,96,100,32,@s.to_s,2)
  end

  def update
    @color_window.update
    if Input.trigger?(Input::B)
      $game_system.se_play($data_system.cancel_se)
      $scene = Scene_Menu.new(3)
      return
    end
    if Input.trigger?(Input::C)
      $game_system.se_play($data_system.decision_se)
      $scene = Scene_Menu.new(3)
      return
    end
    if Input.repeat?(Input::RIGHT)
      $game_system.se_play($data_system.cursor_se)
      case @color_window.index
      when 0 # red
        if @r == -255
          @color_window.increase_back_red(5)
        else
          @color_window.increase_back_red(10)
        end
      when 1 # green
        if @g == -255
          @color_window.increase_back_green(5)
        else
          @color_window.increase_back_green(10)
        end
      when 2 #blue
        if @b == -255
          @color_window.increase_back_blue(5)
        else
          @color_window.increase_back_blue(10)
        end
      when 3 #gray
        @color_window.increase_back_gray(10)
      end
      refresh
    end
    if Input.repeat?(Input::LEFT)
      $game_system.se_play($data_system.cursor_se)
      case @color_window.index
      when 0 # red
        if @r == 255
          @color_window.increase_back_red(-5)
        else
          @color_window.increase_back_red(-10)
        end
      when 1 # green
        if @g == 255
          @color_window.increase_back_green(-5)
        else
          @color_window.increase_back_green(-10)
        end
      when 2 #blue
        if @b == 255
          @color_window.increase_back_blue(-5)
        else
          @color_window.increase_back_blue(-10)
        end
      when 3 #gray
        if @s == 255
          @color_window.increase_back_gray(-5)
        else
          @color_window.increase_back_gray(-10)
        end
      end
      refresh
    end
  end
end



Compatibility

No compatibility issues found.


Credits and Thanks


  • Pokemon Essentials - for the original code source

  • Wecoc - for the simple add-on




Author's Notes

If you have any problem with that script or with incompatibilities don't hestitate to ask.
36
RMXP Script Database / [XP] Scene_Shop Item Counter
January 11, 2013, 03:45:05 pm
Scene_Shop Item Counter
Authors: Wecoc
Version: 1.0
Type: Shop AddOn
Key Term: Custom Shop System

Introduction

With that easy script, you will be able to control how many items you will buy (or sell), without going to a counter window.
The new multiplier number shown on the same window as the items list, will be managed now with -> and <-

Features

  • Works on Buy Window and Sell Window
  • Price string is multiplied automatically.

Screenshots

Spoiler: ShowHide




Demo

Nope for this type of script.

Script

Spoiler: ShowHide

#==============================================================================
# ** [XP] Castlevania Shop Item Counter v 1.1
#------------------------------------------------------------------------------
# Autor: Wecoc (no requiere créditos)
#==============================================================================

#==============================================================================
# ** Window_ShopBuy
#==============================================================================

class Window_ShopBuy < Window_Selectable
  #--------------------------------------------------------------------------
  attr_accessor :shop_multipliers
  #--------------------------------------------------------------------------
  # * Initialize
  #--------------------------------------------------------------------------
  alias castle_multi_ini initialize unless $@
  def initialize(shop_goods)
    @shop_multipliers = Array.new(shop_goods.size, 1)
    castle_multi_ini(shop_goods)
  end
  #--------------------------------------------------------------------------
  # * Draw Item
  #--------------------------------------------------------------------------
  def draw_item(index)
    item = @data[index]
    multi = @shop_multipliers[index]
    case item
    when RPG::Item
      number = $game_party.item_number(item.id)
    when RPG::Weapon
      number = $game_party.weapon_number(item.id)
    when RPG::Armor
      number = $game_party.armor_number(item.id)
    end
    price = item.price * multi
    if price <= $game_party.gold and number < 99
      self.contents.font.color = normal_color
    else
      self.contents.font.color = disabled_color
    end
    x = 4
    y = index * 32
    rect = Rect.new(x, y, self.width - 32, 32)
    self.contents.fill_rect(rect, Color.new(0, 0, 0, 0))
    bitmap = RPG::Cache.icon(item.icon_name)
    opacity = self.contents.font.color == normal_color ? 255 : 128
    self.contents.blt(x, y + 4, bitmap, Rect.new(0, 0, 24, 24), opacity)
    self.contents.draw_text(x + 28, y, 212, 32, item.name, 0)
    self.contents.draw_text(x + 160, y, 88, 32, multi.to_s, 2)
    self.contents.draw_text(x + 240, y, 88, 32, price.to_s, 2)
  end
end

#==============================================================================
# ** Scene_Shop
#==============================================================================

class Scene_Shop
  #--------------------------------------------------------------------------
  # * Frame Update (when buy window is active)
  #--------------------------------------------------------------------------
  def update_buy
    @status_window.item = @buy_window.item
    if Input.trigger?(Input::B)
      $game_system.se_play($data_system.cancel_se)
      @command_window.active = true
      @dummy_window.visible = true
      @buy_window.active = false
      @buy_window.visible = false
      @status_window.visible = false
      @status_window.item = nil
      @help_window.set_text("")
      return
    end
    if Input.repeat?(Input::RIGHT)
      item = @buy_window.item
      return if item == nil
      multi = @buy_window.shop_multipliers[@buy_window.index]
      return if multi == 99 or item.price * (multi + 1) > $game_party.gold
      $game_system.se_play($data_system.cursor_se)
      @buy_window.shop_multipliers[@buy_window.index] += 1
      @buy_window.draw_item(@buy_window.index)
    end
    if Input.repeat?(Input::LEFT)
      item = @buy_window.item
      return if item == nil
      multi = @buy_window.shop_multipliers[@buy_window.index]
      return if multi == 1
      $game_system.se_play($data_system.cursor_se)
      @buy_window.shop_multipliers[@buy_window.index] -= 1
      @buy_window.draw_item(@buy_window.index)
    end
    if Input.trigger?(Input::C)
      @item = @buy_window.item
      if @item == nil
        $game_system.se_play($data_system.buzzer_se)
        return
      end
      multi = @buy_window.shop_multipliers[@buy_window.index]
      price = @item.price * multi
      if price > $game_party.gold
        $game_system.se_play($data_system.buzzer_se)
        return
      end
      case @item
      when RPG::Item
        number = $game_party.item_number(@item.id)
      when RPG::Weapon
        number = $game_party.weapon_number(@item.id)
      when RPG::Armor
        number = $game_party.armor_number(@item.id)
      end
      if number == 99
        $game_system.se_play($data_system.buzzer_se)
        return
      end
      $game_system.se_play($data_system.shop_se)
      $game_party.lose_gold(price)
      case @item
      when RPG::Item
        $game_party.gain_item(@item.id, multi)
      when RPG::Weapon
        $game_party.gain_weapon(@item.id, multi)
      when RPG::Armor
        $game_party.gain_armor(@item.id, multi)
      end
      @buy_window.shop_multipliers[@buy_window.index] = 1
      @gold_window.refresh
      @buy_window.refresh
      @status_window.refresh
    end
  end
end


Instructions

Just post above main.

Compatibility

Probably it will not fit well with custom shop systems.

Credits and Thanks

  • Wecoc

Author's Notes

Please report any bugs/issues.
37
RMXP Script Database / [XP] Message Choice Edit
January 07, 2013, 05:52:54 pm
Message Choice Edit
Authors: Wecoc
Version: 1.1
Type: Message Add-on
Key Term: Message Add-on



Introduction

This edit changes choice distribution displaying it horizontally instead of vertically. Long sentences will be shown as always.


Features


  • Short sentences will be shown horizontally (even if 4 choices fit on 1 line).

  • Long sentences will be shown as always.

  • You can easily activate and deactivate the script anytime using Game Temp.




Screenshots

Spoiler: ShowHide

That was silly



Demo

None.


Script

Spoiler: ShowHide

#==============================================================================
# Choice Edit - versión 1.1
# by Wecoc
#==============================================================================

class Game_Temp

  attr_accessor :choice_short
  attr_accessor :choice_type
  attr_accessor :choice_data

  alias ini initialize unless $@
  def initialize
    ini
   
    # To activate / deactivate the script only thing you have to do is
    #modify next line:
       
        @choice_short = true
       
    # false: vertical (default), true : horizontal (just short words)
    # Long sentences will always be displayed vertically.
   
    @choice_data = nil
    @choice_type = 0 # 0 = vertical, 1 = horizontal
  end
end

class Interpreter
  def setup_choices(parameters)
    $game_temp.choice_max = parameters[0].size
    $game_temp.choice_data = parameters[0]
   
    w = $game_temp.choice_data.to_s.length
    if w > 26
      $game_temp.choice_type = 0
    else
      if $game_temp.choice_short == true
        $game_temp.choice_type = 1
      else
        $game_temp.choice_type = 0
      end
    end
   
    if $game_temp.choice_type == 0 # Vertical
      for text in parameters[0]
        $game_temp.message_text += text + "\n"
      end   
    else # Horizontal
      for text in parameters[0]
        $game_temp.message_text += text + "      "
      end
      $game_temp.message_text += "\n"
    end
    $game_temp.message_text += "\n"
    $game_temp.choice_cancel_type = parameters[1]
    current_indent = @list[@index].indent
    $game_temp.choice_proc = Proc.new { |n| @branch[current_indent] = n }
  end
end

class Interpreter
  def command_101 # Show Text
    if $game_temp.message_text != nil
      return false
    end
    @message_waiting = true
    $game_temp.message_proc = Proc.new { @message_waiting = false }
    $game_temp.message_text = @list[@index].parameters[0] + "\n"
    line_count = 1
    loop do
      if @list[@index+1].code == 401 # Show Text
        $game_temp.message_text += @list[@index+1].parameters[0] + "\n"
        line_count += 1
      else
        if @list[@index+1].code == 102 # Show Choices
         
          a = @list[@index+1].parameters[0]
          w = a.to_s.length
          if w > 26
            $game_temp.choice_type = 0
          else
            if $game_temp.choice_short == true
              $game_temp.choice_type = 1
            else
              $game_temp.choice_type = 0
            end
          end

          if (@list[@index+1].parameters[0].size <= 4 - line_count and
          $game_temp.choice_type == 0) or (line_count < 4 and
          $game_temp.choice_type == 1) then
            @index += 1
            $game_temp.choice_start = line_count
            setup_choices(@list[@index].parameters)
          end
        elsif @list[@index+1].code == 103 # Input Number
          if line_count < 4
            @index += 1
            $game_temp.num_input_start = line_count
            $game_temp.num_input_variable_id = @list[@index].parameters[0]
            $game_temp.num_input_digits_max = @list[@index].parameters[1]
          end
        end
        return true
      end
      @index += 1
    end
  end
end

class Window_Message < Window_Selectable
  def refresh
    self.contents.clear
    self.contents.font.color = normal_color
    x = y = 0
    if $game_temp.choice_start == 0
      x = 8
    end
    @cursor_width = 0
    if $game_temp.message_text != nil
      text = $game_temp.message_text
      begin
        last_text = text.clone
        text.gsub!(/\\[Vv]\[([0-9]+)\]/) { $game_variables[$1.to_i] }
      end until text == last_text
      text.gsub!(/\\[Nn]\[([0-9]+)\]/) do
        $game_actors[$1.to_i] != nil ? $game_actors[$1.to_i].name : ""
      end
      text.gsub!(/\\\\/) { "\000" }
      text.gsub!(/\\[Cc]\[([0-9]+)\]/) { "\001[#{$1}]" }
      text.gsub!(/\\[Gg]/) { "\002" }
      while ((c = text.slice!(/./m)) != nil)
        if c == "\000"
          c = "\\"
        end
        if c == "\001"
          text.sub!(/\[([0-9]+)\]/, "")
          color = $1.to_i
          if color >= 0 and color <= 7
            self.contents.font.color = text_color(color)
          end
          next
        end
        if c == "\002"
          if @gold_window == nil
            @gold_window = Window_Gold.new
            @gold_window.x = 560 - @gold_window.width
            if $game_temp.in_battle
              @gold_window.y = 192
            else
              @gold_window.y = self.y >= 128 ? 32 : 384
            end
            @gold_window.opacity = self.opacity
            @gold_window.back_opacity = self.back_opacity
          end
          next
        end
        if c == "\n"
          if y >= $game_temp.choice_start
            @cursor_width = [@cursor_width, x].max
          end
          y += 1
          x = 0
         
          if y >= $game_temp.choice_start and $game_temp.choice_type == 0
            x = 8
          end
          next
        end
        self.contents.draw_text(4 + x, 32 * y, 40, 32, c)
        x += self.contents.text_size(c).width
      end
    end
   
    # If choice
    if $game_temp.choice_max > 0
      @column_max = $game_temp.choice_max if $game_temp.choice_type == 1
      @item_max = $game_temp.choice_max
      self.active = true
      self.index = 0
    end
    # If number input
    if $game_temp.num_input_variable_id > 0
      digits_max = $game_temp.num_input_digits_max
      number = $game_variables[$game_temp.num_input_variable_id]
      @input_number_window = Window_InputNumber.new(digits_max)
      @input_number_window.number = number
      @input_number_window.x = self.x + 8
      @input_number_window.y = self.y + $game_temp.num_input_start * 32
    end
  end

  def update_cursor_rect
    if @index >= 0
      if $game_temp.choice_type == 0
        n = $game_temp.choice_start + @index
        self.cursor_rect.set(8, n * 32, @cursor_width, 32)
      else
        n = $game_temp.choice_start
        w = self.contents.text_size($game_temp.choice_data[@index]).width
        a = 0
        for i in 0..@index-1
          a += self.contents.text_size($game_temp.choice_data[i] + "      ").width
        end
        self.cursor_rect.set(a, n * 32, w+10, 32)
      end
    else
      self.cursor_rect.empty
    end
  end
end



Instructions

Use $game_temp.choice_short = (true/false) on a Script Call before a choice to activate or deactivate the script.



Compatibility

Should be compatible, but I didn't used any alias except on Game Temp.


Credits and Thanks


  • Wecoc




Author's Notes

Please report any bugs/issues/incompatibilities.
38
RMXP Script Database / [XP] RM2kXP v0.7
January 06, 2013, 08:06:05 am
    RM2kXP
    Authors: Wecoc
    Version: 0.7
    Type: Add-on Collection
    Key Term: Add-on Collection



    Introduction

    RM2kXP is a compilation of add-ons for XP that makes all to work like on the old RPG Maker or simulating it's style. It includes a lot of new features.



    Features

    VERSION 0.1 (Aug 07, 2011)


    • Windowskin System

    • Draw_Text Colors

    • 2k CMS

    • Faceset support

    • Fullscreen

    • Sprite Timer

    • 2k Shop with "only buy / sell" function

    • 2k Name Input



    VERSION 0.5 (Jan 03, 2013)


    • Vehicle System (by Orochii)



    VERSION 0.6 (Feb 03, 2013)


    • Vocab Script

    • Encounters by terrain (by gameus)

    • Terrain battlebacks (by gameus)

    • Replace Tile AddOn



    VERSION 0.7 (Jul 09, 2013)

    • F4 & F5 support

    • Interpreter Script Call Fix (by Juan)

    • New icon style using "2k_" on it's name

    • Restricted use and apply items (by gerrtunk)

    • Multiusable items (by gerrtunk)

    • Weapon & Skill AddOns (by gerrtunk)

    • Encounter step rate command (by gerrtunk)





    Screenshots

    Spoiler: ShowHide













    Demo

    Download RM2kXP v0.7.zip



    Compatibility

    Checked with Mode 7, Neo_Mode 7 and Cogwheel's Sideview Battle and fits well with them.
    With big systems like XAS or BABS may appear issues.
    Not compatible with SDK.



    Credits and Thanks


    • Wecoc => RM2KXP Author

    • Poccil/Flameguru => Window module base for System Windowskin

    • Orochii => Vehicle System XP

    • gameus => Terrain Battlebacks / Monster Areas

    • Zeus81 => Fullscreen (F5) script

    • Juan => Interpreter Script Call Fix

    • gerrtunk => Some lost features



    [/list]
    39
    Tilemap new Autotile lecture
    Authors: Wecoc
    Version: 1.0
    Type: Tilemap Add-on
    Key Term: Environment Add-on



    Introduction

    The script now allows to use a new type of autotiles:

    Before
    After



    Features


    • You can use both lectures, it reads each depending on autotile height.

    • It supports animated autotiles

    • On the editor you will see the normal autotile




    Screenshots

    Spoiler: ShowHide
    Before

    After



    Spoiler: ShowHide
    Before

    After





    Script

    Spoiler: ShowHide
    # Tilemap de Pokemon Essentials
    # + Nueva Lectura de Autotiles

    class TilemapAutotiles
     attr_accessor :changed
     def initialize
     @changed=true
     @tiles=[nil,nil,nil,nil,nil,nil,nil]
     end
     def []=(i,value)
     @tiles[i]=value
     @changed=true
     end
     def [](i)
     return @tiles[i]
     end
    end

    class Tilemap
     Animated_Autotiles_Frames = 15
       NewAutotiles = [
       [ [27, 28, 33, 34], [49, 50, 55, 56], [51, 52, 57, 58], [49, 52, 55, 58],
         [63, 64, 69, 70], [65, 66, 71, 72], [51, 52, 69, 70], [ 5,  6, 33, 12] ],
       [ [61, 62, 67, 68], [49, 50, 67, 68], [53, 54, 59, 60], [ 5,  6, 11, 34],
         [61, 64, 67, 70], [ 5, 28, 11, 12], [27,  6, 11, 12], [ 5,  6, 11, 12] ],
       [ [25, 26, 31, 32], [25,  6, 31, 32], [25, 26, 31, 12], [25,  6, 31, 12],
         [15, 16, 21, 22], [15, 16, 21, 12], [15, 16, 11, 22], [15, 16, 11, 12] ],
       [ [29, 30, 35, 36], [29, 30, 11, 36], [ 5, 30, 35, 36], [ 5, 30, 11, 36],
         [39, 40, 45, 46], [ 5, 40, 45, 46], [39,  6, 45, 46], [ 5,  6, 45, 46] ],
       [ [25, 30, 31, 36], [15, 16, 45, 46], [13, 14, 19, 20], [13, 14, 19, 12],
         [17, 18, 23, 24], [17, 18, 11, 24], [41, 42, 47, 48], [ 5, 42, 47, 48] ],
       [ [37, 38, 43, 44], [37,  6, 43, 44], [13, 18, 19, 24], [13, 14, 43, 44],
         [37, 42, 43, 48], [17, 18, 47, 48], [13, 18, 43, 48], [ 1,  2,  7,  8] ]
     ]
     OldAutotiles = [
       [ [27, 28, 33, 34], [ 5, 28, 33, 34], [27,  6, 33, 34], [ 5,  6, 33, 34],
         [27, 28, 33, 12], [ 5, 28, 33, 12], [27,  6, 33, 12], [ 5,  6, 33, 12] ],
       [ [27, 28, 11, 34], [ 5, 28, 11, 34], [27,  6, 11, 34], [ 5,  6, 11, 34],
         [27, 28, 11, 12], [ 5, 28, 11, 12], [27,  6, 11, 12], [ 5,  6, 11, 12] ],
       [ [25, 26, 31, 32], [25,  6, 31, 32], [25, 26, 31, 12], [25,  6, 31, 12],
         [15, 16, 21, 22], [15, 16, 21, 12], [15, 16, 11, 22], [15, 16, 11, 12] ],
       [ [29, 30, 35, 36], [29, 30, 11, 36], [ 5, 30, 35, 36], [ 5, 30, 11, 36],
         [39, 40, 45, 46], [ 5, 40, 45, 46], [39,  6, 45, 46], [ 5,  6, 45, 46] ],
       [ [25, 30, 31, 36], [15, 16, 45, 46], [13, 14, 19, 20], [13, 14, 19, 12],
         [17, 18, 23, 24], [17, 18, 11, 24], [41, 42, 47, 48], [ 5, 42, 47, 48] ],
       [ [37, 38, 43, 44], [37,  6, 43, 44], [13, 18, 19, 24], [13, 14, 43, 44],
         [37, 42, 43, 48], [17, 18, 47, 48], [13, 18, 43, 48], [ 1,  2,  7,  8] ]
     ]
     FlashOpacity=[100,90,80,70,80,90]
     attr_reader :tileset
     attr_reader :autotiles
     attr_reader :map_data
     attr_accessor :flash_data
     attr_accessor :priorities
     attr_reader :visible
     attr_accessor :ox
     attr_accessor :oy
     attr_reader :viewport
     attr_accessor :tone
     attr_accessor :color
     def graphicsHeight
       return 480
     end
     def graphicsWidth
       return 640
     end
     def initialize(viewport)
       @tileset    = nil  # Refers to Map Tileset Name
       @autotiles  = TilemapAutotiles.new
       @map_data  = nil  # Refers to 3D Array Of Tile Settings
       @flash_data = nil  # Refers to 3D Array of Tile Flashdata
       @priorities = nil  # Refers to Tileset Priorities
       @visible    = true # Refers to Tileset Visibleness
       @ox        = 0    # Bitmap Offsets
       @oy        = 0    # bitmap Offsets
       @plane      = false
       @tone=Tone.new(0,0,0,0)
       @color=Color.new(0,0,0,0)
       @oldtone=Tone.new(0,0,0,0)
       @oldcolor=Color.new(0,0,0,0)
       @selfviewport=Viewport.new(0,0,graphicsWidth,graphicsHeight)
       @viewport=viewport ? viewport : @selfviewport
       @tiles=[]
       @autotileInfo=[]
       @regularTileInfo=[]
       @oldOx=0
       @oldOy=0
       @layer0=Sprite.new(viewport)
       @layer0.visible=true
       @nowshown=false
       @layer0.bitmap=Bitmap.new([graphicsWidth*2,1].max,[graphicsHeight*2,1].max)
       @flash=nil
       @layer0.ox=0
       @layer0.oy=0
       @oxLayer0=0
       @oyLayer0=0
       @oxFlash=0
       @oyFlash=0
       @layer0.z=0
       @priotiles=[]
       @prioautotiles=[]
       @autosprites=[]
       @framecount=[]
       @tilesetChanged=true
       @flashChanged=false
       @firsttime=true
       @disposed=false
       @usedsprites=false
       @layer0clip=true
       @firsttimeflash=true
       @fullyrefreshed=false
       @fullyrefreshedautos=false
     end
     def disposed?
     return @disposed
     end
     def flash_data=(value)
     @flash_data=value
     @flashChanged=true
     end
     def update
       if @oldtone!=@tone
         @layer0.tone=@tone
         @flash.tone=@tone if @flash
         for sprite in @autosprites
           sprite.tone=@tone
         end
         for sprite in @tiles
           sprite.tone=@tone if sprite.is_a?(Sprite)
         end
         @oldtone=@tone.clone
       end
       if @oldcolor!=@color
         @layer0.color=@color
         @flash.color=@color if @flash
         for sprite in @autosprites
           sprite.color=@color
         end
         for sprite in @tiles
           sprite.color=@color if sprite.is_a?(Sprite)
         end
         @oldcolor=@color.clone
       end
       if @autotiles.changed
         refresh_autotiles
         repaintAutotiles
       end
       if @flashChanged
         refresh_flash
       end
       if @tilesetChanged
         refresh_tileset
       end
       if @flash
       @flash.opacity=FlashOpacity[(Graphics.frame_count/2) % 6]
       end
       if !(@oldOx==@ox && @oldOy==@oy &&
             !@tilesetChanged &&
             !@autotiles.changed)
         refresh
       end
       if (Graphics.frame_count % Animated_Autotiles_Frames == 0) || @nowshown
         repaintAutotiles
         refresh(true)
       end
       @nowshown=false
       @autotiles.changed=false
       @tilesetChanged=false
     end
    def priorities=(value)
     @priorities=value
     @tilesetChanged=true
    end
    def tileset=(value)
     @tileset=value
     @tilesetChanged=true
    end
    def shown?
     return false if !@visible
     ysize=@map_data.ysize
     xsize=@map_data.xsize
     xStart=(@ox/32)-1
     xEnd=((@ox+@viewport.rect.width)/32)+1
     yStart=(@oy/32)-1
     yEnd=((@oy+@viewport.rect.height)/32)+1
     xStart=0 if xStart<0
     xStart=xsize-1 if xStart>=xsize
     xEnd=0 if xEnd<0
     xEnd=xsize-1 if xEnd>=xsize
     yStart=0 if yStart<0
     yStart=ysize-1 if yStart>=ysize
     yEnd=0 if yEnd<0
     yEnd=ysize-1 if yEnd>=ysize
     return (xStart<xEnd && yStart<yEnd)
    end
    def dispose
    return if disposed?
    @help.dispose if @help
    @help=nil
    i=0;len=@autotileInfo.length;while i<len
     if @autotileInfo[i]
       @autotileInfo[i].dispose
       @autotileInfo[i]=nil
     end
     i+=1
    end
    i=0;len=@regularTileInfo.length;while i<len
     if @regularTileInfo[i]
       @regularTileInfo[i].dispose
       @regularTileInfo[i]=nil
     end
     i+=1
    end
    i=0;len=@tiles.length;while i<len
     @tiles[i].dispose
     @tiles[i]=nil
     i+=2
    end
    i=0;len=@autosprites.length;while i<len
     @autosprites[i].dispose
     @autosprites[i]=nil
     i+=2
    end
    if @layer0
     @layer0.bitmap.dispose if !@layer0.disposed?
     @layer0.bitmap=nil if !@layer0.disposed?
     @layer0.dispose
     @layer0=nil
    end
    if @flash
     @flash.bitmap.dispose if !@flash.disposed?
     @flash.bitmap=nil if !@flash.disposed?
     @flash.dispose
     @flash=nil
    end
    for i in 0...7
     self.autotiles[i]=nil
    end
    @tiles.clear
    @autosprites.clear
    @autotileInfo.clear
    @regularTileInfo.clear
    @tilemap=nil
    @tileset=nil
    @priorities=nil
    @selfviewport.dispose
    @selfviewport=nil
    @disposed=true
    end

    def bltAutotile(bitmap,x,y,id,frame)
     return if frame<0
     autotile=@autotiles[id/48-1]
     return if !autotile
     if autotile.height==32
       anim=frame<<5
       src_rect=Rect.new(anim,0,32,32)
       bitmap.blt(x,y,autotile,src_rect)
     else
       anim=frame*96
       id%=48
       if autotile.height==192
         tiles = NewAutotiles[id>>3][id&7]
       else
         tiles = OldAutotiles[id>>3][id&7]
       end
       src=Rect.new(0,0,0,0)
       for i in 0...4
         tile_position = tiles[i] - 1
         src.set(
         (tile_position % 6)*16 + anim,
         (tile_position / 6)*16, 16, 16)
         bitmap.blt(i%2*16+x,i/2*16+y, autotile, src)
       end
     end
    end

    def autotileNumFrames(id)
     autotile=@autotiles[id/48-1]
     return 0 if !autotile || autotile.disposed?
     frames=1
     if autotile.height==32
     frames=autotile.width>>5
     else
     frames=autotile.width/96
     end
     return frames
    end

    def autotileFrame(id)
     autotile=@autotiles[id/48-1]
     return -1 if !autotile || autotile.disposed?
     frames=1
     if autotile.height==32
     frames=autotile.width>>5
     else
     frames=autotile.width/96
     end
     return (Graphics.frame_count/Animated_Autotiles_Frames)%frames
    end

    def repaintAutotiles
    for i in 0...@autotileInfo.length
     next if !@autotileInfo[i]
     frame=autotileFrame(i)
     bltAutotile(@autotileInfo[i],0,0,i,frame)
    end
    end

    def getAutotile(sprite,id)
     anim=autotileFrame(id)
     return if anim<0
     bitmap=@autotileInfo[id]
     if !bitmap
       bitmap=Bitmap.new(32,32)
       bltAutotile(bitmap,0,0,id,anim)
       @autotileInfo[id]=bitmap
     end
     sprite.bitmap=bitmap if !sprite.equal?(bitmap) || sprite.bitmap!=bitmap
    end

    def getRegularTile(sprite,id)
    if false
     sprite.bitmap=@tileset if !sprite.equal?(@tileset) || sprite.bitmap!=@tileset
     sprite.src_rect.set(((id - 384)&7)<<5,((id - 384)>>3)<<5,32,32)
    else
     bitmap=@regularTileInfo[id]
     if !bitmap
     bitmap=Bitmap.new(32,32)
     rect=Rect.new(((id - 384)&7)<<5,((id - 384)>>3)<<5,32,32)
     bitmap.blt(0,0,@tileset,rect)
     @regularTileInfo[id]=bitmap
     end
     sprite.bitmap=bitmap if !sprite.equal?(bitmap) || sprite.bitmap!=bitmap
    end
    end

    def addTile(tiles,count,xpos,ypos,id)
     if id>=384
       if count>=tiles.length
         sprite=Sprite.new(@viewport)
         tiles.push(sprite,0)
       else
         sprite=tiles[count]
         tiles[count+1]=0
       end
       sprite.visible=@visible
       sprite.x=xpos
       sprite.y=ypos
       sprite.tone=@tone
       sprite.color=@color
       getRegularTile(sprite,id)
       spriteZ=(@priorities[id]==0||!@priorities[id]) ? 0 : ypos+@priorities[id]*32+32
       sprite.z=spriteZ
       count+=2
     else
       if count>=tiles.length
         sprite=Sprite.new(@viewport)
         tiles.push(sprite,1)
       else
         sprite=tiles[count]
         tiles[count+1]=1
       end
       sprite.visible=@visible
       sprite.x=xpos
       sprite.y=ypos
       sprite.tone=@tone
       sprite.color=@color
       getAutotile(sprite,id)
       spriteZ=(@priorities[id]==0||!@priorities[id]) ? 0 : ypos+@priorities[id]*32+32
       sprite.z=spriteZ
       count+=2
     end
     return count
    end

    def refresh_tileset
    i=0;len=@regularTileInfo.length;while i<len
     if @regularTileInfo[i]
       @regularTileInfo[i].dispose
       @regularTileInfo[i]=nil
     end
     i+=1
    end
    @regularTileInfo.clear
    @priotiles.clear
    ysize=@map_data.ysize
    xsize=@map_data.xsize
    zsize=@map_data.zsize
    if xsize>100 || ysize>100
     @fullyrefreshed=false
    else
     for z in 0...zsize
     for y in 0...ysize
       for x in 0...xsize
       id = @map_data[x, y, z]
       next if id==0 || !@priorities[id]
       next if @priorities[id]==0
       @priotiles.push([x,y,z,id])
       end
     end
     end
     @fullyrefreshed=true
    end
    end

    def refresh_flash
    if @flash_data && !@flash
     @flash=Sprite.new(viewport)
     @flash.visible=true
     @flash.z=1
     @flash.blend_type=1
     @flash.bitmap=Bitmap.new([graphicsWidth*2,1].max,[graphicsHeight*2,1].max)
     @firsttimeflash=true
    elsif !@flash_data && @flash
     @flash.bitmap.dispose if @flash.bitmap
     @flash.dispose
     @flash=nil
     @firsttimeflash=false
    end
    end

    def refresh_autotiles
    i=0;len=@autotileInfo.length;while i<len
     if @autotileInfo[i]
       @autotileInfo[i].dispose
       @autotileInfo[i]=nil
     end
     i+=1
    end
    i=0;len=@autosprites.length;while i<len
     if @autosprites[i]
       @autosprites[i].dispose
       @autosprites[i]=nil
     end
     i+=2
    end
    @autosprites.clear
    @autotileInfo.clear
    @prioautotiles.clear
    hasanimated=false
    for i in 0...7
     numframes=autotileNumFrames(48*(i+1))
     hasanimated=true if numframes>=2
     @framecount[i]=numframes
    end
    if hasanimated
     ysize=@map_data.ysize
     xsize=@map_data.xsize
     zsize=@map_data.zsize
     if xsize>100 || ysize>100
       @fullyrefreshedautos=false
     else
       for y in 0...ysize
       for x in 0...xsize
         haveautotile=false
         for z in 0...zsize
         id = @map_data[x, y, z]
         next if id==0 || id>=384 || @priorities[id]!=0 || !@priorities[id]
         next if @framecount[id/48-1]<2
         haveautotile=true
         break
         end
         @prioautotiles.push([x,y]) if haveautotile
       end
       end
       @fullyrefreshedautos=true
     end
    else
     @fullyrefreshedautos=true
    end
    end

    def map_data=(value)
    @map_data=value
    @tilesetChanged=true
    end

    def refreshFlashSprite
    return if !@flash || @flash_data.nil?
    ptX=@ox-@oxFlash
    ptY=@oy-@oyFlash
    if !@firsttimeflash && !@usedsprites &&
       ptX>=0 && ptX+@viewport.rect.width<=@flash.bitmap.width &&
       ptY>=0 && ptY+@viewport.rect.height<=@flash.bitmap.height
     @flash.ox=0
     @flash.oy=0
     @flash.src_rect.set(ptX.round,ptY.round,
       @viewport.rect.width,@viewport.rect.height)
     return
    end
    width=@flash.bitmap.width
    height=@flash.bitmap.height
    bitmap=@flash.bitmap
    ysize=@map_data.ysize
    xsize=@map_data.xsize
    zsize=@map_data.zsize
    @firsttimeflash=false
    @oxFlash=@ox-(width>>2)
    @oyFlash=@oy-(height>>2)
    @flash.ox=0
    @flash.oy=0
    @flash.src_rect.set(width>>2,height>>2,
       @viewport.rect.width,@viewport.rect.height)
    @flash.bitmap.clear
    @oxFlash=@oxFlash.floor
    @oyFlash=@oyFlash.floor
    xStart=(@oxFlash>>5)
    xStart=0 if xStart<0
    yStart=(@oyFlash>>5)
    yStart=0 if yStart<0
    xEnd=xStart+(width>>5)+1
    yEnd=yStart+(height>>5)+1
    xEnd=xsize if xEnd>=xsize
    yEnd=ysize if yEnd>=ysize
    if xStart<xEnd && yStart<yEnd
     yrange=yStart...yEnd
     xrange=xStart...xEnd
     tmpcolor=Color.new(0,0,0,0)
     for y in yrange
     ypos=(y<<5)-@oyFlash
     for x in xrange
       xpos=(x<<5)-@oxFlash
       id = @flash_data[x, y, 0]
       r=(id>>8)&15
       g=(id>>4)&15
       b=(id)&15
       tmpcolor.set(r<<4,g<<4,b<<4)
       bitmap.fill_rect(xpos,ypos,32,32,tmpcolor)
     end
     end
    end
    end


    def refreshLayer0(autotiles=false)
    if autotiles
     return true if !shown?
    end
    ptX=@ox-@oxLayer0
    ptY=@oy-@oyLayer0
    if !autotiles && !@firsttime && !@usedsprites &&
       ptX>=0 && ptX+@viewport.rect.width<=@layer0.bitmap.width &&
       ptY>=0 && ptY+@viewport.rect.height<=@layer0.bitmap.height
     if @layer0clip
     @layer0.ox=0
     @layer0.oy=0
     @layer0.src_rect.set(ptX.round,ptY.round,
       @viewport.rect.width,@viewport.rect.height)
     else
     @layer0.ox=ptX.round
     @layer0.oy=ptY.round
     @layer0.src_rect.set(0,0,@layer0.bitmap.width,@layer0.bitmap.height)
     end
     return true
    end
    width=@layer0.bitmap.width
    height=@layer0.bitmap.height
    bitmap=@layer0.bitmap
    ysize=@map_data.ysize
    xsize=@map_data.xsize
    zsize=@map_data.zsize
    if autotiles
     return true if @fullyrefreshedautos && @prioautotiles.length==0
     xStart=(@oxLayer0>>5)
     xStart=0 if xStart<0
     yStart=(@oyLayer0>>5)
     yStart=0 if yStart<0
     xEnd=xStart+(width>>5)+1
     yEnd=yStart+(height>>5)+1
     xEnd=xsize if xEnd>xsize
     yEnd=ysize if yEnd>ysize
     return true if xStart>=xEnd || yStart>=yEnd
     trans=Color.new(0,0,0,0)
     temprect=Rect.new(0,0,0,0)
     tilerect=Rect.new(0,0,32,32)
     range=0...zsize
     overallcount=0
     count=0
     if !@fullyrefreshedautos
     for y in yStart..yEnd
       for x in xStart..xEnd
       haveautotile=false
       for z in range
         id = @map_data[x, y, z]
         next if id<48 || id>=384 || @priorities[id]!=0 || !@priorities[id]
         next if @framecount[id/48-1]<2
         if !haveautotile
           haveautotile=true
           overallcount+=1
           xpos=(x<<5)-@oxLayer0
           ypos=(y<<5)-@oyLayer0
           bitmap.fill_rect(xpos,ypos,0,0,trans) if overallcount<=2000
           break
         end
       end
       for z in range
         id = @map_data[x,y,z]
         next if id<48 || @priorities[id]!=0 || !@priorities[id]
         if overallcount>2000
         xpos=(x<<5)-@oxLayer0
         ypos=(y<<5)-@oyLayer0
         count=addTile(@autosprites,count,xpos,ypos,id)
         next
         elsif id>=384
         temprect.set(((id - 384)&7)<<5,((id - 384)>>3)<<5,32,32)
         xpos=(x<<5)-@oxLayer0
         ypos=(y<<5)-@oyLayer0
         bitmap.blt(xpos,ypos,@tileset,temprect)
         else
         tilebitmap=@autotileInfo[id]
         if !tilebitmap
           anim=autotileFrame(id)
           next if anim<0
           tilebitmap=Bitmap.new(32,32)
           bltAutotile(tilebitmap,0,0,id,anim)
           @autotileInfo[id]=tilebitmap
         end
         xpos=(x<<5)-@oxLayer0
         ypos=(y<<5)-@oyLayer0
         bitmap.blt(xpos,ypos,tilebitmap,tilerect)
         end
       end
       end
     end
     else
     for tile in @prioautotiles
       x=tile[0]
       y=tile[1]
       next if x<xStart||x>xEnd
       next if y<yStart||y>yEnd
       overallcount+=1
       xpos=(x<<5)-@oxLayer0
       ypos=(y<<5)-@oyLayer0
       bitmap.fill_rect(xpos,ypos,0,0,trans) if overallcount<=2000
       for z in range
       id = @map_data[x,y,z]
       next if id<48 || @priorities[id]!=0 || !@priorities[id]
       if overallcount>2000
         count=addTile(@autosprites,count,xpos,ypos,id)
         next
       elsif id>=384
         temprect.set(((id - 384)&7)<<5,((id - 384)>>3)<<5,32,32)
         bitmap.blt(xpos,ypos,@tileset,temprect)
       else
         tilebitmap=@autotileInfo[id]
         if !tilebitmap
           anim=autotileFrame(id)
           next if anim<0
           tilebitmap=Bitmap.new(32,32)
           bltAutotile(tilebitmap,0,0,id,anim)
           @autotileInfo[id]=tilebitmap
         end
         bitmap.blt(xpos,ypos,tilebitmap,tilerect)
       end
       end
     end
     end
     Graphics.frame_reset if overallcount>2000
     @usedsprites=false
     return true
    end
    return false if @usedsprites
    @firsttime=false
    @oxLayer0=@ox-(width>>2)
    @oyLayer0=@oy-(height>>2)
    if @layer0clip
     @layer0.ox=0
     @layer0.oy=0
     @layer0.src_rect.set(width>>2,height>>2,
       @viewport.rect.width,@viewport.rect.height)
    else
     @layer0.ox=(width>>2)
     @layer0.oy=(height>>2)
    end
    @layer0.bitmap.clear
    @oxLayer0=@oxLayer0.floor
    @oyLayer0=@oyLayer0.floor
    xStart=(@oxLayer0>>5)
    xStart=0 if xStart<0
    yStart=(@oyLayer0>>5)
    yStart=0 if yStart<0
    xEnd=xStart+(width>>5)+1
    yEnd=yStart+(height>>5)+1
    xEnd=xsize if xEnd>=xsize
    yEnd=ysize if yEnd>=ysize
    if xStart<xEnd && yStart<yEnd
     tmprect=Rect.new(0,0,0,0)
     yrange=yStart...yEnd
     xrange=xStart...xEnd
     for z in 0...zsize
     for y in yrange
       ypos=(y<<5)-@oyLayer0
       for x in xrange
       xpos=(x<<5)-@oxLayer0
       id = @map_data[x, y, z]
       next if id==0 || @priorities[id]!=0 || !@priorities[id]
       if id>=384
         tmprect.set((id - 384) % 8 * 32, (id - 384) / 8 * 32,32,32)
         bitmap.blt(xpos,ypos,@tileset,tmprect)
       else
         frame=autotileFrame(id)
         bltAutotile(bitmap,xpos,ypos,id,frame)
       end
       end
     end
     end
     Graphics.frame_reset
    end
    return true
    end
    def getResizeFactor
     return $ResizeFactor ? $ResizeFactor : 1.0
    end
    def ox=(val)
     val=(val*getResizeFactor).to_i
     val=(val/getResizeFactor).to_i
     wasshown=self.shown?
     @ox=val.floor
     @nowshown=(!wasshown && self.shown?)
    end
    def oy=(val)
     val=(val*getResizeFactor).to_i
     val=(val/getResizeFactor).to_i
     wasshown=self.shown?
     @oy=val.floor
     @nowshown=(!wasshown && self.shown?)
    end
    def visible=(val)
     wasshown=@visible
     @visible=val
     @nowshown=(!wasshown && val)
    end
    def refresh(autotiles=false)
    @oldOx=@ox
    @oldOy=@oy
    usesprites=false
    if @layer0
     @layer0.visible=@visible
     usesprites=!refreshLayer0(autotiles)
     if autotiles && !usesprites
     return
     end
    else
     usesprites=true
    end
    refreshFlashSprite
    vpx=@viewport.rect.x
    vpy=@viewport.rect.y
    vpr=@viewport.rect.width+vpx
    vpb=@viewport.rect.height+vpy
    xsize=@map_data.xsize
    ysize=@map_data.ysize
    minX=(@ox/32)-1
    maxX=((@ox+@viewport.rect.width)/32)+1
    minY=(@oy/32)-1
    maxY=((@oy+@viewport.rect.height)/32)+1
    minX=0 if minX<0
    minX=xsize-1 if minX>=xsize
    maxX=0 if maxX<0
    maxX=xsize-1 if maxX>=xsize
    minY=0 if minY<0
    minY=ysize-1 if minY>=ysize
    maxY=0 if maxY<0
    maxY=ysize-1 if maxY>=ysize
    count=0
    if minX<maxX && minY<maxY
     @usedsprites=usesprites || @usedsprites
     if @layer0
     @layer0.visible=false if usesprites
     end
     if @fullyrefreshed
     for prio in @priotiles
       x=prio[0]
       y=prio[1]
       next if x<minX||x>maxX
       next if y<minY||y>maxY
       id=prio[3]
       xpos=(x<<5)-@ox
       ypos=(y<<5)-@oy
       count=addTile(@tiles,count,xpos,ypos,id)
     end
     else
     for z in 0...@map_data.zsize
       for y in minY..maxY
       for x in minX..maxX
         id = @map_data[x, y, z]
         next if id==0 || !@priorities[id]
         next if @priorities[id]==0
         xpos=(x<<5)-@ox
         ypos=(y<<5)-@oy
         count=addTile(@tiles,count,xpos,ypos,id)
       end
       end
     end
     end
    end
    if count<@tiles.length
     bigchange=(count<=(@tiles.length*2/3)) && (@tiles.length*2/3)>25
     j=count;len=@tiles.length;while j<len
     sprite=@tiles[j]
     @tiles[j+1]=-1
     if bigchange
       sprite.dispose
       @tiles[j]=nil
       @tiles[j+1]=nil
     elsif !@tiles[j].disposed?
       sprite.visible=false if sprite.visible
     end
     j+=2
     end
     @tiles.compact! if bigchange
    end
    end
    end



    Instructions

    Just insert this script above main.


    Compatibility

    No compatibility issues found.


    Credits and Thanks


    • Pokemon Essentials - for the original code source

    • Wecoc (me) - for the simple add-on




    Author's Notes

    If you have any problem with that script or with incompatibilities don't hestitate to ask.