Annoying Crushes With V.M of D.T's Sleek Item Popup

Joined
Apr 17, 2013
Messages
93
Reaction score
6
First Language
English
Primarily Uses
N/A
So... This is kinda weird. When testing items with new saves (spawning char right next to a chest with the item), the script works fine, but when continuing older saves, my players keep getting the following crush: Script 'Item Popup' line 109: ZeroDivisionError occured.
Divided by 0 (see the first attached image)

The version of the script I use is 1.13, and I can only find version 1.00 online, so I'm including it here:
Code:
#Sleek Item Popup v1.13
#----------#
#Features: A nice and sleek little pop up you can use to tell the player
#           they received (or lost) an item! Now with automatic popups whenever
#           you use the gain item commands in events!
#
#Usage:   Event Script Call:
#           popup(type,item,amount,[duration],[xoff],[yoff])
#
#          Where: type is category of item (0 = item, 1 = weapon,
#                                            2 = armor, 3 = gold)
#                 item is the id number of the item
#                 amount is the amount lost or gained
#                 duration is the time the window is up and is optional
#        
#          Examples:
#            popup(0,1,5)
#            popup(2,12,1,120)
#            $PU_AUTOMATIC_POPUP = false
#            $PU_AUTOMATIC_POPUP = true
#      
#Customization: Everything down there under customization
#
#----------#
#-- Script by: V.M of D.T
#
#- Questions or comments can be:
#    given by email: sumptuaryspade@live.ca
#    provided on facebook: http://www.facebook.com/DaimoniousTailsGames
#   All my other scripts and projects can be found here:
#         http://daimonioustails.weebly.com/
#
#--- Free to use in any project, commercial or non-commercial, with credit given
# - - Though a donation's always a nice way to say thank you~ (I also accept actual thank you's)
 
$imported = {} if $imported.nil?
$imported[:Vlue_SleekPopup] = true
 
#Sound effect played on popup: # "Filename", Volume(0-100), Pitch(50-150)
PU_SOUND_EFFECT_GAIN = ["Ice1",100,100]
PU_SOUND_EFFECT_LOSE = ["Ice1",100,100]
PU_SOUND_GOLD_GAIN = ["Coin",100,100]
PU_SOUND_GOLD_LOSE = ["Coin",100,100]
 
#Animation to be played on the player during popup
PU_USE_ANIMATION = false
PU_POPUP_ANIMATION = 2
 
#Duration in frames of Item Popup fadein and fadeout
PU_FADEIN_TIME = 30
PU_FADEOUT_TIME = 30
 
#Default duration of the popup
PU_DEFAULT_DURATION = 90
 
#Use automatic popup? Can be enabled/disabled in game, see examples
$PU_AUTOMATIC_POPUP = true
 
#Whether to use a custom or default font
PU_USE_CUSTOM_FONT = true
 
#Settings for custom item popup font
PU_DEFAULT_FONT_NAME = ["Verdana"]
PU_DEFAULT_FONT_SIZE = 16
PU_DEFAULT_FONT_COLOR = Color.new(255,255,255,255)
PU_DEFAULT_FONT_BOLD = false
PU_DEFAULT_FONT_ITALIC = false
PU_DEFAULT_FONT_SHADOW = false
PU_DEFAULT_FONT_OUTLINE = true
 
#Compact mode will hide the amount unless it's greater then 1
PU_COMPACT_MODE = true
 
#Background Icon to be displayed under item icon
PU_USE_BACKGROUND_ICON = true
PU_BACKGROUND_ICON = 102
 
#Gold details:
PU_GOLD_NAME = "Gold"
PU_GOLD_ICON = 262
 
#True for single line, false for multi line
PU_SINGLE_LINE = true
 
