I'm not sure what class or module the load_data command belongs to. I want to alias it so I can do some extra processing whenever a database file or a map is loaded. Does anyone know what the correct syntax would be (or how I would find where load_data "lives")?
How to alias load_data?
RGSSx Script SupportNevermind - my bad, wrong RPGmaker :X
Yeah, Ace 🙂
Ah, it's a built-in function, like rgss_main:
So that shows me where it is, but I'm still unsure how to alias it ...
Edit: think I've got it:
Edit2: And now that I've got it, I don't think I can use it for the desired purpose, as database objects are arrays, and a map isn't. So back to plan 1 (2 separate methods), and at least I learned something new today.
Ah, it's a built-in function, like rgss_main:
So that shows me where it is, but I'm still unsure how to alias it ...
Edit: think I've got it:
Code:
alias shaz_load_data load_data
def load_data(file)
p 'loading file ' + file
shaz_load_data(file)
# do stuff here
end
Edit2: And now that I've got it, I don't think I can use it for the desired purpose, as database objects are arrays, and a map isn't. So back to plan 1 (2 separate methods), and at least I learned something new today.
Probably not helpful anymore, but for the sake of completion:
load_data is a private instance method from the Kernel module (it should therefore show up when you use Kernel.private_instance_methods(false)).
Good luck with your project.
load_data is a private instance method from the Kernel module (it should therefore show up when you use Kernel.private_instance_methods(false)).
Good luck with your project.
And that's why we got:
object.is_a?(Array)
Which should let you do what you want, I guess.
You can also check the file name itself to know ahead what is loaded exactly. A map file always has "MapNNN" in it's name, the data file for weapons is always named "Weapons.rvdata2", and so on.
Thanks guys.
Original thread: https://forums.rpgmakerweb.com/threads/how-to-alias-load_data.60183/