HomeForumSearchRegister
Pages: [1]
Topic: Name display  (Read 746 times)
0 Members and 2 Sneaky Snoopers are viewing this topic.
ngoaho
  Male
**
Rep: +1/-2
Level 17 (10%)
Real-time RPG is great
View Profile WWW
« on: January 14, 2010, 09:49:40 AM »
IP Logged

display a name above event(npc) and actor(player)
someone have wrote a script like this, but too long and complex, i write a new one that simple to see and simple to use

Code:
class Game_Event
attr_reader :name
def initialize
@name = @event.name
end
end

class Game_Player
def name
  return $game_party.actors[0].name
end

end
class Sprite_Character < RPG::Sprite
  attr_accessor :character
  def initialize(viewport, character = nil)
    super(viewport)
    @character = character
    @filename = @character.character_name.to_s
    @x_frame = @y_frame = 4
    @x_frame = @filename.split(/@/)[1].to_i if @filename.split(/@/)[1].to_i != 0
    @y_frame = @filename.split(/@/)[2].to_i if @filename.split(/@/)[2].to_i != 0
    @name_spr = Sprite.new
    @name_spr.bitmap = Bitmap.new(100,20)
    update
  end
  def update
    super
    if @tile_id != @character.tile_id or @character_name != @character.character_name or @character_hue != @character.character_hue
    @tile_id = @character.tile_id
    @character_name = @character.character_name
    @character_hue = @character.character_hue
    self.bitmap = RPG::Cache.character(@character.character_name,0) rescue self.bitmap = RPG::Cache.character("",0)
    @name_spr.bitmap.clear
    @name_spr.bitmap.draw_text(0,0,100,30,@character.name,1)
    @cw = bitmap.width / @x_frame
    @ch = bitmap.height / @y_frame
    self.ox = @cw / 2
    self.oy = @ch
    end
    self.visible = (not @character.transparent)
    if @tile_id == 0
    sx = @character.pattern * @cw
   case @character.direction
   when 2
     sy = 0 * @ch
   when 4
     sy = 1 * @ch
   when 6
     sy = 2 * @ch
   when 8
     sy = 3 * @ch
   when 1
     if @y_frame == 8
     sy = 4 * @ch
     else
     sy = 1 * @ch
     end
   when 3
     if @y_frame == 8
     sy = 5 * @ch
     else
     sy = 0 * @ch
     end
   when 7
     if @y_frame == 8
     sy = 6 * @ch
     else
     sy = 3 * @ch
     end
   when 9
     if @y_frame == 8
     sy = 7 * @ch
     else
     sy = 2 * @ch
     end
   when 5
     if @y_frame == 8
     sy = 0 * @ch
     else
     sy = 0 * @ch
     end
   end
    self.src_rect.set(sx, sy, @cw, @ch)
    end
    self.x = @character.screen_x

    self.y = @character.screen_y
    self.z = @character.screen_z(@ch)
    @name_spr.x = self.x - @cw/2
    @name_spr.y = self.y - @ch - 30
    @name_spr.z = self.z
    self.opacity = @character.opacity
    self.blend_type = @character.blend_type
    self.bush_depth = @character.bush_depth
    if @character.animation_id != 0
    animation = $data_animations[@character.animation_id]
    animation(animation, true)
    @character.animation_id = 0
    end
  end
end

ok, all done, F12 and test.

** this script include Charset frame change
« Last Edit: January 14, 2010, 09:53:51 AM by ngoaho »

- play audition with me.
- oh, i'm playing jx now.
- leave it, play audition with me.
- ok ok, audition...i'm gonna download now, oh my god, over 2Gb.
- what?
- my hdd is not enough.
- so, why jx is ok.
- oh, jx is ~1Gb, it's enough.
- hmm, you don't want to play with me?
- oh, i want, but it not possible.
- huh, you think your computer is more important than me....

so she angry, not talk with me within 1 week.
Mr_Wiggles
  Male
***
PM me for my password. ^^
Rep: +14/-21
Level 25 (91%)
View Profile
« Reply #1 on: February 05, 2010, 07:51:58 PM »
IP Logged

How does one use this script?

Outbreak: First Blood

Zombie Shooter, RMXP

Progress: [=                    ]  5%
Demo:     [==                  ] 11%
ngoaho
  Male
**
Rep: +1/-2
Level 17 (10%)
Real-time RPG is great
View Profile WWW
« Reply #2 on: February 06, 2010, 03:12:17 AM »
IP Logged

