What's up, RMers?
Well, I have been busy with the compilation of several custom Ruby classes into a single source file written in C. It already includes scripts like the BaseObject, BasicSprite, KChest, and Door classes, plus the Klear, Map, Load and KUnits modules. I discovered there aren't as many shortcuts as in plain Ruby code, not that they don't exist at all, but some macros and functions are quite cryptic...
"For God has not destined us for wrath, but for obtaining salvation through our Lord Jesus Christ," 1 Thessalonians 5:9

Maranatha!

The Internet might be either your friend or enemy. It just depends on whether or not she has a bad hair day.

[Image: SP1-Scripter.png]
[Image: SP1-Writer.png]
[Image: SP1-Poet.png]
[Image: SP1-PixelArtist.png]
[Image: SP1-Reporter.png]

My Original Stories (available in English and Spanish)

List of Compiled Binary Executables I have published...
HiddenChest & Roole

Give me a free copy of your completed game if you include at least 3 of my scripts! Laughing + Tongue sticking out

Just some scripts I've already published on the board...
KyoGemBoost XP VX & ACE, RandomEnkounters XP, KSkillShop XP, Kolloseum States XP, KEvents XP, KScenario XP & Gosu, KyoPrizeShop XP Mangostan, Kuests XP, KyoDiscounts XP VX, ACE & MV, KChest XP VX & ACE 2016, KTelePort XP, KSkillMax XP & VX & ACE, Gem Roulette XP VX & VX Ace, KRespawnPoint XP, VX & VX Ace, GiveAway XP VX & ACE, Klearance XP VX & ACE, KUnits XP VX, ACE & Gosu 2017, KLevel XP, KRumors XP & ACE, KMonsterPals XP VX & ACE, KStatsRefill XP VX & ACE, KLotto XP VX & ACE, KItemDesc XP & VX, KPocket XP & VX, OpenChest XP VX & ACE
Reply }
I have continued developing my KUnits Ruby C extension, I added more methods, iterators and other stuff, plus one or two new classes, it's going pretty fine, but I can only compile it n Linux (specifically Kubuntu Bionic 18.04 LTS) because I have no free C compiler for Windows (8.1). I also went through some serious headaches while trying to define a block in Ruby C, but I got an iterator to do the job in a couple of methods, but I still wonder how I can do it in C without depending on the function call for Ruby methods...
"For God has not destined us for wrath, but for obtaining salvation through our Lord Jesus Christ," 1 Thessalonians 5:9

Maranatha!

The Internet might be either your friend or enemy. It just depends on whether or not she has a bad hair day.

[Image: SP1-Scripter.png]
[Image: SP1-Writer.png]
[Image: SP1-Poet.png]
[Image: SP1-PixelArtist.png]
[Image: SP1-Reporter.png]

My Original Stories (available in English and Spanish)

List of Compiled Binary Executables I have published...
HiddenChest & Roole

Give me a free copy of your completed game if you include at least 3 of my scripts! Laughing + Tongue sticking out

Just some scripts I've already published on the board...
KyoGemBoost XP VX & ACE, RandomEnkounters XP, KSkillShop XP, Kolloseum States XP, KEvents XP, KScenario XP & Gosu, KyoPrizeShop XP Mangostan, Kuests XP, KyoDiscounts XP VX, ACE & MV, KChest XP VX & ACE 2016, KTelePort XP, KSkillMax XP & VX & ACE, Gem Roulette XP VX & VX Ace, KRespawnPoint XP, VX & VX Ace, GiveAway XP VX & ACE, Klearance XP VX & ACE, KUnits XP VX, ACE & Gosu 2017, KLevel XP, KRumors XP & ACE, KMonsterPals XP VX & ACE, KStatsRefill XP VX & ACE, KLotto XP VX & ACE, KItemDesc XP & VX, KPocket XP & VX, OpenChest XP VX & ACE
Reply }
I admit I'm illiterate when it comes to programing languages so may I ask how does Ruby compare to other languages such a C++ and PHP?
Reply }
I picked up an idiot's guide to C++. Funny read, though I strayed away from studying it because of other issues. Still, I see parallels between it and Ruby, particularly in structure. Methods holding classes holding methods (defs)... and other thingies. I cannot say the same for php. Totally different in an html sorta way.
Up is down, left is right and sideways is straight ahead. - Cord "Circle of Iron", 1978 (written by Bruce Lee and James Coburn... really...)

