Rewriting Script (for Scripters Only!)

Rewriting Script
Version: 1.0

Introduction

This script offers scripters a new alternative for editing scripts, where they cannot alias methods. With this script you can edit part of scripts without rewriting a whole part (e.g. a method). You can either delete lines add new lines or replace lines of a script.

How does this script work?

This script is quite simple to use. You just have to add some lines of code somewhere in a section. The code has to be structured like that:

#=# Rewriting Start #=#
  [i]method you want to call (see below, the code is written below)[/i]
#=# code #=#
  [i]the new code (when deleting this part isnt needed)[/i]
#=# Rewriting End #=#
Expand to see the code.

(Below you can find an example for easier understanding..)

Methods I can use with this script

Rewriting::delete_lines(section, lines, appearance)
(deletes lines in a script)
section: the section in which the code is deleted (can be an Integer or a String)
lines: the lines which are deleted (can be an Integer, a Range, a String or an Array containing some of the other possibilities)
appearance: if section is a String this is used when the section is found more than once (has to be an Integer)

Rewriting::write_lines(section, line, appearance, code = "\r") (adds new lines to a script)
section: the section in which the code is added (can be an Integer or a String)
line: the line in which the code is added (does not replace lines! Integer)
appearance: if section is a String this is used when the section is found more than once (has to be an Integer)
code: the code which is added

Rewriting::replace_lines(section, lines, appearance, code = "\r") (replaces lines in a script)
section: the section in which the code is added (can be an Integer or a String)
lines: the replaced lines (can be an Integer, a Range, a String or an Array containing some of the other possibilities)
appearance: if section is a String this is used when the section is found more than once (has to be an Integer)
code: the code which is added

Example
#=# Rewriting Start #=#
  Rewriting::delete_lines('Game_Character 3', 37..53, 1)
#=# Rewriting End #=#

#=# Rewriting Start #=#
  Rewriting::write_lines('Game_Character 3', 37, 1)
#=# code #=#
   p 'move_left has been deleted!'
#=# Rewriting End #=#

#=# Rewriting Start #=#
  Rewriting::replace_lines('Game_Character 3', 23, 1)
#=# code #=#
  @y += 2
   p 'move_down has been edited!'
#=# Rewriting End #=#
Expand to see the code.


Demo

you can find the script here:
*klick* (just klick on "Scripts")

Instructions

Just put the script above all other methods (so at the top of the list!) and use the methods shown above.

Compatibility

I think it should be compatible with all other scripts.. But you have to keep in mind, that bugfinding in parts which have been edited with this script will get difficult.. and of course you should not edit the code edited with this script anymore..

Author's Notes

Well.. I hope somebody needs this script.. ^^
I got the idea for this when I tried to alias a method where I only had to replace a single line.. of course this is not possible with aliasing.. but with this script.. (;

if you find any bugs, things to improve, etc. just post here.. ^^
So basically, this is like an alias but you can edit lines in the middle of the method as opposed to just adding things to the beginning or the end of the method with an alias.
OMG, this is just what I need! YOU RULE!
Wow!

This is an amazing idea...this will really help alot of people i wish i had this a while ago cause i really needed it :P

Well done!

~Mac
Hate to say this, but this script can cause a lot of errors. It's a nice idea, but if you change the line count of a script, following lines get shifted and won't match up with the defaults. And when a script goes to edit were those lines should be, you get unwanted line replacements/edits.

A good attempt, though.
Shouldn't you be working on releasing an update of pixelmovement, f0tz? ; )

Anyway, this is quite interesting. Many times there was only one line to edit in the middle of some update method. Cheers.
thxthx (:

Icedmetal57: exactly!

Yeyinde: This is what I wrote.. of course you cannot edit those scripts anymore (or you have to change the rewriting parts too)
I hope I find a way to find a way around this..

arevulopapo: well.. I needed this for the pixelmovement.. ^^ although I dont know yet if I will really use it..
The demo links are down, 404 not found :( I really would like to try it.
o0 sorry.. I changed my website so the links have changed too.. -.-

you can find the script here:
*klick* (just klick on "Scripts")

Original thread: https://www.hbgames.org/forums/viewtopic.php?t=29028