I wrote an item window script, but when I try to use it, I get an error saying that an RGSS error occurred on Selwyn's Window Cursor. I don't know what is causing the error at all, but I know that the problem is with my script.
Here is the small code I wrote:
Here is Selwyn's Window Cursor:
Here is the small code I wrote:
Code:
class Window_Itemget < Window_Message
def initialize(itemid)
@itemid = itemid
@itemid = ""
self.x = 2
self.y_bottom = 5
self.width = 236
self.height = 64
self.contents = Bitmap.new(width - 32, height - 32)
self.contents.font.name = "Kartika"
self.contents.font.size = 20
self.windowskin = RPG::Cache.windowskin("wskin_g3")
refresh
end
def refresh
def refresh
self.contents.clear
self.contents.font.color = normal_color
self.contents.draw_text(4, 0, 180, 32, itemid)
end
end
end
Here is Selwyn's Window Cursor:
Code:
class Sprite_Cursor < Sprite
#--------------------------------------------------------------------------
# â— instances
#--------------------------------------------------------------------------
attr_accessor :true_x
attr_accessor :true_y
#--------------------------------------------------------------------------
# â— initialize
#--------------------------------------------------------------------------
def initialize(x = 0, y = 0)
super()
self.x = @true_x = x
self.y = @true_y = y
self.z = 10000
self.bitmap = RPG::Cache.picture("cursor") rescue Bitmap.new(32, 32)
end
#--------------------------------------------------------------------------
# â— update
#--------------------------------------------------------------------------
def update
super
if self.y < @true_y
n = (@true_y - self.y) / 3
n = 1 if n == 0
self.y += n
elsif self.y > @true_y
n = (self.y - @true_y) / 3
n = 1 if n == 0
self.y -= n
end
if self.x < @true_x
n = (@true_x - self.x) / 3
n = 1 if n == 0
self.x += n
elsif self.x > @true_x
n = (self.x - @true_x) / 3
n = 1 if n == 0
self.x -= n
end
end
end
#==============================================================================
# â– Window_Selectable
#==============================================================================
class Window_Selectable < Window_Base
#--------------------------------------------------------------------------
# â— instances
#--------------------------------------------------------------------------
attr_reader :index
attr_reader :help_window
attr_accessor :cursor
alias update_cursor_moves update
#--------------------------------------------------------------------------
# â— initialize
#--------------------------------------------------------------------------
def initialize(x, y, width, height)
super(x, y, width, height)
@item_max = 1
@column_max = 1
@index = -1
@cursor = Sprite_Cursor.new(x, y)
update_cursor
end
#--------------------------------------------------------------------------
# â— x=
#--------------------------------------------------------------------------
def x=(x)
super
@cursor.x = x if !@cursor.nil?
end
#--------------------------------------------------------------------------
# â— y=
#--------------------------------------------------------------------------
def y=(y)
super
@cursor.y = y if !@cursor.nil?
end
#--------------------------------------------------------------------------
# â— visible=
#--------------------------------------------------------------------------
def visible=(visible)
super
if !@cursor.nil? and visible == false
@cursor.visible = false
end
end
#--------------------------------------------------------------------------
# â— dispose
#--------------------------------------------------------------------------
def dispose
@cursor.dispose
super
end
#--------------------------------------------------------------------------
# â— update_cursor_rect
#--------------------------------------------------------------------------
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 + 32)
y = @index / @column_max * 32 - self.oy
self.cursor_rect.set(x, y, cursor_width, 32)
end
#--------------------------------------------------------------------------
# â— update_cursor
#--------------------------------------------------------------------------
def update_cursor
@cursor.true_x = self.cursor_rect.x + self.x - 8
@cursor.true_y = self.cursor_rect.y + self.y + 16
@cursor.update
@cursor.visible = (self.visible and self.index >= 0)
end
#--------------------------------------------------------------------------
# â— update
#--------------------------------------------------------------------------
def update
update_cursor_moves
update_cursor
end
end