The RPG Maker Resource Kit

RMRK RPG Maker Creation => RPG Maker General => General Scripting => Topic started by: Tsunokiette on September 26, 2006, 09:37:16 PM

Title: Using an Actors Name in and Item Script ~ Tested
Post by: Tsunokiette on September 26, 2006, 09:37:16 PM
Replace your Window_Item with the following script -

*forget it*
Title: Re: Using an Actors Name in and Item Script ~ Tested
Post by: thingy on September 26, 2006, 11:51:44 PM
omg I love you, almost all of my characters names are changed when you meet them (cept one cuz he looks cool so I'm giving him a cool name)
Title: Re: Using an Actors Name in and Item Script ~ Tested
Post by: Naphe on September 27, 2006, 12:17:30 AM
Yes, I'm already using this code, thanks.
Title: Re: Using an Actors Name in and Item Script ~ Tested
Post by: Tsunokiette on September 27, 2006, 02:39:03 AM
Minor error realized, don't use this version. Will update with version 2 VERY soon.

EDIT : Forget it, the dang thing doesn't want to work. It keeps doing weird stuff, it won't even let me use the $game_actors class. I tried many different ways, but none worked, it always errored at the Game_Actors class.

The following is written off the top of my head, I did something similar to it but it didn't work. BTW: I tried the gsub method, but I kept getting errors.

text = item.name
temp = text.split(/ /)
for i in 0..(temp.size)
if temp[i].include?('[') and temp[i].include?(']')
temp[i].delete!('[')
temp[i].delete!(']')
values = 0
for j in 'a'...'z'
if !temp[i].include?(j)
values += 1
end
end
if values == 26
temp[i] = $game_actors[temp[i].to_i - 1].name
end
end
end
text = ''
for j in 0..(temp.size)
text = text + ' ' + temp[j]
end
Title: Re: Using an Actors Name in and Item Script ~ Tested
Post by: Tsunokiette on September 27, 2006, 09:49:18 PM
I seriously need help, it keeps telling me there's no method " name". It doesn't matter what class I use, $data_actors or $game_actors. I even defined a name method, and it gives me the same crap.

  #--------------------------------------------------------------------------
  # * Draw Item
  #     index : item number
  #--------------------------------------------------------------------------
  def draw_item(index)
    item = @data[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
    if item.is_a?(RPG::Item) and
       $game_party.item_can_use?(item.id)
      self.contents.font.color = normal_color
    else
      self.contents.font.color = disabled_color
    end
    text = item.name
    text.gsub!(/\[([0-9]+)\]/) { $data_actors[$1.to_i - 1].name }
    x = 4 + index % 2 * (288 + 32)
    y = index / 2 * 32
    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 + 4, bitmap, Rect.new(0, 0, 24, 24), opacity)
    self.contents.draw_text(x + 28, y, 212, 32, text, 0)
    self.contents.draw_text(x + 240, y, 16, 32, ":", 1)
    self.contents.draw_text(x + 256, y, 24, 32, number.to_s, 2)
  end
Title: Re: Using an Actors Name in and Item Script ~ Tested
Post by: Winged on September 27, 2006, 10:04:15 PM
it sounded interesting....maybe bliz can help?

~Winged
Title: Re: Using an Actors Name in and Item Script ~ Tested
Post by: thingy on September 27, 2006, 10:54:20 PM
we need  :fred: (blizzard)

:P
Title: Re: Using an Actors Name in and Item Script ~ Tested
Post by: Blizzard on September 28, 2006, 03:35:01 PM
*copies the code* I can´t right now, but I´ll tell you tomorrow if I succeeded with something.
Title: Re: Using an Actors Name in and Item Script ~ Tested
Post by: thingy on September 29, 2006, 01:31:52 AM
ty ;D
Title: Re: Using an Actors Name in and Item Script ~ Tested
Post by: Blizzard on September 29, 2006, 11:33:49 AM
Okay, since I know Tsuno will add me into the credits of this script no matter what even if I only changed one line, I also added the same support for item/weapon/armor descriptions. Just use \n[X] where X is the ID of the character in the database. You can use it in Item names AND descriptions.

#==============================================================================
# Window_Item
#==============================================================================

class Window_Item < Window_Selectable

  def draw_item(index)
    item = @data[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
    if item.is_a?(RPG::Item) and
       $game_party.item_can_use?(item.id)
      self.contents.font.color = normal_color
    else
      self.contents.font.color = disabled_color
    end
    text = item.name
    text.gsub!(/\\[Nn]\[([0-9]+)\]/) do
      $game_actors[$1.to_i] != nil ? $game_actors[$1.to_i].name : ""
    end
    x = 4 + index % 2 * (288 + 32)
    y = index / 2 * 32
    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 + 4, bitmap, Rect.new(0, 0, 24, 24), opacity)
    self.contents.draw_text(x + 28, y, 212, 32, text, 0)
    self.contents.draw_text(x + 240, y, 16, 32, ":", 1)
    self.contents.draw_text(x + 256, y, 24, 32, number.to_s, 2)
  end
 
end

#==============================================================================
# Window_Help
#==============================================================================

class Window_Help < Window_Base
 
  alias set_text_playername_later set_text
  def set_text(text)
    text.gsub!(/\\[Nn]\[([0-9]+)\]/) do
      $game_actors[$1.to_i] != nil ? $game_actors[$1.to_i].name : ""
    end
    set_text_playername_later(text)
  end
 
end

Title: Re: Using an Actors Name in and Item Script ~ Tested
Post by: thingy on October 07, 2006, 02:56:49 AM
description works, doesn't work for the name tho
Title: Re: Using an Actors Name in and Item Script ~ Tested
Post by: Blizzard on October 07, 2006, 11:37:16 AM
?_? It worked for me. Can somebody else test it?
Title: Re: Using an Actors Name in and Item Script ~ Tested
Post by: l0itty on October 08, 2006, 06:44:45 AM
good !thankyou!
Title: Re: Using an Actors Name in and Item Script ~ Tested
Post by: Naphe on October 08, 2006, 05:36:58 PM
Just wondering if you can some how make this a little bit better. I was wondering if you could make it so you could also show item and skill names by \i[X] and \s[X] commands.
Title: Re: Using an Actors Name in and Item Script ~ Tested
Post by: Blizzard on October 09, 2006, 10:01:53 AM
That's for a message system while this is supposed to be used directly in names and description. I think Dubealex' AMS might support such commands like \i[X] and \s[X], but I can't tell for sure.
Title: Re: Using an Actors Name in and Item Script ~ Tested
Post by: Naphe on October 10, 2006, 12:21:27 AM
Well, if you could check for me, it would be most appreciated. I tried to edit the script myself, but to no avail.
Title: Re: Using an Actors Name in and Item Script ~ Tested
Post by: Sthrattoff on October 20, 2006, 07:25:41 PM
Well, well, well...
It works on me with one 'condition' :
Need open the Item window first.
Then it's appear on the Equip screen...
Else...
It shows "\n[1]" on the Window_Help.