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.
Overwriting Partial Code

0 Members and 1 Guest are viewing this topic.

*
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
Just wondering:

Is it possible to overwrite parts of a code without overwriting the entire method?

I.E. If we have a method like this

Code: [Select]
def method
  for i in 100...110
    p i
  end
  p "done"
end

and you wanted to overwrite p "done" and change it to p "complete", but wanted to leave everything above it as it is and you don't want to rewrite the entire method.

Is that possible?



*
Full Metal Mod - He will pillage your women!
Rep:
Level 93
The RGSS Dude
You should re-write it into the following. (A more compatible method)

Code: [Select]
def method
  for i in 100...110
    p i
  end
end

Then in the class you want to re-define it, do -

Code: [Select]
alias: name_refering_to_original_method: method
def method
      name_refering_to_original_method
      p "Complete"
end
"The wonderful thing about Tiggers
Is Tiggers are wonderful things
Their tops are made out of rubber
Their bottoms are made out of springs

They’re bouncy, trouncy, flouncy, pouncy
Fun, fun, fun, fun, fun!
But the most wonderful thing about Tiggers
Is I’m the only one, I’m the only one."

*
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
Thanks, but the reason I wanted it was so for my scripts, if I had to do minor modifications to the default scripts (but ones that required some overwriting, so not straight additions), I could just do it in a code snippet, thus making it easier to share the scripts.

Unfortunately, your method would still involve rewriting part of the default scripts  ;9

Thanks anyway though.

*
? ? ? ? ? ? ? ? ? The nice kind of alien~
Rep:
Level 92
Martian - Occasionally kind
One of the goals of the SDK is to split many of the default scripts up into a lot of methods thus allowing easier customization.
This naturally causes a lot of compatibility problems, but meh.

Anyway. You might be able to modify the parse tree directly or you might be able to read and modify the original method in question.
If you are able to either of these ways it will probably not be simple what you have to do. I'm only guessing, I haven't researched.