add script and test game..... naming event by edit event name.

- play audition with me.
- oh, i'm playing jx now.
- leave it, play audition with me.
- ok ok, audition...i'm gonna download now, oh my god, over 2Gb.
- what?
- my hdd is not enough.
- so, why jx is ok.
- oh, jx is ~1Gb, it's enough.
- hmm, you don't want to play with me?
- oh, i want, but it not possible.
- huh, you think your computer is more important than me....

so she angry, not talk with me within 1 week.
Mr_Wiggles
  Male
***
PM me for my password. ^^
Rep: +14/-21
Level 25 (91%)
View Profile
« Reply #3 on: February 08, 2010, 03:14:18 AM »
IP Logged

i get an error:

Script 'Game_Map' line 76: ArgumentError occurred.
wrong number of arguments(2 for 0)
 

Outbreak: First Blood

Zombie Shooter, RMXP

Progress: [=                    ]  5%
Demo:     [==                  ] 11%
ngoaho
  Male
**
Rep: +1/-2
Level 17 (10%)
Real-time RPG is great
View Profile WWW
« Reply #4 on: February 08, 2010, 09:47:16 PM »
IP Logged

copy Game_Map line 76 to here.

- play audition with me.
- oh, i'm playing jx now.
- leave it, play audition with me.
- ok ok, audition...i'm gonna download now, oh my god, over 2Gb.
- what?
- my hdd is not enough.
- so, why jx is ok.
- oh, jx is ~1Gb, it's enough.
- hmm, you don't want to play with me?
- oh, i want, but it not possible.
- huh, you think your computer is more important than me....

so she angry, not talk with me within 1 week.
Mr_Wiggles
  Male
***
PM me for my password. ^^
Rep: +14/-21
Level 25 (91%)
View Profile
« Reply #5 on: February 10, 2010, 10:52:03 PM »
IP Logged

Game_Map


# 76      @events = Game_Event.new(@map_id, @map.events)

Outbreak: First Blood

Zombie Shooter, RMXP

Progress: [=                    ]  5%
Demo:     [==                  ] 11%
ngoaho
  Male
**
Rep: +1/-2
Level 17 (10%)
Real-time RPG is great
View Profile WWW
« Reply #6 on: February 13, 2010, 11:43:44 PM »
IP Logged

replace
Code:
class Game_Event
attr_reader :name
def initialize
@name = @event.name
end
end
with
Code:
class Game_Event
attr_reader :name
alias old_init initialize
def initialize(*arg)
old_init(*arg)
@name = @event.name
end
end

*hug hug hug*

- play audition with me.
- oh, i'm playing jx now.
- leave it, play audition with me.
- ok ok, audition...i'm gonna download now, oh my god, over 2Gb.
- what?
- my hdd is not enough.
- so, why jx is ok.
- oh, jx is ~1Gb, it's enough.
- hmm, you don't want to play with me?
- oh, i want, but it not possible.
- huh, you think your computer is more important than me....

so she angry, not talk with me within 1 week.
Mr_Wiggles
  Male
***
PM me for my password. ^^
Rep: +14/-21
Level 25 (91%)
View Profile
« Reply #7 on: February 14, 2010, 12:13:19 AM »
IP Logged

Cool, for some suggestions on an update, is that  there is some way some way of making the name of the event (the one that shows over top of it) where it has to be in Quotes or some thing along that lines, so you can turn it off for certain events.

Because (unless i don't know about it) right now it will show what you have the event labeled as, so if you have some events that are hidden (transfer players, Auto runs, and such) when you lablbe them for organization, it will show your label as the events name.

Outbreak: First Blood

Zombie Shooter, RMXP

Progress: [=                    ]  5%
Demo:     [==                  ] 11%
ngoaho
  Male
**
Rep: +1/-2
Level 17 (10%)
Real-time RPG is great
View Profile WWW
« Reply #8 on: February 20, 2010, 08:39:24 AM »
IP Logged

my english is bad, i don't understand your reply clearly.
if you want to turn off event name, leave blank name box.

- play audition with me.
- oh, i'm playing jx now.
- leave it, play audition with me.
- ok ok, audition...i'm gonna download now, oh my god, over 2Gb.
- what?
- my hdd is not enough.
- so, why jx is ok.
- oh, jx is ~1Gb, it's enough.
- hmm, you don't want to play with me?
- oh, i want, but it not possible.
- huh, you think your computer is more important than me....

so she angry, not talk with me within 1 week.
Pages: [1]
Jump to:  

hi