PDA

View Full Version : Window Module, create your own simple windows!


Blizzy
June 3rd, 2005, 09:03 PM
i made this script so people can easy create windows
and don't need to create any script.
all you need is the call script function to create a simple window.

functions that are done:
- create window
- draw text
- draw variable
- draw actor name
* if anybody has other ideas, please post them,
so i can add it in the module.

first of all.
insert a new script above all,
and put the following script in it:

# ============================================================
# ● Module Win - for creating your own windows in rgss
# ------------------------------------------------------------------------------------------------------------
# ● Credits: Virtual (creator) + Peekimon (thinker)
# ============================================================
module Win

#initialize the window
def self.initialize(x, y, w, h, opacity, back_opacity)
@window = Window_Base.new(x,y,w,h)
@window.contents = Bitmap.new(@window.width - 32, @window.height - 32)
@window.opacity = opacity
@window.back_opacity = back_opacity
end #method

#draw text
def self.text(x, y, w, h, text, i)
@window.contents.font.name = "Arial"
@window.contents.font.size = 24
@window.contents.draw_text(x, y, w, h, text, 0)
end #method

#draw a single variable
def self.variable(x,y,w,h,i)
@window.contents.draw_text(x, y, w, h, "Variable " + i.to_s + " = " + $game_variables[i].to_s, 0)
end #method

#draw the name of the actor
def self.actorname(x,y,w,h,i)
if $game_party.actors[i] != nil
@window.contents.draw_text(x, y, w, h, $game_party.actors[i].name, 0)
else
print "actor " + i.to_s + " doesn't excist"
end #if statement
end #method

#close the window
def self.close
@window.dispose
end #method

end #module

if you have this done,
open the call script function in the events commands.

1. to create the window, use the following:

Win.initialize(x, y, width, height, opacity, back_opacity)

for example:

Win.initialize(80, 80, 200, 180, 220, 200)

this sets the x at 80, the y at 80, width at 200, and the height at 180.
opacity is set to 220 and the back opacity is 200.

to draw text, use:

Win.text(x, y, width, height, Text, i)

example:

Win.text(4, 0, 120, 32, "Text", 1)

the x = 4, y = 0, width = 120, height = 32, text must be between " "
and the i = 1. i is the number of the message.
if you use:

Win.text(4, 0, 120, 32, "Text", 1)
Win.text(4, 20, 120, 32, "Text2", 1)

"text2" will show up, because it overwrite the first one.
to do this, use numbers, like the following:

Win.text(4, 0, 120, 32, "Text1", 1)
Win.text(4, 20, 120, 32, "Text2", 2)
Win.text(4, 40, 120, 32, "Text3", 3)
etc.


to draw a variable, use:

Win.variable(x, y, width, height, variable_id)

example:

Win.variable(4, 20, 200, 32, 1)

this will draw:
Variable 1 = value

to draw the name of the hero:

Win.actorname(x, y, width, height, actor_id)

example:

Win.actorname(4, 0, 120, 32, 0)

this will draw the name of the actor with the id 0
which is the first actor.
hero 1 = actor 0
hero 2 = actor 1
hero 3 = actor 2
etc.

screenshot is in the attachement

this is it for now.
i hope this helps a lot of people

Illusion
June 3rd, 2005, 09:34 PM
I think it will help a lot of people, and it helped me a bit! When I looked at the code and discovered the def named self.actorname etc.. I never knew about it.
Pokemaster_shiny ;)

Blizzy
June 4th, 2005, 08:42 AM
I think it will help a lot of people, and it helped me a bit! When I looked at the code and discovered the def named self.actorname etc.. I never knew about it.
Pokemaster_shiny ;)
i got the self.keyword from peekimon,
so that's why he is in the credits.