BlueMage

Slime Lv99
Veteran
Joined
Apr 13, 2019
Messages
116
Reaction score
149
First Language
English
Primarily Uses
RMVX
Hi guys,
I want to ask does it mean to create a new object if we run:
abc = abc.new(1,2)

But then, for example that i need object abc to insert into: tint_start(abc)
how can i straightly write something like: tint_start({1,2}) instead of using .new key
 

MushroomCake28

KAMO Studio
Global Mod
Joined
Nov 18, 2015
Messages
3,933
Reaction score
4,845
First Language
EN, FR
Primarily Uses
RMMZ
.new simply creates an object based on the object you're calling. It comes from C++, where you have static classes. Imagine that you have a prototype model and you want to mass produce it. You're going to reproduce it. That's exactly what .new does: it takes an object and creates another object with the same properties.

In your case:

Code:
abc = Abc.new(1, 2) # By convention, we start classes with a upper case.

# This will create an object based on the Abc class and will name it abc. It will call the initialize function from the Abc class and give it the
# parameter 1 and 2.
# It's also important to note that abc != Abc. You've created a new object.
# You should have somewhere a class to define Abc

class Abc
   def initialize(x, y)
      self.x = x;
      self.y = y;
   end
end
 

BlueMage

Slime Lv99
Veteran
Joined
Apr 13, 2019
Messages
116
Reaction score
149
First Language
English
Primarily Uses
RMVX
Hey thank you very much @MushroomCake28
Your answer helped me understood the problem!
So RPG::BGM.new("BGM Name", volume, pitch).play
mean re-produce BGM class from module RPG?
 

MushroomCake28

KAMO Studio
Global Mod
Joined
Nov 18, 2015
Messages
3,933
Reaction score
4,845
First Language
EN, FR
Primarily Uses
RMMZ
No, "Objects are instances of the class." (https://www.tutorialspoint.com/ruby/ruby_classes.htm , I actually recommend reading this to help you). Vocab, Cache, Sound, DataManager, SceneManager, and BattleManagers are modules, not classes, and therefore you can't really create an object out of them (well... it wouldn't do anything). They are acting more like static classes from C++ (someone should double check this statement cause I'm not a professional programmer that has a degree).

So basically for audio, you don't create an object to play it, you simply call it:

Code:
Sound.play_cursor                        # plays the cursor SE
Audio.bgm_play(name, vol, pitch)  # plays a bgm which is defined in the parameters

What exactly are you trying to accomplish? Or is this a simple learning experience?
 

Engr. Adiktuzmiko

Chemical Engineer, Game Developer, Using BlinkBoy'
Veteran
Joined
May 15, 2012
Messages
14,682
Reaction score
3,006
First Language
Tagalog
Primarily Uses
RMVXA
The default engine uses the RPG::BGM object simply to hold the data needed to be passed on to the Audio.bgm_play method.

So yeah, strictly speaking, you don't even need to use the BGM object to play an audio.

Also, using .new doesnt exactly reproduce the class, it creates an instance of that class. The new object being just an instance of the class, can only access anything the class has.

Reproduction would be more akin to making child classes. They have all properties of the parent class, and can have their own properties not in the parent class.
 
Last edited:

BlueMage

Slime Lv99
Veteran
Joined
Apr 13, 2019
Messages
116
Reaction score
149
First Language
English
Primarily Uses
RMVX
Thanks guys. I got it!
I have another question.
Is there a way to store a script snippet in script list and call it later via script call command in game?
Like create a module/class/method?? and call it? =D
 

Engr. Adiktuzmiko

Chemical Engineer, Game Developer, Using BlinkBoy'
Veteran
Joined
May 15, 2012
Messages
14,682
Reaction score
3,006
First Language
Tagalog
Primarily Uses
RMVXA
If you write it in the script editor, you can call it using the script call event command.

For example, I put this code in the script editor, close it and save the game.

Code:
module Adik
  def test
    p "test!"
  end
end

In game, if I use the script call Adik.test this will call my method above and print the message into the console.
 

BlueMage

Slime Lv99
Veteran
Joined
Apr 13, 2019
Messages
116
Reaction score
149
First Language
English
Primarily Uses
RMVX
If you write it in the script editor, you can call it using the script call event command.

For example, I put this code in the script editor, close it and save the game.

Code:
module Adik
  def test
    p "test!"
  end
end

In game, if I use the script call Adik.test this will call my method above and print the message into the console.

Awesome! Thanks @Engr. Adiktuzmiko , i used to insert bunches of scripts into Game_Interpreter to call them = D
 

Engr. Adiktuzmiko

Chemical Engineer, Game Developer, Using BlinkBoy'
Veteran
Joined
May 15, 2012
Messages
14,682
Reaction score
3,006
First Language
Tagalog
Primarily Uses
RMVXA
The good thing if you put them inside the GE class is that you can script call the method name directly since the script call box is processed inside the GE class itself.

Its useful for small snippets that wont be called by other scripts..

Code:
class Game_Interpreter
  def test
  end
end

If you do it that way, you can just script call it on the event as test
 

Latest Threads

Latest Posts

Latest Profile Posts

Hmm... Game has 91 views, 25 downloads, 5 reviews and netted me 7 additional followers. Meanwhile the image I posted just yesterday on Imgur to showcase it has 45,197 views. Interesting, I think I have a new advertising idea. Also Twitter? The post got 16 retweets, 20 likes, and 1,683 views.... And a whole 3 hits to my game, completely valueless. I am glad I did this game jam, this information is quite valuable.
We're playing another Touch the Stars game jam entry, come join us! :D
Ok is telling someone that their drawing isnt good rude
I'm familiar with MZ thanks to jam now. I say it's a better working and looking MV. Lots of plugins too and FOSSIL helps alot. It's not bad.
Some more progress <3 and in most important news:
ALPACARAPTOR SPRITE! (not animated yet, though :( )
h4u90Sz.png

Forum statistics

Threads
113,654
Messages
1,076,466
Members
147,674
Latest member
StaciaStay
Top