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.

RGSS Conversions

Status
Not open for further replies.
Im trying to convert variables and strings using RGSS. I understand how .to_s works. I also understand how .to_i, .to_f, and .to_a work. However, I am having trouble implementing them into my script.
I have created an array, for example @array = []
I then created data to be pushed into the array:
Code:
@array = []
@data1 = []
@data1 = [x, y, z]
@data2 = []
@data3 = [a,b,c]
.
.
.
etc...
Finally I push the data into the array, however, since in my game I contain about 75 pieces of data, I would rather not use:
Code:
@array.push(@data1)
@array.push(@data2).......

-or-

Code:
@array.push(@data1, @data2, ......................................................)

I began by trying:
Code:
@array.push(("@data" + (1...75).to_s).to_a)

However this does not work. Does anyone know how to correctly arrange and convert these data? Thanks in advanced!
 
How about:

Code:
@array = []
@data = []
@data[1] = [x, y, z]
@data[2] = []
@data[3] = [a, b, c]

for i in 1..data.size
    @array.push(@data[i])
end

I'm not sure what you're exactly trying to do though.
 
Or if you want to keep the @data1, @data2 scheme:
Code:
for i in 1..3
  eval("@array << @data#{i}")
end

Or to make the code nicer. :P
Code:
@array = []
@data = []
@data[1] = [x, y, z]
@data[2] = []
@data[3] = [a, b, c]

@data.each { |data| @array << data}
 
This topic has been resolved. If christophercain3 or any other users have any questions or further problems regarding this topic, please create a new thread about them.

Thank you!
 
Status
Not open for further replies.

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