rgss tips : xp structures and ace structure

● ARCHIVED · READ-ONLY
Started by nio kasgami 20 posts View original ↗
  1. 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

    Spoiler
    #==============================================================================# ** 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

    Spoiler
    #==============================================================================# ** 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~
  2. nio kasgami said:
    [...] (unless Alias because alias don't exist into RGSSI they only exist in RGSSII and RGSSIII) [...]
    It does exist. You can alias in RGSS1, either by alias_method or alias.
  3. ♥SOURCE♥ said:
    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 ;_;
  4. 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.
  5. 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.
  6. TheoAllen said:
    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

    Tsukihime said:
    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 )
  7. nio kasgami said:
    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.
  8. Tsukihime said:
    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 
  9. 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
  10. 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.
  11. 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.
  12. Shaz said:
    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 ! 
  13. Tsukihime said:
    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.
  14. Tsukihime said:
    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 ~
  15. TheoAllen said:
    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.
    Spoiler
    a5fd9f50473ea78ab4a5668771803996dfaebe931facffc060a9c530337dc7e7.jpg
    You can alias just fine. There are tons of scripts for XP, you should check how they do it.
  16. ♥SOURCE♥ said:
    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
  17. TheoAllen said:
    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.
  18. ♥SOURCE♥ said:
    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/
  19. 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.
  20. 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.