Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
 Ruby, RGSS & General Code Discussion
#2
I think the all RGSS code should be open source. There are some scripts that require DLL or executable to work. The custom DLL's should have included source. The scripter reading other scripts, learns how to making scripts. Why people uses DLL in RGSS scripts? The first thing is - to hide source.

Some coding standards prefered by me :

98 % of Rpg Maker users edits RGSS Default Interpreter Scripts. This is not good idea.
The better is make new * Mods script and paste in it modified segments.

For ex.

This is Window Playtime class.
Code:
class Window_PlayTime < Window_Base
  def initialize
    super(0, 0, 160, 96)
    self.contents = Bitmap.new(width - 32, height - 32)
    self.contents.font.name = $font.get($actual_font, 0)
    self.contents.font.size = $font.get($actual_font, 1)
    refresh
  end
  def refresh
    self.contents.clear
    self.contents.font.color = system_color
    self.contents.draw_text(4, 0, 120, 32, "Play Time")
    @total_sec = Graphics.frame_count / Graphics.frame_rate
    hour = @total_sec / 60 / 60
    min = @total_sec / 60 % 60
    sec = @total_sec % 60
    text = sprintf("d:d:d", hour, min, sec)
    self.contents.font.color = normal_color
    self.contents.draw_text(4, 32, 120, 32, text, 2)
  end
  def update
    super
    if Graphics.frame_count / Graphics.frame_rate != @total_sec
      refresh
    end
  end
end

You want to edit a part of this class to change the text "Play Time" at the "Real Time" and you want to make visible your computer, real hour instead of PlayTime.
In * Mods :
Copy object you want to edit and edit features in the mods class.
Using this method makes code clean :)

Code:
class Window_PlayTime < Window_Base
  def refresh
    self.contents.clear
    self.contents.font.color = system_color
    self.contents.draw_text(4, 0, 120, 32, "Real Time")
    text = "#{Time.now.hour} : #{Time.now.min} : #{Time.now.sec}"
    self.contents.font.color = normal_color
    self.contents.draw_text(4, 32, 120, 32, text, 2)
  end
end

That's all my suggestions.
Skills: Android, Ruby, PHP, Linux
Reply }


Messages In This Thread
RE: Ruby, RGSS & General Code Discussion - by Narzew - 11-15-2012, 02:02 PM

Possibly Related Threads…
Thread Author Replies Views Last Post
   Possible means to speed up Bitmap TONE code? DerVVulfman 7 1,893 06-11-2023, 08:22 PM
Last Post: kyonides
   RGSS scripting dissections and explinations Siletrea 97 92,692 03-18-2019, 06:46 AM
Last Post: Siletrea
   Help iwth script (RGSS Player crash) Whisper 3 7,747 06-17-2017, 05:03 PM
Last Post: Whisper
  How can I use the cmd of "require" in rgss superegp 2 5,432 11-03-2015, 06:16 AM
Last Post: kyonides
   Custom Game_Event code lags too much! MechanicalPen 4 5,969 06-27-2013, 11:22 PM
Last Post: MechanicalPen
Question  RGSS stoped to work Chaos17 5 6,992 02-14-2013, 05:13 PM
Last Post: DerVVulfman
   [Request] Tut. for RGSS Eldur 9 10,759 12-07-2012, 04:27 AM
Last Post: DerVVulfman
   [RUBY] Depack Thread Problem Narzew 1 4,010 07-20-2012, 01:16 PM
Last Post: Narzew
   [ASK-RGSS] Behemoth's CBS alike Getsuga_kawaii 0 3,909 04-29-2010, 03:07 PM
Last Post: Getsuga_kawaii
   Quick RGSS question - switches Ravenith 2 5,187 08-23-2009, 11:23 AM
Last Post: Ravenith



Users browsing this thread: