LOGIN
SEARCH
PROFILE
keys: ↑ ↓
LOGOUT
INDEX
MEMBERS
keys: ↑ ↓
HOME
PORTAL
PLAY ALONG
PLAY with WORDS
PLAY with GRAPHICS
PLAY with SOUNDS
PLAY with CODES
PLAY with PROJECTS
keys: ← →
Guest Access
Register:
Members:



Go to page : 1, 2, 3  Next

View previous topic View next topic Go down Message [Page 1 of 3]

Administrator
Administrator
#1 RGSS = Scripting Basics - Window Class Empty RGSS = Scripting Basics - Window Class
Loading

G@MeF@Ce

G@MeF@Ce
Administrator
Administrator
Administrator
profile
Here you will learn to create a basic window with
a simple text message to be displayed.

Each line of code will be commented to explain it's purpose.

Start by copy and paste this script into the RMXP script data base (F11)

Code:
class My_First_Window < Window_Base #1
  def initialize #2
    super(0, 0, 350, 150) #3
    self.contents = Bitmap.new (width - 32, height - 32) #4
    #this shows what is in the window with a 32pixel margin#5
    refresh # run the variable named "refresh"#6
  end # end the initialization process#7
  def refresh #8 define what refresh does
    self.contents.clear #9 clear content of the variable Bitmap
    self.contents.draw_text(0, 0, 300, 32,"This is my first window")#10
  end #11 end the refresh process
end #12end the window class

Now let's take a look at each line of code...

#1 = class sub-window under the Window Base class.

Code:
class My_First_Window < Window_Base

#2 = define start process
Code:
def initialize

#3 = instruct window size and location
Code:
super(0, 0, 350, 150)

"super" calls the Class to start
(arguments) = from left to right

0= x window position
0 = y window position
350= x window width
150 = y window height

#4 = like the body to a web page, this creates the viewable content inside the window with a 32 pixel margin or inner frame
Code:
self.contents = Bitmap.new (width - 32, height - 32)

#5 = is just a comment line beginning with a #
Code:
#this shows what is in the window with a 32pixel margin#5
*in case you missed the first lesson...
RGSS+RMXP Comments

#6 = this calls the method named refresh which is defined later in the script
Code:
refresh # run the variable named "refresh"#6

#7 = end method
just like HTML tags in where you have to start and end a link, or div,
RGSS is pretty much the same in regards to starting a class, def (method) to 'if statements.

Code:
  end #to close/end the defined method 'initialize'#7

*note, when running a script, the system looks for the 'initialize' method first if not then 'main'
or it will crash*

#8 = just like defining the initialize method, this will define a method call 'refresh'
*remember we are calling this method 0n line #6 which is called inside the initialize method ~ still with me?
Code:
  def refresh #8 define what refresh does

#9 = this basically clears the window's contents so that there is a clean slate every time you call your window
Code:
 self.contents.clear #9 clear content of the variable Bitmap

#10 = now this writes the test message on the clean slate
Code:
 self.contents.draw_text(0, 0, 300, 32,"This is my first window")#10

self.(this window)contents.(what's inside)draw_text(0,0,300,32,"YOUR TEXT")

(arguments) = from left to right
0= text horizontal position
0= text vertical position
300 = width of text field
32 = height of text field
"YOUR TEXT" = keep in between " "

11 = close the defined method named refresh
Code:
 end #11 end/close the refresh process

12 = close the defined class named
My First Window - which is being used under the Window_Base class.
Code:
end #12end the window class


Now to display this window you may use an event with the following call script in the list of event commands
(RMXP - third tab, bottom right option)

Code:
My_First_Window.new

your window will look just like this!

Spoiler:

simple but not easy...
the level of difficulty will increase as we continue our adventures in RGSS for RMXP

*remember I'm only sharing what I'm learning = 101
Administrator
Show Signature
Administrator
https://www.dropbox.com/sh/i47rig99qhrvn8s/4m5HvsM2fD http://g4m3f4c3.deviantart.com https://www.facebook.com//pages/Gameface101/332331300127008 https://twitter.com//mr_gameface101 https://soundcloud.com/schurr https://www.youtube.com/user/MrGameface101?feature=watch
Active Member
Active Member
#2 RGSS = Scripting Basics - Window Class Empty Re: RGSS = Scripting Basics - Window Class
Loading

Legault123

Legault123
Active Member
Active Member
Active Member
profile
thank you so much for de classes! They are just like you said, simple but not easy. It takes time, I think I'm doing just fine, I need to make a list of these 'things' -don't know the name :$ - like:

super : call the class to start

Like a dictionary with all that stuff. I'll keep studying and post what I dont understand here (:
Active Member
Show Signature
Active Member
||||||||||
||||||||||
#3 RGSS = Scripting Basics - Window Class Empty Re: RGSS = Scripting Basics - Window Class
Loading

supercow

supercow
||||||||||
||||||||||
profile
@gameface could it be the enemy mini hud script got bug (where sometimes doesnt show its hud) because of the refresh problem? or not enough of it?
if used too many refresh would it make a script more lag? silent
whats the diff bettwen refresh and update? Neutral
sorry for the random question Embarassed
||||||||||
Show Signature
||||||||||
Administrator
Administrator
#4 RGSS = Scripting Basics - Window Class Empty Re: RGSS = Scripting Basics - Window Class
Loading

G@MeF@Ce

G@MeF@Ce
Administrator
Administrator
Administrator
profile
supercow wrote:@gameface could it be the enemy mini hud script got bug (where sometimes doesnt show its hud) because of the refresh problem? or not enough of it?
if used too many refresh would it make a script more lag? silent

@supercow - I'll address the issue with the e-mini HUD on that topic (there's a bug with the 'for loop' method I believe, hope to have it worked out soon)
and yes, to refresh/update more than needed can definitely cause lag.

