rgss tips : xp structures and ace structure

nio kasgami

VampCat
Veteran
Joined
May 21, 2013
Messages
8,949
Reaction score
3,042
First Language
French
Primarily Uses
RMMV
I saw a lot of people complain about rgss1 

saying this hard to read and to manipulate but be surprise

Xp structure is horrible we can't deny! 

but when you look at the code more close to the rgss 

you will notice the code are relatively simple 

so for people who want to improve their code knowledge xp is a good way for improve it

(unless Alias because alias don't exist into RGSSI they only exist in RGSSII and RGSSIII)

why?

well RGSSI is less structural so this in some way less scary 

RGSSIII is heavily structural and can be a little scary to play with 

if I show a exemple of how window command is build 

RGSSI

#==============================================================================# ** Window_Command#------------------------------------------------------------------------------# This window deals with general command choices.#==============================================================================class Window_Command < Window_Selectable #-------------------------------------------------------------------------- # * Object Initialization # width : window width # commands : command text string array #-------------------------------------------------------------------------- def initialize(width, commands) # Compute window height from command quantity super(0, 0, width, commands.size * 32 + 32) @item_max = commands.size @commands = commands self.contents = Bitmap.new(width - 32, @item_max * 32) refresh self.index = 0 end #-------------------------------------------------------------------------- # * Refresh #-------------------------------------------------------------------------- def refresh self.contents.clear for i in 0...@item_max draw_item(i, normal_color) end end #-------------------------------------------------------------------------- # * Draw Item # index : item number # color : text color #-------------------------------------------------------------------------- def draw_item(index, color) self.contents.font.color = color rect = Rect.new(4, 32 * index, self.contents.width - 8, 32) self.contents.fill_rect(rect, Color.new(0, 0, 0, 0)) self.contents.draw_text(rect, @commands[index]) end #-------------------------------------------------------------------------- # * Disable Item # index : item number #-------------------------------------------------------------------------- def disable_item(index) draw_item(index, disabled_color) endend
RGSSIII

#==============================================================================# ** Window_Command#------------------------------------------------------------------------------# This window deals with general command choices.#==============================================================================class Window_Command < Window_Selectable #-------------------------------------------------------------------------- # * Object Initialization #-------------------------------------------------------------------------- def initialize(x, y) clear_command_list make_command_list super(x, y, window_width, window_height) refresh select(0) activate end #-------------------------------------------------------------------------- # * Get Window Width #-------------------------------------------------------------------------- def window_width return 160 end #-------------------------------------------------------------------------- # * Get Window Height #-------------------------------------------------------------------------- def window_height fitting_height(visible_line_number) end #-------------------------------------------------------------------------- # * Get Number of Lines to Show #-------------------------------------------------------------------------- def visible_line_number item_max end #-------------------------------------------------------------------------- # * Get Number of Items #-------------------------------------------------------------------------- def item_max @list.size end #-------------------------------------------------------------------------- # * Clear Command List #-------------------------------------------------------------------------- def clear_command_list @list = [] end #-------------------------------------------------------------------------- # * Create Command List #-------------------------------------------------------------------------- def make_command_list end #-------------------------------------------------------------------------- # * Add Command # name : Command name # symbol : Corresponding symbol # enabled : Activation state flag # ext : Arbitrary extended data #-------------------------------------------------------------------------- def add_command(name, symbol, enabled = true, ext = nil) @list.push({:name=>name, :symbol=>symbol, :enabled=>enabled, :ext=>ext}) end #-------------------------------------------------------------------------- # * Get Command Name #-------------------------------------------------------------------------- def command_name(index) @list[index][:name] end #-------------------------------------------------------------------------- # * Get Activation State of Command #-------------------------------------------------------------------------- def command_enabled?(index) @list[index][:enabled] end #-------------------------------------------------------------------------- # * Get Command Data of Selection Item #-------------------------------------------------------------------------- def current_data index >= 0 ? @list[index] : nil end #-------------------------------------------------------------------------- # * Get Activation State of Selection Item #-------------------------------------------------------------------------- def current_item_enabled? current_data ? current_data[:enabled] : false end #-------------------------------------------------------------------------- # * Get Symbol of Selection Item #-------------------------------------------------------------------------- def current_symbol current_data ? current_data[:symbol] : nil end #-------------------------------------------------------------------------- # * Get Extended Data of Selected Item #-------------------------------------------------------------------------- def current_ext current_data ? current_data[:ext] : nil end #-------------------------------------------------------------------------- # * Move Cursor to Command with Specified Symbol #-------------------------------------------------------------------------- def select_symbol(symbol) @list.each_index {|i| select(i) if @list[:symbol] == symbol } end #-------------------------------------------------------------------------- # * Move Cursor to Command with Specified Extended Data #-------------------------------------------------------------------------- def select_ext(ext) @list.each_index {|i| select(i) if @list[:ext] == ext } end #-------------------------------------------------------------------------- # * Draw Item #-------------------------------------------------------------------------- def draw_item(index) change_color(normal_color, command_enabled?(index)) draw_text(item_rect_for_text(index), command_name(index), alignment) end #-------------------------------------------------------------------------- # * Get Alignment #-------------------------------------------------------------------------- def alignment return 0 end #-------------------------------------------------------------------------- # * Get Activation State of OK Processing #-------------------------------------------------------------------------- def ok_enabled? return true end #-------------------------------------------------------------------------- # * Call OK Handler #-------------------------------------------------------------------------- def call_ok_handler if handle?(current_symbol) call_handler(current_symbol) elsif handle?:)ok) super else activate end end #-------------------------------------------------------------------------- # * Refresh #-------------------------------------------------------------------------- def refresh clear_command_list make_command_list create_contents super endend

did you notice how much this seem simple and less scary to look? 

I don't say switch to xp for make script not at all! RGSSI have big flaw! 

I mean this just a good way for learning to tweak with rgss! 

this can be a good practice for help you to make script ! 

at least I can have false!

I just say my opinion of my though about xp I love simply the simpleness of RGSSI

and I think this a good way for practice in script making!

now Nio out~
 

nio kasgami

VampCat
Veteran
Joined
May 21, 2013
Messages
8,949
Reaction score
3,042
First Language
French
Primarily Uses
RMMV
It does exist. You can alias in RGSS1, either by alias_method or alias.
wait what!? 

all the people said this was simply impossible to alias ! 

D: people lied to me ;_;
 

TheoAllen

Self-proclaimed jack of all trades
Veteran
Joined
Mar 16, 2012
Messages
5,592
Reaction score
6,522
First Language
Indonesian
Primarily Uses
RMVXA
It's impossible to alias because if you want to add new line, you have no choice but overwrite the entire method. At least, most of the case.
 

Tsukihime

Veteran
Veteran
Joined
Jun 30, 2012
Messages
8,564
Reaction score
3,846
First Language
English
def refresh self.contents.clear for i in 0...@item_max draw_item(i, normal_color) endendWhat happens if I wanted to change the max number of items? Where do I change it?When I look at the ace code, I see that there is a method called "item_max", so I'm thinking ok I'll just change that. Sounds a bit weird, but comments seem to indicate that's what it's for.

Having lots of methods is advantageous when you're dealing with multiple scripts all trying to work with the same code. It is also good object-oriented design since every method has only one responsibility.

If you have one method that does everything, and my script just wants to change one piece of that process...well everything has to be overhauled.

It also adds a lot of overhead to your performance.

I also remember seeing code like this

class Window_Message < Window_Selectable def initialize super(80, 304, 480, 160)480 is the width.Why 480? What does that represent?

This does not lend itself very well to responsive window design.

well RGSSI is less structural so this in some way less scary
Which is true. Some people don't like object-oriented programming because of the massive amounts of overhead and syntax that it adds.

If you're writing a small, one-off program that you're writing on your own, then it probably doesn't matter, but for anything larger than a snippet of code, you may need something more.
 
Last edited by a moderator:

nio kasgami

VampCat
Veteran
Joined
May 21, 2013
Messages
8,949
Reaction score
3,042
First Language
French
Primarily Uses
RMMV
It's impossible to alias because if you want to add new line, you have no choice but overwrite the entire method. At least, most of the case.
okai so I assume this will be impossible to use alias

def refresh self.contents.clear for i in 0...@item_max draw_item(i, normal_color) endendWhat happens if I wanted to change the max number of items? Where do I change it?When I look at the ace code, I see that there is a method called "max_items", so I'm thinking ok I'll just change that.

Having lots of methods is advantageous when you're dealing with multiple scripts all trying to work with the same code. It is also good object-oriented design since every method has only one responsibility.

If you have one method that does everything, and my script just wants to change one piece of that process...well everything has to be overhauled.

It also adds a lot of overhead to your performance.

Which is true. Some people don't like object-oriented programming because of the massive amounts of overhead and syntax that it adds.

If you're writing a small, one-off program that you're writing on your own, then it probably doesn't matter, but for anything larger than a snippet of code, you may need something more.
hum I admit when you have to overhauled all the stuff this not help 

and yes I hate to modify ace script du the fact I need to check if each syntax is good and make the proccess hard 

Xp offert simpless but in someway this not also the best way for coding to 

(sorry if I get false I have a little dificulty to all understand what you mean )
 

Tsukihime

Veteran
Veteran
Joined
Jun 30, 2012
Messages
8,564
Reaction score
3,846
First Language
English
hum I admit when you have to overhauled all the stuff this not help 


and yes I hate to modify ace script du the fact I need to check if each syntax is good and make the proccess hard 


Xp offert simpless but in someway this not also the best way for coding to
Having to check whether your syntax is correct is not a good reason to not use methods or classes or inheritance. Or to suggest that it's easier.


At some point you will learn how to write and call methods without crashing a dozen times due to syntax errors, and XP's style of coding would just become a hindrance.
 

nio kasgami

VampCat
Veteran
Joined
May 21, 2013
Messages
8,949
Reaction score
3,042
First Language
French
Primarily Uses
RMMV
Having to check whether your syntax is correct is not a good reason to not use methods or classes or inheritance. Or to suggest that it's easier.

At some point you will learn how to write and call methods without crashing a dozen times due to syntax errors, and XP's style of coding would just become a hindrance.
sure! I know a lot of the basic rgss and I  don't follow xp coding to 100%  but try to fight with this all bunch of code can help a lot to improve

and I use a lot of classes and method haha 

for me XP is a simple Practice zone with I can mess 
 

Engr. Adiktuzmiko

Chemical Engineer, Game Developer, Using BlinkBoy'
Veteran
Joined
May 15, 2012
Messages
14,682
Reaction score
3,003
First Language
Tagalog
Primarily Uses
RMVXA
du the fact I need to check if each syntax is good
wait, there's a scripting language that doesn't have a syntax? 0.0
 

Shaz

Veteran
Veteran
Joined
Mar 2, 2012
Messages
40,098
Reaction score
13,704
First Language
English
Primarily Uses
RMMV
Just because you have to rewrite the entire method doesn't mean it's impossible to alias.


You CAN alias in RGSS1. Using alias to modify code is just more annoying because the methods are so huge. In Ace they're broken down into much smaller chunks, so you can alias the little bit you're interested in, instead of the entire thing.
 

Tsukihime

Veteran
Veteran
Joined
Jun 30, 2012
Messages
8,564
Reaction score
3,846
First Language
English
sure! I know a lot of the basic rgss and I don't follow xp coding to 100% but try to fight with this all bunch of code can help a lot to improve
Have you seen the Sprite_* classes in RMXP? There is literally an update method and that does everything you need.


When I look at a class and I see one method with 100 lines doing everything, that is scary.


I don't know where I would even begin to add some extra logic to it WHILE making sure it was compatible with other scripts.


I'm amazed Shaz does primarily XP stuff.
 
Last edited by a moderator:

nio kasgami

VampCat
Veteran
Joined
May 21, 2013
Messages
8,949
Reaction score
3,042
First Language
French
Primarily Uses
RMMV
Just because you have to rewrite the entire method doesn't mean it's impossible to alias.

You CAN alias in RGSS1. Using alias to modify code is just more annoying because the methods are so huge. In Ace they're broken down into much smaller chunks, so you can alias the little bit you're interested in, instead of the entire thing.
HO thanks shaz this a good answer this will avoid me to not understand : D! 

anyways I project to reorganize the whole xp script structure just for my fun and practice myself this more for help me to learn ! 
 

Shaz

Veteran
Veteran
Joined
Mar 2, 2012
Messages
40,098
Reaction score
13,704
First Language
English
Primarily Uses
RMMV
I'm amazed Shaz does primarily XP stuff.
Not really. I've done way more for Ace than for XP. But when VX came out I detested it, so I stuck with XP. So I did a lot in XP before Ace arrived.


I am still on the fence whether to use Ace or XP for my next game. If I use XP, I will probably rewrite all of the scripts so they are structured more like the Ace ones, and easier to alias SMALL methods.


Of course, that would make it easier to write scripts for, but there would be no point in sharing it, because it would then be incompatible with ANY other XP scripts.
 
Last edited by a moderator:

nio kasgami

VampCat
Veteran
Joined
May 21, 2013
Messages
8,949
Reaction score
3,042
First Language
French
Primarily Uses
RMMV
Have you seen the Sprite_* classes in RMXP? There is literally an update method and that does everything you need.

When I look at a class and I see one method with 100 lines doing everything, that is scary.

I don't know where I would even begin to add some extra logic to it WHILE making sure it was compatible with other scripts.

I'm amazed Shaz does primarily XP stuff.
I know what you mean this a pretty big for saying that can be scary a lot ~
 

♥SOURCE♥

Too sexy for your party.
Veteran
Joined
Mar 14, 2012
Messages
693
Reaction score
411
Primarily Uses
It's impossible to alias because if you want to add new line, you have no choice but overwrite the entire method. At least, most of the case.
You can alias just fine. There are tons of scripts for XP, you should check how they do it.
 

TheoAllen

Self-proclaimed jack of all trades
Veteran
Joined
Mar 16, 2012
Messages
5,592
Reaction score
6,522
First Language
Indonesian
Primarily Uses
RMVXA
You can alias just fine. There are tons of scripts for XP, you should check how they do it.
Oh well, no thanks. I'm happy to have RGSS3. I have a lot of reasons why I won't touch RMXP once again
 

♥SOURCE♥

Too sexy for your party.
Veteran
Joined
Mar 14, 2012
Messages
693
Reaction score
411
Primarily Uses
Oh well, no thanks. I'm happy to have RGSS3. I have a lot of reasons why I won't touch RMXP once again
Yet you say it is impossible to alias. I prefer RGSS3 too, and yes, adding code to default methods in RGSS is a little more messy but it is possible and works in the same way as RGSS2/3.
 

TheoAllen

Self-proclaimed jack of all trades
Veteran
Joined
Mar 16, 2012
Messages
5,592
Reaction score
6,522
First Language
Indonesian
Primarily Uses
RMVXA
Yet you say it is impossible to alias. I prefer RGSS3 too, and yes, adding code to default methods in RGSS is a little more messy but it is possible and works in the same way as RGSS2/3.
Once I knew how to script, and then I looked at the RGSS/RMXP, I suddenly lost interest. I aimed my script to be used for public and sticking with how default script works. It will not a problem if I'm working on the project alone (overwrite and alias as you like), but if I have a plan to release the script into public, I don't think it will be easy as RGSS3.

A topic which may worth to read

http://www.rpgmakervxace.net/topic/9682-rgss3-is-terrible/
 

♥SOURCE♥

Too sexy for your party.
Veteran
Joined
Mar 14, 2012
Messages
693
Reaction score
411
Primarily Uses
Thanks for the link, Theo, I'm checking it out. But I'm not discussing which one is better, as I already told you, I prefer RGSS3. I am saying that alias is possible in RGSS1, as with any RGSS version to date.
 

TheoAllen

Self-proclaimed jack of all trades
Veteran
Joined
Mar 16, 2012
Messages
5,592
Reaction score
6,522
First Language
Indonesian
Primarily Uses
RMVXA
I know :)  I just try to explain why most of people said it was impossible. Or at least in my point of view. Technically, it still possible, yes.
 

Users Who Are Viewing This Thread (Users: 0, Guests: 1)

Latest Threads

Latest Posts

Latest Profile Posts

Couple hours of work. Might use in my game as a secret find or something. Not sure. Fancy though no? :D
Holy stink, where have I been? Well, I started my temporary job this week. So less time to spend on game design... :(
Cartoonier cloud cover that better fits the art style, as well as (slightly) improved blending/fading... fading clouds when there are larger patterns is still somewhat abrupt for some reason.
Do you Find Tilesetting or Looking for Tilesets/Plugins more fun? Personally I like making my tileset for my Game (Cretaceous Park TM) xD
How many parameters is 'too many'??

Forum statistics

Threads
105,860
Messages
1,017,038
Members
137,568
Latest member
invidious
Top