class Item_Popup < Window_Base
  def initialize(item, amount, duration, nosound,xoff,yoff)
    super(0,0,100,96)
    if item.name != PU_GOLD_NAME
      sedg, sedl = PU_SOUND_EFFECT_GAIN, PU_SOUND_EFFECT_LOSE
    else
      sedg, sedl = PU_SOUND_GOLD_GAIN, PU_SOUND_GOLD_LOSE
    end
    se = RPG::SE.new(sedg[0],sedg[1],sedg[2]) unless sedg.nil? or nosound
    se2 = RPG::SE.new(sedl[0],sedl[1],sedl[2]) unless sedl.nil? or nosound
    se.play if se and amount > 0
    se2.play if se2 and amount < 0
    self.opacity = 0
    self.x = $game_player.screen_x - 16
    self.y = $game_player.screen_y - 80
    @xoff = 0
    @yoff = 0
    @duration = 90
    @item = item
    @amount = amount
    @name = item.name.clone
    @text = ""
    @padding = ' '*@name.size
    @timer = 0
    @split = (PU_FADEIN_TIME) / @name.size
    @split = 2 if @split < 2
    amount > 0 ? @red = Color.new(0,255,0) : @red = Color.new(255,0,0)
    if PU_USE_CUSTOM_FONT
      contents.font.size = PU_DEFAULT_FONT_SIZE
    else
      contents.font.size = 16
    end
    @textsize = text_size(@name)
    textsize2 = text_size("+" + amount.to_s)
    self.width = @textsize.width + standard_padding * 2 + 24
    self.width += textsize2.width + 48 if PU_SINGLE_LINE
    contents.font.size < 24 ? size = 24 : size = contents.font.size
    self.height = size + standard_padding * 2
    self.height += size if !PU_SINGLE_LINE
    self.x -= self.width / 2
    create_contents
    if PU_USE_CUSTOM_FONT
      contents.font.name = PU_DEFAULT_FONT_NAME
      contents.font.size = PU_DEFAULT_FONT_SIZE
      contents.font.color = PU_DEFAULT_FONT_COLOR
      contents.font.bold = PU_DEFAULT_FONT_BOLD
      contents.font.italic = PU_DEFAULT_FONT_ITALIC
      contents.font.shadow = PU_DEFAULT_FONT_SHADOW
      contents.font.outline = PU_DEFAULT_FONT_OUTLINE
    end
    self.contents_opacity = 0
    $game_player.animation_id = PU_POPUP_ANIMATION if PU_USE_ANIMATION
    update
  end
  def update
    #super
    return if self.disposed?
    self.visible = true if !self.visible
    self.x = $game_player.screen_x - contents.width/4 + 12
    self.y = $game_player.screen_y - 80 + @yoff
    self.x -= self.width / 3
    open if @timer < (PU_FADEIN_TIME)
    close if @timer > (PU_FADEOUT_TIME + @duration)
    @timer += 1
    return if @timer % @split != 0
    @text += @name.slice!(0,1)
    @padding.slice!(0,1)
    contents.clear
    contents.font.color = @red
    stringamount = @amount
    stringamount = "+" + @amount.to_s if @amount > 0
    if PU_SINGLE_LINE
      width = text_size(@item.name).width#@textsize.width
      draw_text(27 + width,0,36,24,stringamount) unless PU_COMPACT_MODE and @amount == 1
      if Module.const_defined?(:AFFIXES)
        contents.font.color = @item.color
      else
        contents.font.color = Font.default_color
      end
      change_color(@item.rarity_colour) if $imported[:TH_ItemRarity]
      draw_text(24,0,contents.width,contents.height,@text+@padding)
      change_color(normal_color)
      draw_icon(PU_BACKGROUND_ICON,0,0) if PU_USE_BACKGROUND_ICON
      draw_icon(@item.icon_index,0,0)
    else
      draw_text(contents.width / 4 + 16,24,36,24,stringamount) unless PU_COMPACT_MODE and @amount == 1
      if Module.const_defined?(:AFFIXES)
        contents.font.color = @item.color
      else
        contents.font.color = Font.default_color
      end
      draw_icon(PU_BACKGROUND_ICON,contents.width / 2 - 24,24) if PU_USE_BACKGROUND_ICON
      draw_icon(@item.icon_index,contents.width / 2 - 24,24)
      draw_text(0,0,contents.width,line_height,@text+@padding)
    end
  end
  def close
    self.contents_opacity -= (255 / (PU_FADEOUT_TIME))
  end
  def open
    self.contents_opacity += (255 / (PU_FADEIN_TIME))
  end
