RMRK is retiring.
Server is paid up for the rest of 2026, but the forum may go after that. See here for more information. Please archive or save anything you would like to keep before 2027.
Main Menu

:S ... Why ... (is Game_Actor becoming nil...) - WOOHOO....solved

Started by da good king, January 12, 2009, 02:06:00 AM

0 Members and 1 Guest are viewing this topic.

da good king

 After a week or two working on the Game_Actor class, I have come to find one great disturbing factor... As I have previously mentioned, my game is using a recruit method, where class_id and level are part of Game_Actor's setup method.

Apparently, that just isn't working...In Game_Actors I replaced this code:

if @data[actor_id] == nil
  @data[actor_id] = Game_Actor.new(actor_id)
end

With a similar code only with Game_Actor.new(actor_id, 1 , 1). This is supposed to say if data does not exist for this actor, make a new default one. I think...
Well, anyhow, when I use the script code Game_Actor.new(2, 2, 15), which should create a new actor with ID: 2, Class_id: 2, and level: 15, I then refer to its level with $game_actors[2].level, and it returns 1....

It would seem no matter what I do, it's returning its data as nil...So what on earth am I supposed to do...I suppose I just don't understand how Object.new works even thought I would have thought it simple  :mad:

I have the daunting feeling I'm gonna have to start all over... :'( *sigh*
Any ideas as to what I should do to...idk...make it so I can create a new actor with its class and level specified in its setup?  ???

EDIT: I tried making its @data = a new recruit with the specified arguments inside the Game_Actor class...but ofc the "Stack level is too deep"... jeeeez

modern algebra

Wait, so what do you mean by nil? - you're getting an error that says undefined method level for nil:NilClass

or is it just not levelling the actor?

What have you modified in Game_Actor to make it so that it does level the character, anyway?

da good king

 Oh, well the problem was that I wasn't reading how Game_Actors works. It has a @data array that contains all character data, but from the start contains nothing. As you refer to $game_actors[id] it then fills @data with Game_Actor.new(id) data. As such, I, for whatever ridiculous reason, assumed that by calling Game_Actor.new(id, class, level) I was adding data to Actors :P.....

No worries now, however. I have corrected the problem myself, as I simply replaced the add_actor method with one that inserts new Game_Actor data into $game_actors.data according to the arguments placed in get_recruit(class, level) => the new method

Sorry for the needless topic, I basically panicked when I saw weeks of work suddenly going to oblivion.

P.S. They level normally, through experience, but I want to be able to add recruits and specify their class/level in one stroke, not by some annoying method of editing them directly ($game_actors.level=), which would be encumbersome when I'm trying to add new recruits ALL the time.