Envision, Create, Share

Welcome to HBGames, a leading amateur game development forum and Discord server. All are welcome, and amongst our ranks you will find experts in their field from all aspects of video game design and development.

Two questions.

Is it was possible in ruby to combine the data of two instances from the same class? I want to take all of the instance variables from one copy of a class and add them to them to another copy of the same class.

Also I was wondering if somebody made a script where you could open an input window for RGSS during a test game.
 

OS

Sponsor

1. Try:

Code:
#instance# = Class.new(x, y)
instance1 = Class.new(1, 1)
instance2 = Class.new(instance1.x, instance1.y)

This will give instance2 the same attributes as instance1. Pretty easy, right?

2. I dunno...

Peace Out!

~Broken
 

Anonymous

Guest

An instance of a class is called an object. The class is the template, the object is what is created from that template.

Code:
foo = Foo.new
bar = foo.clone

bar is now identical to foo, but not the same object. However, this is a shallow copy. Instance variables will be copied, but the two will share objects they refrence. If you want a deep copy, you'll have to write the method yourself.
 
hey ccoa, how do you know this shit so well!!!?

i found this index html thingy that has "Demystifying the Game Process," and I was simply amazed at how well you combine events and scripts to produce such effective scenes!

u know, u really should make a full tutorial on scripting, cuz u's is genious at that!
 

Thank you for viewing

HBGames is a leading amateur video game development forum and Discord server open to all ability levels. Feel free to have a nosey around!

Discord

Join our growing and active Discord server to discuss all aspects of game making in a relaxed environment. Join Us

Content

  • Our Games
  • Games in Development
  • Emoji by Twemoji.
    Top