RMXP - Displaying A Player's Username In The Save/Load Menu

Started by WoofLover, December 13, 2011, 11:54:37 am

Previous topic - Next topic

WoofLover

Hello, I was hoping if someone can help me with something.  I'm trying to make it so that when the player starts a new game, a Name Input Processing event runs that lets players rename a blank Actor slate.  This blank actor's new name then becomes their unique username throughout the whole game and their save file.

I'm using the Chaos Project Save Layout and I'm trying to modify it so that it will also display the username in the existing files.  So far I've tried two variations of the modification, each with their own problems.

1.

UserName = true # Enable user names

     if CPSL::UserName
      y = CPSL::UserName ? 0 : 14
        user = $game_actors[9]
        draw_user_name(user, 256, y, 82, 1)
      end

def draw_user_name(user, x, y, width=120, align=0)
    self.contents.font.color = normal_color
    self.contents.draw_text(x, y, width, 32, user.name, align)
end

The problem with the first is that it will only display the username you created for all the save files, even the ones that are supposed to have a different username for it.  The second problem is that the game crashes when I try to call the load scene.  It says that NoMethodError occurred for the lines 'user= $game_actors[9]' and that there's an 'undefined method '[]' for nil:NilClass'.

2

UserName = true # Enable user names

     if CPSL::UserName
      y = CPSL::UserName ? 0 : 14
        $actor_names = load_data('Data/Actors.rxdata')
        user = $actors_names[9]
        draw_user_name(user, 256, y, 82, 1)
      end

def draw_user_name(user, x, y, width=120, align=0)
    self.contents.font.color = normal_color
    self.contents.draw_text(x, y, width, 32, user.name, align)
end

The problem with the second is that while there are no crashes when you try to save/load the file, the username doesn't change at all from what I've originally typed in the Game Database.

Can someone please help me with this, or suggest a better method for what I'm trying to do?  Thank you. :)

Fantasist

Hi :)
The change you've made in the second variation ($actor_names = load_data('Data/Actors.rxdata')) shows that you have some idea about scripting, which will make it much easier for the both of us.
You've obviously figured out that you need to have the data loaded for it to be accessed. The load screen used to crash because $game_actors is normally loaded after loading a savefile.

QuoteThe problem with the second is that while there are no crashes when you try to save/load the file, the username doesn't change at all from what I've originally typed in the Game Database.

That's because Actors.rxdata contains the actor data you have set in the RMXP editor. So you're simply displaying the 9th actor's name from the database. To get the actor's name you've defined, you need to get the actor from the Game_Party object from the savefile.

But this gets me thinking. By user name, don't you simply mean the actor's name? Isn't that already displayed? Like Aluxes, Basil, etc? If you tell me what you mean exactly, I'll try to guide you.
Do you like ambient/electronic music? Then you should promote a talented artist! Help out here. (I'm serious. Just listen to his work at least!)


The best of freeware reviews: Gizmo's Freeware Reviews