end
 
class Game_Interpreter
  alias pu_command_126 command_126
  alias pu_command_127 command_127
  alias pu_command_128 command_128
  alias pu_command_125 command_125
  def popup(type,item,amount,duration = PU_DEFAULT_DURATION,nosound = false, xo = 0, yo = 0)
    data = $data_items[item] if type == 0
    data = $data_weapons[item] if type == 1
    data = $data_armors[item] if type == 2
    if type == 3
      data = RPG::Item.new
      data.name = PU_GOLD_NAME
      data.icon_index = PU_GOLD_ICON
    end
    Popup_Manager.add(data,amount,duration,nosound,xo,yo)
  end
  def command_126
    pu_command_126
    value = operate_value(@params[1], @params[2], @params[3])
    popup(0,@params[0],value) if $PU_AUTOMATIC_POPUP
  end
  def command_127
    pu_command_127
    value = operate_value(@params[1], @params[2], @params[3])
    popup(1,@params[0],value) if $PU_AUTOMATIC_POPUP
  end
  def command_128
    pu_command_128
    value = operate_value(@params[1], @params[2], @params[3])
    popup(2,@params[0],value) if $PU_AUTOMATIC_POPUP
  end
  def command_125
    pu_command_125
    value = operate_value(@params[0], @params[1], @params[2])
    popup(3,@params[0],value) if $PU_AUTOMATIC_POPUP
  end
end
 
module Popup_Manager
  def self.init
    @queue = []
  end
  def self.add(item,value,dura,ns,xo,yo)
    @queue.insert(0,[item,value,dura,ns,xo,yo])
  end
  def self.queue
    @queue
  end
end
 
Popup_Manager.init
 
class Scene_Map
  alias popup_update update
  alias popup_preterminate pre_terminate
  def update
    popup_update
    update_popup_window unless $popupwindow.nil?
    return if Popup_Manager.queue.empty?
    if $popupwindow.nil? or $popupwindow.contents_opacity == 0
      var = Popup_Manager.queue.pop
      $popupwindow = Item_Popup.new(var[0],var[1],var[2],var[3],var[4],var[5])
    end
  end
  def update_popup_window
    $popupwindow.update
    $popupwindow.dispose if !$popupwindow.disposed? and $popupwindow.contents_opacity == 0
    $popupwindow = nil if $popupwindow.disposed?
  end
  def pre_terminate
    popup_preterminate
    $popupwindow.visible = false unless $popupwindow.nil?
  end
end

The bug keeps happening on the same items each time (so far only found it on one specific weapon and one armor), but I cannot find anything different I do with them than I have with other items, nor anything common with the items getting the crush. I have attempted changing their names, properties etc, but it's like the problem is connected with their ID instead of the names, which is weird. Anyone have a clue how to fix this?

Keep in mind that the bug triggers only when finding the items in chests or from dialogues. Receiving the item from a vendor does not trigger the crush as it does not call the popup script, so the problem lies with the script, not the items (probably).
 

Attachments

Last edited:

Kes

Veteran
Veteran
Joined
Aug 3, 2012
Messages
22,299
Reaction score
11,712
First Language
English
Primarily Uses
RMVXA
'Scripts' is where people who written completed scripts they want to share with others can post them.

[move]RGSSx Script Support[/move]
If you are trying to use this script with saves made before you inserted the script, you will get errors. Most scripts require you to start with a new game, as they are trying to call data info which they cannot find in older saves.
 

Shaz

Veteran
Veteran
Joined
Mar 2, 2012
Messages
40,098
Reaction score
13,704
First Language
English
Primarily Uses
RMMV
The error line seems to indicate that the length of the name is 0. Do you have any items you're using this script with, that do not have names?

I didn't think $data_items got saved with the save file, but maybe you have another script that does that, and those items weren't set up in the database when you saved those games.
 

TheoAllen

