collapse collapse

 Community


 User Info




Willkommen Gast. Bitte einloggen oder registrieren.

 Partnerseiten

rpgvx.net

Das Forum ist offline

Autor Thema: + [ Character's Textbox ] + Version 1.0  (Gelesen 5303 mal)

woratana

  • Gast
+ [ Character's Textbox ] + Version 1.0
« am: Mai 22, 2008, 02:33:15 »
Character's Textbox
Version 1.0
by Woratana
Release Date: 21/05/2008


Introduction
This script will create the text box for each character (Player and events).

You can set and remove text for each character by call script.
You can also set SE for textbox, and change textbox properties (Position / Opacity / Windowskin).


Features
Version 1.0
- Show Textbox above character (Player and/or Event)
- Change textbox's opacity and position (in script)
- Choose to use sound effect when show textbox (in script)


Screenshots



Script
Place it above main

[div class=\'codetop\']CODE[div class=\'codemain\' style=\'height:200px;white-space:pre;overflow:auto\']#===============================================================
# ? [VX] ? Character's Textbox ? ?
# * Show textbox above character *
#--------------------------------------------------------------
# ? by Woratana [woratana@hotmail.com]
# ? Thaiware RPG Maker Community
# ? Released on: 21/05/2008
# ? Version: 1.0
#--------------------------------------------------------------

#==================================================================
# ** FEATURES **
#-----------------------------------------------------------------
# - Show Textbox above character (Player and/or Event)
# - Change textbox's opacity and position (in script)
# - Choose to use sound effect when show textbox (in script)

#==================================================================
# ** HOW TO USE **
# * use event command 'Script...' for the any script line below~
#-----------------------------------------------------------------
# 1. Setup this script in SETUP part below
# 2. To set text to character's textbox, call script:
#   set_text(character, new_text)
#
# * character: What character you want to set this text?
# ** -1 for 'Player', 0 for 'This Event', and 1 or more for Event ID
# * new_text: What is the text you want to show?
# ** write text in 'text here' or "text here"

# For example:
#   set_text(10,'Hello!')
# * Script above will show text 'Hello!' over event ID 10.
#
# 3. To clear textbox, call script:
#   set_text(character, '')
#==================================================================

module Wora_CTB
  #================================================================
  # ** [START] Character's Overhead Textbox SETUP
  #----------------------------------------------------------------
  SAVE_TEXT = true # Save text in textbox~? (true or false)
  # If save, old text will show when you teleport back to that map~
  
  TEXTBOX_SKIN = 'Window' # Textbox windowskin file name, from folder 'System'
  TEXTBOX_OPACITY = 0 # Textbox Opacity (0 - 255)
  TEXTBOX_X_OFFSET = 0 # Move textbox horizontally (+ or -)
  TEXTBOX_Y_OFFSET = -1 # Move textbox vertically (+ or -)
  
  TEXTBOX_POPSOUND_MODE = 2 # SE (Sound Effect) to play when the textbox appear,
  # or change text~
  # 0 for no sound, 1 for use sound when textbox first appear,
  # & 2 for use sound when textbox first appear and change text
  
  TEXTBOX_POPSOUND = 'Decision1' # SE file name
  TEXTBOX_POPSOUND_VOLUME = 80 # SE volume
  TEXTBOX_POPSOUND_PITCH = 100 # SE pitch
  #----------------------------------------------------------------
  # ** [END] Character's Overhead Textbox SETUP
  #================================================================
end

$worale = {} if $worale.nil?
$worale['Chartbox'] = true

class Game_Interpreter
  def set_text(evid, new_text)
    target = get_character(evid)
    target.text = new_text
  end
end

class Sprite_Character < Sprite_Base
  alias wora_chartbox_sprcha_upd update
  alias wora_chartbox_sprcha_dis dispose
  
  def update
    wora_chartbox_sprcha_upd
    @chartext = '' if @chartext.nil?
    if @character.text != @chartext # If there is new text
      @chartext = @character.text
      $game_system.chartbox = {} if $game_system.chartbox.nil?
      case @character.class
      when Game_Player; char_id = -1
      when Game_Event; char_id = @character.id
      end
      # Save new text
      $game_system.chartbox[[$game_map.map_id, char_id]] = @chartext
      if @chartext == '' # If new text is empty? ('')
        @textbox.visible = false if !@textbox.nil?
      else # If new text is not empty~ change text
        if @textbox.nil?
          @textbox = Window_CharTBox.new
          RPG::SE.new(Wora_CTB::TEXTBOX_POPSOUND, Wora_CTB::TEXTBOX_POPSOUND_VOLUME,
Wora_CTB::TEXTBOX_POPSOUND_PITCH).play if Wora_CTB::TEXTBOX_POPSOUND_MODE > 0
        else
          RPG::SE.new(Wora_CTB::TEXTBOX_POPSOUND, Wora_CTB::TEXTBOX_POPSOUND_VOLUME,
  Wora_CTB::TEXTBOX_POPSOUND_PITCH).play if Wora_CTB::TEXTBOX_POPSOUND_MODE == 2
        end
        @textbox.set_text(@chartext)
        @textbox.visible = true
      end
    end
    if @chartext != ''
      @textbox.x = self.x - (@textbox.width / 2) + Wora_CTB::TEXTBOX_X_OFFSET
      @textbox.y = self.y - self.oy - @textbox.height + Wora_CTB::TEXTBOX_Y_OFFSET
    end
  end
  
  def dispose
    @textbox.dispose if !@textbox.nil?
    wora_chartbox_sprcha_dis
  end
end

class Game_Character
  attr_accessor :text
  alias wora_chartbox_gamcha_ini initialize
  def initialize(*args)
    wora_chartbox_gamcha_ini(*args)
    $game_system.chartbox = {} if $game_system.chartbox.nil?
    case self.class
    when Game_Player
      my_text = $game_system.chartbox[[$game_map.map_id, -1]] if
!$game_system.chartbox[[$game_map.map_id, -1]].nil?
    when Game_Event
      my_text = $game_system.chartbox[[$game_map.map_id, @id]] if
!$game_system.chartbox[[$game_map.map_id, @id]].nil?
    end
    @text = my_text.nil? ? '' : my_text
  end
end

class Game_System
  attr_accessor :chartbox
end

unless Wora_CTB::SAVE_TEXT
  class Game_Interpreter
    alias wora_chartbox_gamint_com201 command_201 unless $@
    def command_201
      if $game_map.fog_reset
        if @params[0] == 0; id_map = @params[1]
        else; id_map = $game_variables[@params[1]]
        end
        $game_system.chartbox = {} if id_map != @map_id
      end
      wora_chartbox_gamint_com201
    end
  end
end
#===============================================================
# Window_CharTBox: Edited version of Window_Help
#===============================================================
class Window_CharTBox < Window_Base
  def initialize(x = 0, y = 0, w = 66, h = WLH+32)
    super(x,y,w,h)
    self.windowskin = Cache.system(Wora_CTB::TEXTBOX_SKIN)
    self.opacity = Wora_CTB::TEXTBOX_OPACITY
  end

  def set_text(text)
    if text != @text
      text_w = self.contents.text_size(text).width
      self.width = text_w + 32
      create_contents
      self.contents.font.color = normal_color
      self.contents.draw_text(0, 0, self.contents.width, WLH, text, 1)
      @text = text
    end
  end
end
#==================================================================
# [END] VX Character Textbox by Woratana [woratana@hotmail.com]
#==================================================================


Instruction
- Setup script in the SETUP part

- There is instruction in the script :)
1. Setup this script in SETUP part below

2. To set text to character's textbox, call script:
   set_text(character, new_text)
* character: What character you want to set this text?
** -1 for 'Player', 0 for 'This Event', and 1 or more for Event ID
* new_text: What is the text you want to show?
** write text in 'text here' or "text here"

For example:
   set_text(10,'Hello!')* Script above will show text 'Hello!' over event ID 10.

3. To clear textbox, call script:
   set_text(character, '')

Author's Notes
Free for use in your work if credit is included.

Please do not redistribute this script without permission. If you want to post it on any forum, please link to this topic.


Bug Report?
Please give me these informations:
Zitat
- What is it says in error window?
- When is it get error? (Right after run game, when you choose something, etc.)
- What have you changed in setting part?
- Do you have any other scripts running in your game that may crash with this script?

+ [ Character's Textbox ] + Version 1.0

Offline Hanmac

  • true = false
  • Database-Verunstalter
  • **
  • Beiträge: 138
+ [ Character's Textbox ] + Version 1.0
« Antwort #1 am: Mai 22, 2008, 06:55:58 »
make a demo...


PS: i think it must be an error if you oben the menu.



PPS: can i modify this?
i will include range and outher spezific things for my npc scripts
"alles ist wahr, wenn wahr einen bestimmten Wert annimmt."

+ [ Character's Textbox ] + Version 1.0

woratana

  • Gast
+ [ Character's Textbox ] + Version 1.0
« Antwort #2 am: Mai 22, 2008, 07:04:53 »
@Hanmac:
I think this script is pretty simple to use. :P

Why do you think it will error if open the menu? Have you tried it?
And what is the error say? That will help me a lot to fix bug. :)

Feels free to modify any of my script :)
I don't mind if the credit is included~

+ [ Character's Textbox ] + Version 1.0

Offline Hanmac

  • true = false
  • Database-Verunstalter
  • **
  • Beiträge: 138
+ [ Character's Textbox ] + Version 1.0
« Antwort #3 am: Mai 22, 2008, 09:09:56 »
no i dont test. (1. i have no demo. 2. no time)
but i think if you open the menu, the windows are visible
"alles ist wahr, wenn wahr einen bestimmten Wert annimmt."

+ [ Character's Textbox ] + Version 1.0

woratana

  • Gast
+ [ Character's Textbox ] + Version 1.0
« Antwort #4 am: Mai 22, 2008, 09:53:54 »
It will, because Scene_Map will take map's picture before dispose Spriteset_Map.

But the windows are actually already disposed. :)

+ [ Character's Textbox ] + Version 1.0

chaosBlender

  • Gast
+ [ Character's Textbox ] + Version 1.0
« Antwort #5 am: Mai 22, 2008, 10:14:26 »
Very nice script, I think I may be going to use it.
Would you mind if I modify it, so you don't need the event id, but so you also can use the events name?
EDIT: Nah, forget it, that doesn't seem to work (I thought I remembered a function to get the event's id based on it's name, but I think I've got something wrong there) XD

@hanmac: Funktioniert übrigens einwandfrei.
« Letzte Änderung: Mai 22, 2008, 10:27:00 von chaosBlender »

+ [ Character's Textbox ] + Version 1.0

woratana

  • Gast
+ [ Character's Textbox ] + Version 1.0
« Antwort #6 am: Mai 22, 2008, 10:25:43 »
Yeah, go for it. :)
As I said to Hanmac that
Zitat
Feels free to modify any of my script :)
I don't mind if the credit is included~
:lol:

+ [ Character's Textbox ] + Version 1.0

chaosBlender

  • Gast
+ [ Character's Textbox ] + Version 1.0
« Antwort #7 am: Mai 22, 2008, 11:12:18 »
Oh, forget my edit. Got it to work ^^

Change:

class Game_Interpreter
  def set_text(evid, new_text)
    target = get_character(evid)
    target.text = new_text
  end
end


Into:

class Game_Map
  def setup_events
    @events = {}          # Map event
    @event_name = {}
    for i in @map.events.keys
      @events[i] = Game_Event.new(@map_id, @map.events[i])
      @event_name[i] = @map.events[i].name
    end
    @common_events = {}   # Common event
    for i in 1...$data_common_events.size
      @common_events[i] = Game_CommonEvent.new(i)
    end
  end
  
   def get_id_from_name(name)
    @evid = @event_name.index(name)
    return @evid
  end
end
  
class Game_Interpreter
  def set_text(evid, new_text)
    target = get_character($game_map.get_id_from_name(evid))
    target.text = new_text
  end
end

Now, instead of using the event id, you can use the events' name.
Deutsch: Jetzt kann man statt der Event ID auch den Eventnamen benutzen ^^ (Is vielleicht einfach einfacher, wenn man das ganze mit nem zentralen Event steuert und net ständig für alles die ID rausfinden will ^^)

+ [ Character's Textbox ] + Version 1.0

Dainreth

  • Gast
+ [ Character's Textbox ] + Version 1.0
« Antwort #8 am: Mai 22, 2008, 12:51:37 »
Hey wora, I like this one, it's great!

+ [ Character's Textbox ] + Version 1.0

Offline Onkel Hell

  • Sol Invictus
  • Administrator
  • VX-Kenner
  • ****
  • Beiträge: 562
  • You can't shoot me, I'm AIDS !
+ [ Character's Textbox ] + Version 1.0
« Antwort #9 am: Juni 13, 2008, 03:08:39 »
its realy nice
i use this in cooperation with an edit of my mapmarker to show the names of npcs when you are near to them, realy good when you seek a specific enemy
Verborgen in der Dunkelheit
Ich kenne nur die Einsamkeit
Auf das kein Gott mich sieht, ich bin ein Eremit


Mega Man Battle Engine


+ [ Character's Textbox ] + Version 1.0

Offline Hanmac

  • true = false
  • Database-Verunstalter
  • **
  • Beiträge: 138
+ [ Character's Textbox ] + Version 1.0
« Antwort #10 am: Juni 13, 2008, 09:07:47 »
i have mod this to a verion that schows only name from npcs that are in range.
the bad this is that you need more scripts:
-NPC
-EOS (event-object-system)
-and a mod of this)
"alles ist wahr, wenn wahr einen bestimmten Wert annimmt."

+ [ Character's Textbox ] + Version 1.0

Dainreth

  • Gast
+ [ Character's Textbox ] + Version 1.0
« Antwort #11 am: Juni 13, 2008, 15:09:40 »
@Hanmac
Sounds interesting and seems to work? So, why you're not posting it so we can test it..

Re: + [ Character's Textbox ] + Version 1.0

Offline Deses

  • Database-Verunstalter
  • **
  • Beiträge: 105
    • Ulugar - Developers Blog
Re: + [ Character's Textbox ] + Version 1.0
« Antwort #12 am: September 25, 2008, 12:49:08 »
i use the script and it's very nice but can you make "press action button" to delete the textbox?
deutsch (im falle es jemand besser übersetzen kann^^ ) : Kannst du vielleich einen "PRess Button" einbauen um die Nachricht verschwiendne zu lassen anstatt set_text(charakter ,"")?

Re: + [ Character's Textbox ] + Version 1.0

Offline Ceta

  • Irgendwie da, irgendwie auch nicht
  • Eventmeister
  • ***
  • Beiträge: 365
  • ehemals Elements
Re: + [ Character's Textbox ] + Version 1.0
« Antwort #13 am: Dezember 17, 2008, 18:09:45 »
Hey wora!^^

I'm very interested in this Script, but may I ask you a question?

Is it possible to show Facesets near this Textboxes, like it was in Golden Sun?

It looked like this:



Is it possible?

Greetz

Elements
Zomg ele.. xD
Spoiler for Hiden:
Elements [09|Jun 07:16 ]:   Dauernd hab ich diese "xD" oder so in den Charasets-Namen xD
Domin0e [09|Jun 07:16 ]:   Zomg ele.. xD
Fi [09|Jun 07:16 ]:   bedenklich
[spo

Re: + [ Character's Textbox ] + Version 1.0

Offline Stef-san

  • Eventmeister
  • ***
  • Beiträge: 307
    • Space Live
Re: + [ Character's Textbox ] + Version 1.0
« Antwort #14 am: Dezember 31, 2008, 21:58:11 »
is it perhaps possible for a bigger chatbox? ;O

current projects
Arco Iris - A Fading World
School Days (Co-Project with Klex)

 


 Bild des Monats

rooftop party

Views: 3614
By: papilion

 Umfrage

  • Wer soll das BdM gewinnen?
  • Dot Kandidat 1
  • 3 (25%)
  • Dot Kandidat 2
  • 1 (8%)
  • Dot Kandidat 3
  • 2 (16%)
  • Dot Kandidat 4
  • 0 (0%)
  • Dot Kandidat 5
  • 6 (50%)
  • Stimmen insgesamt: 12
  • View Topic

 Schnellsuche





SimplePortal 2.3.3 © 2008-2010, SimplePortal