じ☆ve冰风 发表于 2026-7-29 09:50:53

Simple Monkey Patching

Simple Monkey Patching - v0.5​
I am tired of aliasing​
 ​
 ​
The Default Way of Monkey Patching:​
class Scene_Basealias monkeypatch_demo_sb_init initializedef initialize    monkeypatch_demo_sb_init    puts "A Scene Has Been Initiliazed!"endendWhy do we need all these aliases?

The Simple Way:​
class Scene_Base    monkeypatch :initialize do      puts "A Scene Has Been Initialized!"    endendThis is much better 


Normal Usages:​
                Code:       
class WhateverClassmonkeypatch :method_name do    #whatever you want to do ._.endend

                Code:       
class Scene_Basemonkeypatch :initialize, :before do    puts "This is called before the original scripts"endend

Installation​
get the script here: http://pastebin.com/zgQe4HWH​
insert this before all scripts that uses this type of monkey-patching.​
 ​
Possible Updates​
I really don't like the naming of the aliases._.. Maybe I will improve it later.​
You still cannot call the original return value._., maybe you can later.​
 ​
Known Bugs​
Currently None, but there is a high possibility that there are some 

 ​
Terms of Use​
You can repost this anywhere else without my permission.​
You can modify the script as long as you keep my name on it.​
Credit Me.  ​



本贴来自国际rpgmaker官方论坛作者:BakaCoder处,因国际论坛即将永久关站,为了存档多年珍贵资料,署名转载到本论坛存档,由于官方帖子为英文原帖,需要中文翻译请点击论坛顶部切换语言为中文就可以将帖子翻译成中文浏览,方便大家随时查看,原文地址:https://forums.rpgmakerweb.com/threads/simple-monkey-patching.20088/
页: [1]
查看完整版本: Simple Monkey Patching