Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- -- Reduce Read Time
- -- require "TimedActions/ISReadABook"
- --SIMPLE INJECTION
- local old_fn = ISReadABook.new; -- We put the link to the old function in a variable "old_fn".
- -- Replacing the old function with new one.
- -- The old function continues to exist and we have the link in the variable old_fn.
- function ISReadABook:new(...) -- "..." means any parameters. ":" means unlisted "self" parameter.
- local o = old_fn(self, ...); -- We call old function and give all parameters to it.
- -- The result o is saved in a local variable o.
- -- AFTER old function is finished, we apply our patch.
- -- Sadly, injection in the middle of the function (if possible) should be more complicated.
- -- So we keep it simple:
- -- We only have to take into account that at the end of the old function, time can be overwritten by 1.
- if o.maxTime ~= 1 then
- o.maxTime = o.maxTime * 0.5;
- end
- return o; --We return o as old function did.
- end
- -- Now nobody (except us) has access to the old function.
Advertisement
Add Comment
Please, Sign In to add comment