[Image: QrnbKlx.jpg]
[Image: sGz1ErF.png]    [Image: liM4ikn.png]    [Image: fdzKgZA.png]    [Image: sj0H81z.png]
[Image: QL7oRau.png]    [Image: uSqjY09.png]    [Image: GAA3qE9.png]    [Image: 2Hmnx1G.png]    [Image: BwtNdKw.png%5B]
  Above are clickable links
Reply }
C is not modular but you don't necessarily need to type every single thing whenever you're using Ruby C, I mean, some default functions that resemble Ruby methods can just be referenced by calling them provided you entered all required arguments... I suspect Ruby'$s mkmf and make fill it up by replacing calls with actual code. At least that's why I think that happens if you call the Ruby C initialize class instance function, a hidden initialize method intermediate step taken care of by Ruby whenever you call the YourClass.new method...
"For God has not destined us for wrath, but for obtaining salvation through our Lord Jesus Christ," 1 Thessalonians 5:9

Maranatha!

The Internet might be either your friend or enemy. It just depends on whether or not she has a bad hair day.

[Image: SP1-Scripter.png]
[Image: SP1-Writer.png]
[Image: SP1-Poet.png]
[Image: SP1-PixelArtist.png]
[Image: SP1-Reporter.png]

My Original Stories (available in English and Spanish)

List of Compiled Binary Executables I have published...
HiddenChest & Roole

Give me a free copy of your completed game if you include at least 3 of my scripts! Laughing + Tongue sticking out

Just some scripts I've already published on the board...
KyoGemBoost XP VX & ACE, RandomEnkounters XP, KSkillShop XP, Kolloseum States XP, KEvents XP, KScenario XP & Gosu, KyoPrizeShop XP Mangostan, Kuests XP, KyoDiscounts XP VX, ACE & MV, KChest XP VX & ACE 2016, KTelePort XP, KSkillMax XP & VX & ACE, Gem Roulette XP VX & VX Ace, KRespawnPoint XP, VX & VX Ace, GiveAway XP VX & ACE, Klearance XP VX & ACE, KUnits XP VX, ACE & Gosu 2017, KLevel XP, KRumors XP & ACE, KMonsterPals XP VX & ACE, KStatsRefill XP VX & ACE, KLotto XP VX & ACE, KItemDesc XP & VX, KPocket XP & VX, OpenChest XP VX & ACE
Reply }
C++ is modular, just as Ruby. Though not many code using the 'module' structure in Ruby (which is the largest of the structures in C++ and Ruby), we do use the Class structure (the second largest) and fill them with methods (or functions... your choice of names Tongue sticking out ).

Modules hold Classes. Classes hold methods (defs). Methods hold your individual routines... can also be called functions.

Some key method names are mirrored between C++ and Ruby. Both require the 'main' method which acts as the actual engine, running your code. And the initialize method is used for housekeeping, setting up values that are processed by your code.

Insofar as the initialize method within Ruby, it does exist for every class. Yep, even if you see one of the default classes like 'Scene_Battle' not having an initialize method, it does exist. And you can use the 'alias' method to prove it. The Alias method in Ruby allows you to rename a method (aka 'alias') to some other name allowing you to create a new method of the same name. This allows you to add code to a method. A cool little trick added into Ruby.

Code:
#==============================================================================
# ** Scene_Battle (part 1)
#------------------------------------------------------------------------------
#  This class performs battle screen processing.
#==============================================================================

class Scene_Battle
  #--------------------------------------------------------------------------
  # * Main Processing
  #--------------------------------------------------------------------------
  alias fred initialize
  def initialize
    fred
  end
end

If the Scene_Battle class did not have an initialize method, this would not function. Just as C++ has initialize methods, Ruby does by default.
Up is down, left is right and sideways is straight ahead. - Cord "Circle of Iron", 1978 (written by Bruce Lee and James Coburn... really...)

[Image: QrnbKlx.jpg]
[Image: sGz1ErF.png]    [Image: liM4ikn.png]    [Image: fdzKgZA.png]    [Image: sj0H81z.png]
[Image: QL7oRau.png]    [Image: uSqjY09.png]    [Image: GAA3qE9.png]    [Image: 2Hmnx1G.png]    [Image: BwtNdKw.png%5B]
  Above are clickable links
