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.
[RESOLVED] Assistance Needed

0 Members and 1 Guest are viewing this topic.

********
Hungry
Rep:
Level 96
Mawbeast
2013 Best ArtistParticipant - GIAW 11Secret Santa 2013 ParticipantFor the great victory in the Breakfast War.2012 Best Game Creator (Non-RM Programs)~Bronze - GIAW 9Project of the Month winner for December 2009Project of the Month winner for August 20082011 Best Game Creator (Non RM)Gold - GIAW Halloween
alright, I want to try and make NBDA compatable with CBS systems.

I know why it's incompatable, because I overloaded the main and phase 5 methods of the battle class

what I want to know, is if I could make a script go through what it would normally do (the previous version) and then do something new.

like if the original
: printed a name
: played a sound effect

could I make an overloaded version
: do what the original did
: show a face

I hope you can understand what I'm saying
« Last Edit: May 27, 2007, 09:53:31 PM by Zeriab »

FCF3a A+ C- D H- M P+ R T W- Z- Sf RLCT a cmn+++ d++ e++ f h+++ iw+++ j+ p sf+
Follow my project: MBlok | Find me on: Bandcamp | Twitter | Patreon

***
Rep:
Level 90
Skilled Scripter, Shitty Mapper, Decent Writer.
You can do something like that without overwriting a method's function with the alias syntax. What does alias do? It allows you to add to an existing method without overwriting it. For a good number of examples, I'd recommend looking at the various scripts done by Blizzard in the scripts database. The alias syntax works like this. You alias the old method name with a new name, preferably similar to the old name, and then call the new name inside the method. You MUST call the aliased name within the method that was aliased. Now for a little specific detail on when to use the aliased name and what happens when you do. If there are any arguments in the method name, you must have them with the new alias name when you call it. Look at my second example and you should understand aliases involving arguments.

Code: [Select]
class Foo
  def int
    number = 7
  end
end

class Foo

  alias new_int_method int
  def int
    new_int_method#here you are calling the alias name
    if number == 7
      p number
    end
  end
end
As you can see here, we added an "if" conditional branch to the method int. Where would the conditional branch be when the alias "merges" the little pieces of code? Everything AFTER the alias name is called is put at the end of the original method. Unfortunately, I don't know where everything before the alias name goes when the alias name is being called. Now for a working example for you to pick apart and to help you understand aliases a little better. The purpose of this little script is to add the attribute luck to the character's stats through the use of the alias syntax.

Code: [Select]
class Game_Actor
  attr_accessor :luck
  #allows the instance variable @luck to be called like a method with $game_actor[ACTOR_ID].luck
 
  alias shinami_setup  setup
  def setup(actor_id)
    shinami_setup(actor_id)
    @luck = rand(100)
  end#of aliased "def setup(actor_id)"
end#of class Game_Actor

If you have any other questions, please ask them.

********
Hungry
Rep:
Level 96
Mawbeast
2013 Best ArtistParticipant - GIAW 11Secret Santa 2013 ParticipantFor the great victory in the Breakfast War.2012 Best Game Creator (Non-RM Programs)~Bronze - GIAW 9Project of the Month winner for December 2009Project of the Month winner for August 20082011 Best Game Creator (Non RM)Gold - GIAW Halloween
thanks a lot, that's exactly what I needed! ;D

FCF3a A+ C- D H- M P+ R T W- Z- Sf RLCT a cmn+++ d++ e++ f h+++ iw+++ j+ p sf+
Follow my project: MBlok | Find me on: Bandcamp | Twitter | Patreon