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.
:S ... Why ... (is Game_Actor becoming nil...) - WOOHOO....solved

0 Members and 1 Guest are viewing this topic.

***
Rep:
Level 87
 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:

Code: [Select]
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
Code: [Select]
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
« Last Edit: January 12, 2009, 03:18:31 AM by da good king »

*
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
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?

***
Rep:
Level 87
 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.
« Last Edit: January 12, 2009, 03:26:38 AM by da good king »