Reply }
Well, wulfo, that's because the new and initialize methods are included in Ruby C by default! Yeah, if you don't supply one for your class, Ruby will do that for you by making an empty initialize method call automatically. Whenever you define your initialize method, it stops calling its default method and executes yours instead, mainly because it's the last initialize method created for that specific class; it would call the third one in case you ever decided to overwrite it and skip the others by default. (Ruby 1.9 included in VX Ace lets you even include a hash parameter via syntatic sugar by defining its key value pairs like this: key: value, mykey: myvalue . It will later one convert it to the typical :key => value syntax anyway, but it lets you smoothly define your hash in no time.)
"For God has not destined us for wrath, but for obtaining salvation through our Lord Jesus Christ," 1 Thessalonians 5:9

Maranatha!

The Internet might be either your friend or enemy. It just depends on whether or not she has a bad hair day.

[Image: SP1-Scripter.png]
[Image: SP1-Writer.png]
[Image: SP1-Poet.png]
[Image: SP1-PixelArtist.png]
[Image: SP1-Reporter.png]

My Original Stories (available in English and Spanish)

List of Compiled Binary Executables I have published...
HiddenChest & Roole

Give me a free copy of your completed game if you include at least 3 of my scripts! Laughing + Tongue sticking out

Just some scripts I've already published on the board...
KyoGemBoost XP VX & ACE, RandomEnkounters XP, KSkillShop XP, Kolloseum States XP, KEvents XP, KScenario XP & Gosu, KyoPrizeShop XP Mangostan, Kuests XP, KyoDiscounts XP VX, ACE & MV, KChest XP VX & ACE 2016, KTelePort XP, KSkillMax XP & VX & ACE, Gem Roulette XP VX & VX Ace, KRespawnPoint XP, VX & VX Ace, GiveAway XP VX & ACE, Klearance XP VX & ACE, KUnits XP VX, ACE & Gosu 2017, KLevel XP, KRumors XP & ACE, KMonsterPals XP VX & ACE, KStatsRefill XP VX & ACE, KLotto XP VX & ACE, KItemDesc XP & VX, KPocket XP & VX, OpenChest XP VX & ACE
Reply }
Thanks for the answers. Really interesting stuff. Maybe I ought to learn Ruby so I can work on my own scripts or just edit existent ones.

On an unrelated note, what's the easiest way to program events that have one in a determinate number of chances of taking place? Like for example I want a event to have a 1 in a 10 chances of appearing when entering a map?
Reply }
No problem. Given the similarities between the two, you could jump from Ruby to C++ after some practice.

Oh, and I should point out that default initialize methods do exist within C++ programming as well, likely what Ruby's default initialize is based upon. The creation of automatic, static, or thread-local variables is thus made possible without such a method being added into the code, sloppy though that may be. Oh, I've done some studying of constructors and destructors in C++. Destructors are akin to the 'dispose' method we make, and there are default dispose and destructor methods.
Up is down, left is right and sideways is straight ahead. - Cord "Circle of Iron", 1978 (written by Bruce Lee and James Coburn... really...)

[Image: QrnbKlx.jpg]
[Image: sGz1ErF.png]    [Image: liM4ikn.png]    [Image: fdzKgZA.png]    [Image: sj0H81z.png]
[Image: QL7oRau.png]    [Image: uSqjY09.png]    [Image: GAA3qE9.png]    [Image: 2Hmnx1G.png]    [Image: BwtNdKw.png%5B]
  Above are clickable links
Reply }
Okay......... if Ruby has a 'Time' class that allows you to run tests down to the millisecond, and the Time class is accurate and based on your own system rather than an arbitrary counter.....

.... Why hasn't anyone though about replacing the WAIT system in any RPGMaker system which relies on the counter-system frame with an accurate Millisecond Time system?
Up is down, left is right and sideways is straight ahead. - Cord "Circle of Iron", 1978 (written by Bruce Lee and James Coburn... really...)

[Image: QrnbKlx.jpg]
[Image: sGz1ErF.png]    [Image: liM4ikn.png]    [Image: fdzKgZA.png]    [Image: sj0H81z.png]
[Image: QL7oRau.png]    [Image: uSqjY09.png]    [Image: GAA3qE9.png]    [Image: 2Hmnx1G.png]    [Image: BwtNdKw.png%5B]
  Above are clickable links
Reply }




Users browsing this thread: 310 Guest(s)