Self-proclaimed jack of all trades
Veteran
Joined
Mar 16, 2012
Messages
5,592
Reaction score
6,522
First Language
Indonesian
Primarily Uses
RMVXA
Why not just change ...
Code:
@split = (PU_FADEIN_TIME) / [@name.size, 1].max
Btw, it isn't advised to use old save file, it's a common problem that after adding a new script and stuff, older save file becomes irrelevant and may run errors.
 
Joined
Apr 17, 2013
Messages
93
Reaction score
6
First Language
English
Primarily Uses
N/A
Why not just change ...
Code:
@split = (PU_FADEIN_TIME) / [@name.size, 1].max
Btw, it isn't advised to use old save file, it's a common problem that after adding a new script and stuff, older save file becomes irrelevant and may run errors.
Hm... So this closes the display of the item if it's one of those having the bug... Well, still better than the entire game crushing every time, thanks!
Unless someone else has an even better idea, mod, you can close this thread now.

For any potential future users of the script, the non-crushing version of the script is this:
Code:
#Sleek Item Popup v1.14
#----------#
#Features: A nice and sleek little pop up you can use to tell the player
#           they received (or lost) an item! Now with automatic popups whenever
#           you use the gain item commands in events!
#
#Usage:   Event Script Call:
#           popup(type,item,amount,[duration],[xoff],[yoff])
#
#          Where: type is category of item (0 = item, 1 = weapon,
#                                            2 = armor, 3 = gold)
#                 item is the id number of the item
#                 amount is the amount lost or gained
#                 duration is the time the window is up and is optional
#        
#          Examples:
#            popup(0,1,5)
#            popup(2,12,1,120)
#            $PU_AUTOMATIC_POPUP = false
#            $PU_AUTOMATIC_POPUP = true
#      
#Customization: Everything down there under customization
#
#----------#
#-- Script by: V.M of D.T
#
#- Questions or comments can be:
#    given by email: sumptuaryspade@live.ca
#    provided on facebook: http://www.facebook.com/DaimoniousTailsGames
#   All my other scripts and projects can be found here:
#         http://daimonioustails.weebly.com/
#
#--- Free to use in any project, commercial or non-commercial, with credit given
# - - Though a donation's always a nice way to say thank you~ (I also accept actual thank you's)
 
$imported = {} if $imported.nil?
$imported[:Vlue_SleekPopup] = true
 
#Sound effect played on popup: # "Filename", Volume(0-100), Pitch(50-150)
PU_SOUND_EFFECT_GAIN = ["Ice1",100,100]
PU_SOUND_EFFECT_LOSE = ["Ice1",100,100]
PU_SOUND_GOLD_GAIN = ["Coin",100,100]
PU_SOUND_GOLD_LOSE = ["Coin",100,100]
 
#Animation to be played on the player during popup
PU_USE_ANIMATION = false
PU_POPUP_ANIMATION = 2
 
#Duration in frames of Item Popup fadein and fadeout
PU_FADEIN_TIME = 30
PU_FADEOUT_TIME = 30
 
#Default duration of the popup
PU_DEFAULT_DURATION = 90
 
#Use automatic popup? Can be enabled/disabled in game, see examples
$PU_AUTOMATIC_POPUP = true
 
#Whether to use a custom or default font
PU_USE_CUSTOM_FONT = true
 
#Settings for custom item popup font
PU_DEFAULT_FONT_NAME = ["Verdana"]
PU_DEFAULT_FONT_SIZE = 16
PU_DEFAULT_FONT_COLOR = Color.new(255,255,255,255)
PU_DEFAULT_FONT_BOLD = false
PU_DEFAULT_FONT_ITALIC = false
PU_DEFAULT_FONT_SHADOW = false
PU_DEFAULT_FONT_OUTLINE = true
 
#Compact mode will hide the amount unless it's greater then 1
PU_COMPACT_MODE = true
 
#Background Icon to be displayed under item icon
PU_USE_BACKGROUND_ICON = true
PU_BACKGROUND_ICON = 102
 
#Gold details:
PU_GOLD_NAME = "Gold"
PU_GOLD_ICON = 262
 