supercow wrote:
whats the diff bettwen refresh and update? Neutral
sorry for the random question Embarassed
this is on topic with making windows Cool
To answer your question about refresh and update, these are methods used to do exactly that, "update" if coordinates change such as position, new HP, etc...
and "refresh" to clear and rewrite/redraw graphics/text.


Legault123 wrote:
I need to make a list of these 'things' -don't know the name :$ - like:

super : call the class to start

@Legault123-there's different types of variables
some with @ or $ or constants which are in ALL_CAPS.

these set values and label methods that can be called from various places in the script itself or throughout the script database.

A Class is like a block of code that you can access to use what is needed. Super will call the Window_Base Class that's being used. So instead of writing everything needed to make a window, you call the class that makes windows and make the needed window through setting the arguments.

Maybe I will make a 101 on variables and arguments as it helped me a lot when I started out learning RGSS.

*Warning - the more you learn about scripting, the more you will need to learn about scripting.

if anything, RMXP > Help > F1 Contents |
look up classes / methods / variables.

Hope this helps guys...


Administrator
Show Signature
Administrator
https://www.dropbox.com/sh/i47rig99qhrvn8s/4m5HvsM2fD http://g4m3f4c3.deviantart.com https://www.facebook.com//pages/Gameface101/332331300127008 https://twitter.com//mr_gameface101 https://soundcloud.com/schurr https://www.youtube.com/user/MrGameface101?feature=watch
Active Member
Active Member
#5 RGSS = Scripting Basics - Window Class Empty Re: RGSS = Scripting Basics - Window Class
Loading

Legault123

Legault123
Active Member
Active Member
Active Member
profile
ok ok I'm getting it, but as you said, the more I learn the more questions I have.I've been searching on the net and found some very good starter tutorials for scripting but they are on spanish, maybe I can translate them and write them here for every newbie like me, what do you think ?

Waiting for a new class Very Happy
Active Member
Show Signature
Active Member
Administrator
Administrator
#6 RGSS = Scripting Basics - Window Class Empty Re: RGSS = Scripting Basics - Window Class
Loading

G@MeF@Ce

G@MeF@Ce
Administrator
Administrator
Administrator
profile
@Legault - you did say that you would help me with Spanish ^,^

that would be great! we need more tutorials in the creative support center ~ it's so brand new.

I'm excited to see where scripting will take you,
I recall mr_wiggles starting off with event systems, now take a look at him with all his awesome scripts.
Administrator
Show Signature
Administrator
https://www.dropbox.com/sh/i47rig99qhrvn8s/4m5HvsM2fD http://g4m3f4c3.deviantart.com https://www.facebook.com//pages/Gameface101/332331300127008 https://twitter.com//mr_gameface101 https://soundcloud.com/schurr https://www.youtube.com/user/MrGameface101?feature=watch
Active Member
Active Member
#7 RGSS = Scripting Basics - Window Class Empty Re: RGSS = Scripting Basics - Window Class
Loading

Legault123

Legault123
Active Member
Active Member
Active Member
profile
yeah I'll help with spanish, it's great with girls.. I've been told 8-) hahaha just ask and I answer ;D

I start working on translating the tutorials if the guy who made them allows me and post them here on a new topic.

mr wiggles must be an example to everyone haha, you know he still has the name "Eventalist" while the only thing that I see from him are awesome scripts! I got a lot to learn.. let's see what happens (:
Active Member
Show Signature
Active Member
EVENTALIST
EVENTALIST
#8 RGSS = Scripting Basics - Window Class Empty Re: RGSS = Scripting Basics - Window Class
Loading

mr_wiggles

mr_wiggles
EVENTALIST
 EVENTALIST
EVENTALIST
profile
Yea takes time to learn, but there are a lot of useful sites out there and helpful people. Events helped me understand for the most part.

(All events are scripts, the commands get converted trough the Interpreter class)

Working with events help you project the outcome to what you created, which is very useful because writing scripts from scratch is hard trying to get it to make it do what you want it to.

(What helps me is creating the features first then making them work.)
EVENTALIST
Show Signature
EVENTALIST
Active Member
Active Member
#9 RGSS = Scripting Basics - Window Class Empty Re: RGSS = Scripting Basics - Window Class
Loading

Legault123

Legault123
Active Member
Active Member
Active Member
profile
When I have enough time, I'll start translating from spanish to english, some scripting classes I've seen. Maybe in the process I learn something.

In the meantime, can you name the webs you used to visit to learn? Thank you!
Active Member
Show Signature
Active Member
EVENTALIST
EVENTALIST
#10 RGSS = Scripting Basics - Window Class Empty Re: RGSS = Scripting Basics - Window Class
Loading

mr_wiggles

mr_wiggles
EVENTALIST
 EVENTALIST
EVENTALIST
profile
this one mostly

http://www.ruby-doc.org/docs/ProgrammingRuby/

helps A LOT.
EVENTALIST
Show Signature
EVENTALIST

Sponsored content

profile

View previous topic View next topic Back to top Message [Page 1 of 3]

Go to page : 1, 2, 3  Next

 

Chatbox system disabled
Personal messaging disabled