RMRK is retiring.
Registration is disabled. The site will remain online, but eventually become a read-only archive. More information.

RMRK.net has nothing to do with Blockchains, Cryptocurrency or NFTs. We have been around since the early 2000s, but there is a new group using the RMRK name that deals with those things. We have nothing to do with them.
NFTs are a scam, and if somebody is trying to persuade you to buy or invest in crypto/blockchain/NFT content, please turn them down and save your money. See this video for more information.
Creating and accessing an array [Resolved]

0 Members and 1 Guest are viewing this topic.

**
Rep: +0/-0Level 85
Ok, so I get that you make an array by typing something like main_characters = ["Levi", "Peregrine"].

How do I create that in RMXP when the program is doing all of its usual initialization, and then have the program maintain its status (so if the array changes to ["Al", "Gina"] it will not go back to ["Levi", "Peregrine"] the next time I or the player start it up?)

After that, what specifically would I type in to an event that let me access and/or change the contents of the array?
« Last Edit: August 16, 2008, 08:36:14 PM by golothwen »

*
Rep:
Level 97
2014 Most Unsung Member2014 Best RPG Maker User - Engine2013 Best RPG Maker User (Scripting)2012 Most Mature Member2012 Favorite Staff Member2012 Best RPG Maker User (Scripting)2012 Best MemberSecret Santa 2012 ParticipantProject of the Month winner for July 20092011 Best Use of Avatar and Signature Space2011 Best RPG Maker User (Scripting)2011 Most Mature Member2011 Favourite Staff Member2011 Best Veteran2010 Most Mature Member2010 Favourite Staff Member
Well, there are a number of ways to do what you are asking. It really depends on where you want this array to be accessed from. For instance, you could do this:

$bad_global = ["Levi", "Peregrine"]

and if you put this code in in the new_game method of Scene_Title then it would initialize only once. It could then be accessed by simply calling $bad_global.

Or you could set the array as an instance variable of another class, such as Game_Party.

Then you could set this code:

attr_accessor :main_chars

and then in the initialize method, write:

@main_chars = ["Levi", "Peregrine"]


Then the array would initialize once and only once and it would be accessible through the code $game_party.main_chars

**
Rep: +0/-0Level 85
That makes sense, thanks so much. =)