#True for single line, false for multi line
PU_SINGLE_LINE = true
 
class Item_Popup < Window_Base
  def initialize(item, amount, duration, nosound,xoff,yoff)
    super(0,0,100,96)
    if item.name != PU_GOLD_NAME
      sedg, sedl = PU_SOUND_EFFECT_GAIN, PU_SOUND_EFFECT_LOSE
    else
      sedg, sedl = PU_SOUND_GOLD_GAIN, PU_SOUND_GOLD_LOSE
    end
    se = RPG::SE.new(sedg[0],sedg[1],sedg[2]) unless sedg.nil? or nosound
    se2 = RPG::SE.new(sedl[0],sedl[1],sedl[2]) unless sedl.nil? or nosound
    se.play if se and amount > 0
    se2.play if se2 and amount < 0
    self.opacity = 0
    self.x = $game_player.screen_x - 16
    self.y = $game_player.screen_y - 80
    @xoff = 0
    @yoff = 0
    @duration = 90
    @item = item
    @amount = amount
    @name = item.name.clone
    @text = ""
    @padding = ' '*@name.size
    @timer = 0
    @split = (PU_FADEIN_TIME) / [@name.size, 1].max
    @split = 2 if @split < 2
    amount > 0 ? @red = Color.new(0,255,0) : @red = Color.new(255,0,0)
    if PU_USE_CUSTOM_FONT
      contents.font.size = PU_DEFAULT_FONT_SIZE
    else
      contents.font.size = 16
    end
    @textsize = text_size(@name)
    textsize2 = text_size("+" + amount.to_s)
    self.width = @textsize.width + standard_padding * 2 + 24
    self.width += textsize2.width + 48 if PU_SINGLE_LINE
    contents.font.size < 24 ? size = 24 : size = contents.font.size
    self.height = size + standard_padding * 2
    self.height += size if !PU_SINGLE_LINE
    self.x -= self.width / 2
    create_contents
    if PU_USE_CUSTOM_FONT
      contents.font.name = PU_DEFAULT_FONT_NAME
      contents.font.size = PU_DEFAULT_FONT_SIZE
      contents.font.color = PU_DEFAULT_FONT_COLOR
      contents.font.bold = PU_DEFAULT_FONT_BOLD
      contents.font.italic = PU_DEFAULT_FONT_ITALIC
      contents.font.shadow = PU_DEFAULT_FONT_SHADOW
      contents.font.outline = PU_DEFAULT_FONT_OUTLINE
    end
    self.contents_opacity = 0
    $game_player.animation_id = PU_POPUP_ANIMATION if PU_USE_ANIMATION
    update
  end
  def update
    #super
    return if self.disposed?
    self.visible = true if !self.visible
    self.x = $game_player.screen_x - contents.width/4 + 12
    self.y = $game_player.screen_y - 80 + @yoff
    self.x -= self.width / 3
    open if @timer < (PU_FADEIN_TIME)
    close if @timer > (PU_FADEOUT_TIME + @duration)
    @timer += 1
    return if @timer % @split != 0
    @text += @name.slice!(0,1)
    @padding.slice!(0,1)
    contents.clear
    contents.font.color = @red
    stringamount = @amount
    stringamount = "+" + @amount.to_s if @amount > 0
    if PU_SINGLE_LINE
      width = text_size(@item.name).width#@textsize.width
      draw_text(27 + width,0,36,24,stringamount) unless PU_COMPACT_MODE and @amount == 1
      if Module.const_defined?(:AFFIXES)
        contents.font.color = @item.color
      else
        contents.font.color = Font.default_color
      end
      change_color(@item.rarity_colour) if $imported[:TH_ItemRarity]
      draw_text(24,0,contents.width,contents.height,@text+@padding)
      change_color(normal_color)
      draw_icon(PU_BACKGROUND_ICON,0,0) if PU_USE_BACKGROUND_ICON
      draw_icon(@item.icon_index,0,0)
    else
      draw_text(contents.width / 4 + 16,24,36,24,stringamount) unless PU_COMPACT_MODE and @amount == 1
      if Module.const_defined?(:AFFIXES)
        contents.font.color = @item.color
      else
        contents.font.color = Font.default_color
      end
      draw_icon(PU_BACKGROUND_ICON,contents.width / 2 - 24,24) if PU_USE_BACKGROUND_ICON
      draw_icon(@item.icon_index,contents.width / 2 - 24,24)
      draw_text(0,0,contents.width,line_height,@text+@padding)
    end
  end
  def close
    self.contents_opacity -= (255 / (PU_FADEOUT_TIME))
  end
  def open
    self.contents_opacity += (255 / (PU_FADEIN_TIME))
  end
