PDA

View Full Version : Name Box Module [RGSS Script/RMXP]


Peekimon
May 31st, 2005, 09:53 AM
Name Box Module [RGSS Script/RMXP]

Okee dokee, here' my first actual RGSS Tutorial ^^

- What is a Name Box?
o.o A name box is usually a box or a graphic which would show a person's Name.

- What does this script do?
It creates a simple name box to insert character's name in ^^
Or, you oculd use it to identify the box, if it's a Sign, you show "Sign"

First of all, replace your Main with this piece of code:
#==============================================================================
# ¦ Main
#------------------------------------------------------------------------------
# ??????????????????????????????
#==============================================================================

begin
# Change the $fontface variable to change the font style
$fontface = $fonttype = $fontname = $defaultfonttype = $defaultfontface = "Trebuchet MS"
# Change the $fontsize variable to change the font size
$fontsize = $defaultfontsize = 24
Graphics.freeze
$scene = Scene_Title.new
while $scene != nil
$scene.main
end
Graphics.transition(20)
rescue Errno::ENOENT
filename = $!.message.sub("No such file or directory - ", "")
print("File #{filename} was not found.")
end

That would make no font errors appear, oh, and you could change "Trebuchet MS" and "24" to your desired font faces/sizes

Now, onto the actual code ^^
1 - Go to Your Script Editor
2 - Right Click on the Script List
3 - Click on Insert
4 - Insert the below Script

#========================================
# ¦ Module MSG
#------------------------------------------------------------------------------
# This module allows you to create name boxes.
# This would be good for a harvest Moon Game
# This works for custom names, and actors.
# By Peekimon
#
# # INSTRUCTIONS #
# Name Box [Custom Names]
# Simply call this in a Call Script : MSG.name("NAME")
#
# Name Box [Actor Names]
# Simply call this in a Call Script : MSG.nameActor(Actor ID)
#
# Disposing the whole Box:
# Call Script : MSG.remove
#========================================

module MSG
#--------------------------------------------------------------------------
# o Properties of the Name Box
#--------------------------------------------------------------------------
# o X Coordinate of the Name Box
$Window_X = 0
# o Y Coordinate of the Name Box
$Window_Y = 0
# o Height of the Name Box
$Window_H = 100
# o Width of the Name Box
$Window_W = 100
# o Opacity of the Name Box
$Window_Opacity = 160
# o Font Type of the Name Box
$Window_Font = "Arial"
# o Font Size of the Name Box
$Window_Size= 34
# o Font Color of the Name Box
$BoxColor = Color.new(0,0,0,255)
# No Further Editing required
#--------------------------------------------------------------------------
# o Define Custom Names Box
#--------------------------------------------------------------------------
def self.name(n)
$NameWind = true
@Name = Window_Base.new($Window_X,$Window_Y,$Window_W,$Window_H)
@Name.contents = Bitmap.new(@Name.width - 32, @Name.height - 32)
@Name.opacity = $Window_Opacity
@Name.contents.font.name = $Window_Font
@Name.contents.font.size = $Window_Size
@Name.contents.font.color = $BoxColor
@Name.contents.draw_text(0, 0, 1000, 32, n)
end

#--------------------------------------------------------------------------
# o Defines Actor Names Box
#--------------------------------------------------------------------------
def self.nameActor(nA)
$ActorWind = true
@NameActor = Window_Base.new($Window_X,$Window_Y,$Window_W,$Window_H)
@NameActor.contents = Bitmap.new(@NameActor.width - 32, @NameActor.height - 32)
@NameActor.opacity = $Window_Opacity
@NameActor.contents.font.name = $Window_Font
@NameActor.contents.font.size = $Window_Size
@NameActor.contents.font.color = $BoxColor
actor = $game_party.actors[nA]
@NameActor.contents.draw_text(0, 0, 1000, 32, actor.name)
end

#--------------------------------------------------------------------------
# o Remove Definition
#--------------------------------------------------------------------------
def self.remove
if $NameWind == true
@Name.dispose
end

if $ActorWind == true
@NameActor.dispose
end
end
end

As instructed, in a Call Script to make a name box, you type in "MSG.name("NAME")", and to dispose the name box, just, in another call script "MSG.remove"

*UPDATE*
Added Actor Calling Definiton :)
Now, you can call actor's names :)

Use this syntax: MSG.nameActor(Actor ID)

0 = First Actor
1 = Second
2 = third
and, so on.

No errors were found. If there are any sorts of errors, do please post.

Here are some screenies ^_^
>. In action
http://img.photobucket.com/albums/v677/peekimon_gall/name_module_screenie2.gif
>. Basic Insertion Code
http://img.photobucket.com/albums/v677/peekimon_gall/name_module_screenie1.gif
And, enjoy ;)

Mooshykris
June 3rd, 2005, 12:21 AM
Why do I get an error that says failed to create bitmap?

Edit: It's this line: @name.contents = Bitmap.new(@name.width - 32, @name.height - 32)

BlackCharizard
June 3rd, 2005, 12:43 AM
WEait is this code supposed to let a player type in his own characters name?

Kyle_Katarn
June 3rd, 2005, 04:13 AM
darn this ruby coding looks hard to figure out :confused: I'll just stick with 2003 :P lol

Blizzy
June 3rd, 2005, 04:34 PM
this is quite cool, but why a module ?
just do the following in a call script

@text_window = Window_Help.new
@text_window.x = 0
@text_window.y = 0
@text_window.width = 124
@text_window.height = 32
@text_window.set_text("Peeki")

then

<>message: "I PWN, :P"

and then after the message:
call script:

@text_window.dispose

very easy :knockedou

darn this ruby coding looks hard to figure out :confused: I'll just stick with 2003 :P lol
i know it's hard to understand the code,
but if you try to understand the basics, you'll be able to script in no-time

Peekimon
June 3rd, 2005, 04:39 PM
Why do I get an error that says failed to create bitmap?


Hm... I'll check it out.

this is quite cool, but why a module ?
Okee. Some people are sometimes... too lazy to do all that, or either, they don't know RGSS. All they have to do is enter the code. In a Call Script 'MSG.name("Peeki")'
That it, easy :)

WEait is this code supposed to let a player type in his own characters name?

No, this makes a name box to help identify the person, like, in Harvest Moon :)

Mooshykris
June 3rd, 2005, 04:42 PM
No, this makes a name box to help identify the person, like, in Harvest Moon :)

Will it work with the custom hero name code ( n[0001] or something )

Peekimon
June 3rd, 2005, 04:56 PM
Will it work with the custom hero name code ( n[0001] or something )
... Hm... I'm gonna tweak the code a bit. I'll see if I can make it that :)

For now, it couldn't.

Blizzy
June 3rd, 2005, 08:36 PM
i got my module ready,
you can do the following with it:

1. make a window (x, y, width, height, opacity)
2. draw text (x, y, width, height)
3. draw actor name (x, y, width, height)
4. draw a variable (x, y, width, height, var_id)

i'll create a new topic for this,
since it's quite different then peeki's