So, I have done a few quick edits to someone else's code when I knew it wouldn't be that much work. For instance, recently I had to take all of the text in a javascript file and make it internal within a <script> tag in an html file.

Easy Peasy (easier peasier at least)

I've also taken code that had no functions, and put sections into functions with parameters.

That wasn't that bad.

But now:

I need to take code scattered all over a forum, create classes using related code, change the names of all functions and/or variables to more obvious names (if needed), put grouped code into functions with useful parameters (if needed), and package this code into their respective file names (by class). Also, I am trying to make a demo level/game that demonstrates every aspect of the code (how it is used).

I have a document automation app called Editorial that is going to make the re-naming a lot faster (once I have the code organized a bit better). I could also use it for adding functions with parameters to my code faster, and editing existing code (using regular expressions and such).

Questions:

How can I tackle this in an organized and efficient manner? Step by Step?
How should I package it? As a separate file for each class, or as one file with all classes in it?
The demo game? What could it be like? Style?

Notes:

I am programming in Lua, so I have more freedom when constructing the way my object orientation works.

One more Thing:
I also have to make several control schemes for the demo game.

UNREAL ENGINE 4:
Total LOC: ~3M Lines
Total Languages: ~32
--
GREAT QUOTES:
I can do ALL things through Christ - Jesus Christ
--
Logic will get you from A-Z, imagination gets you everywhere - Albert Einstein
--
The problems of the world cannot be solved by skeptics or cynics whose horizons are limited by the obvious realities. - John F. Kennedy

You could write some small tests the verify the code is functioning properly as you go

Try to isolate parts of the code that can be re factored a piece at a time.

Use a version control system like git, or subversion so you can revert to previous changes if you break something

Unfortunately, I find re factoring to be much harder in a dynamic language like Lua or javascript. If you accidentally leave a piece of code using old interfaces or functions it wont break until that section of code runs. A compiler can find a lot of problems for you before you run. Unfortunately, this isn't an option for you.