end
 
class Game_Interpreter
  alias pu_command_126 command_126
  alias pu_command_127 command_127
  alias pu_command_128 command_128
  alias pu_command_125 command_125
  def popup(type,item,amount,duration = PU_DEFAULT_DURATION,nosound = false, xo = 0, yo = 0)
    data = $data_items[item] if type == 0
    data = $data_weapons[item] if type == 1
    data = $data_armors[item] if type == 2
    if type == 3
      data = RPG::Item.new
      data.name = PU_GOLD_NAME
      data.icon_index = PU_GOLD_ICON
    end
    Popup_Manager.add(data,amount,duration,nosound,xo,yo)
  end
  def command_126
    pu_command_126
    value = operate_value(@params[1], @params[2], @params[3])
    popup(0,@params[0],value) if $PU_AUTOMATIC_POPUP
  end
  def command_127
    pu_command_127
    value = operate_value(@params[1], @params[2], @params[3])
    popup(1,@params[0],value) if $PU_AUTOMATIC_POPUP
  end
  def command_128
    pu_command_128
    value = operate_value(@params[1], @params[2], @params[3])
    popup(2,@params[0],value) if $PU_AUTOMATIC_POPUP
  end
  def command_125
    pu_command_125
    value = operate_value(@params[0], @params[1], @params[2])
    popup(3,@params[0],value) if $PU_AUTOMATIC_POPUP
  end
end
 
module Popup_Manager
  def self.init
    @queue = []
  end
  def self.add(item,value,dura,ns,xo,yo)
    @queue.insert(0,[item,value,dura,ns,xo,yo])
  end
  def self.queue
    @queue
  end
end
 
Popup_Manager.init
 
class Scene_Map
  alias popup_update update
  alias popup_preterminate pre_terminate
  def update
    popup_update
    update_popup_window unless $popupwindow.nil?
    return if Popup_Manager.queue.empty?
    if $popupwindow.nil? or $popupwindow.contents_opacity == 0
      var = Popup_Manager.queue.pop
      $popupwindow = Item_Popup.new(var[0],var[1],var[2],var[3],var[4],var[5])
    end
  end
  def update_popup_window
    $popupwindow.update
    $popupwindow.dispose if !$popupwindow.disposed? and $popupwindow.contents_opacity == 0
    $popupwindow = nil if $popupwindow.disposed?
  end
  def pre_terminate
    popup_preterminate
    $popupwindow.visible = false unless $popupwindow.nil?
  end
end

Thanks for the help Theo.
 

Users Who Are Viewing This Thread (Users: 0, Guests: 1)

Latest Threads

Latest Posts

Latest Profile Posts

How many parameters is 'too many'??
Yay, now back in action Happy Christmas time, coming back!






Back in action to develop the indie game that has been long overdue... Final Fallacy. A game that keeps on giving! The development never ends as the developer thinks to be the smart cookie by coming back and beginning by saying... "Oh bother, this indie game has been long overdue..." How could one resist such? No-one c
So I was playing with filters and this looked interesting...

Versus the normal look...

Kind of gives a very different feel. :LZSexcite:
To whom ever person or persons who re-did the DS/DS+ asset packs for MV (as in, they are all 48x48, and not just x2 the pixel scale) .... THANK-YOU!!!!!!!!! XwwwwX

Forum statistics

Threads
105,849
Messages
1,016,981
Members
137,563
Latest member
cexojow
Top