Ancurio / mkxp

Free Software implementation of the Ruby Game Scripting System (RGSS)
GNU General Public License v2.0
524 stars 137 forks source link

TABLE class. RMXP's dup and clone params missing #50

Closed DerVVulfman closed 10 years ago

DerVVulfman commented 10 years ago

It isn't that the commands aren't present. But their function was to retrieve the data contents is not present. You can try this statement within the Spriteset_Map class to see my point:

p $game_map.data[7,6,0] my_dup = $game_map.data.dup p my_dup[7,6,0]

In a normal RPGMaker XP project, this method would twice print the tile ID of a floor tile at the 7/6 location in the map.

However, it runs into a massive problem when run within mkxp. The question I asked myself was... WHY?

As the data field in $game_map is a table, I ran an additional check to ensure the issue was with the Table class.

s1 = Table.new(2,2) s1[0,0] = 1 s1[0,1] = 2 s1[1,0] = 3 s1[1,1] = 4 p s1[0,1] s2 = s1.dup p s2[1,1]

A very simple test. I created a 2x2 table with data in each field. When I ran this within RPGMaker XP, it would retrieve data from both the original and duplicate tables. With mkxp, it again suffered an error. This again puzzled me. I looked at some info on the Table class, and it was a child class of the Object class that has both .dup and .clone commands......

So I did one more test. You COULD get a response from the below version, returning that a table exists...

s1 = Table.new(2,2) s1[0,0] = 1 s1[0,1] = 2 s1[1,0] = 3 s1[1,1] = 4 p s1 s2 = s1.dup p s2

And there in gave me an answer. I could get a response with both .dup and .clone indicating that it was actually copying the whole table itself. But once you try to retrieve contents from the duplicated/cloned table, you get an error. Both dup and clone were supposed to return a table with the contents, but that was where it failed. It duplicated the table, but not the contents as it is supposed to

It would have been nice if the 'Standard Library / Built-In Classes' part of the RMXP help file mentioned that the Table class was a child of the Object class. I tested the other object children and most are working fine. ;) Well, mebby not the Font class (duh), and I honestly wouldn't know how to test the IO, Viewport or Window classes. :P

Ancurio commented 10 years ago

Table cloning wasn't implemented, thanks for the report.

Font cloning is supposed to work, if not please open a new ticket. Viewport, Window etc. cloning is forbidden by RGSS (see #17). No idea about ruby's builtin classes like IO.