Hi there,
I have two scripts imported into the script editor, let's name them A and B. Is there a way to use some features from script A in script B?
Using a script in another scrpt
● ARCHIVED · READ-ONLY
-
-
Depends on those scripts itself.
If those scripts has different concept at the first place, then it doesn't
if those scripts are handles the same problem, then it's either yes or incompatible instead.
Is this the first time do you use script? -
No, but I was wondering if there was like an import command. I guess I will use a common event instead.Depends on those scripts itself.
If those scripts has different concept at the first place, then it doesn't
if those scripts are handles the same problem, then it's either yes or incompatible instead.
Is this the first time do you use script? -
Basically, if two scripts co-existed in same project (assumed they're above main), your project already have those script commands. But you need to edit the script itself. Only said script A and B is not enough. It needs real cases.
Err... I hope I said clearly -
Can you show me an example? Yes both scripts exist in the same project and they are above main.Basically, if two scripts co-existed in same project (assumed they're above main), your project already have those script commands. But you need to edit the script itself. Only said script A and B is not enough. It needs real cases.
Err... I hope I said clearly -
I think you misunderstood something about scripts.
All scripts are automatically imported into the engine when placed in the script editor, resulting them to be available at the same time.
Usually those scripts have different functions and are independent of each other - that's why they work by default.
Some scripts (like menu scripts) are intended to be linked to other scripts - they have instructions on how to create those links.
The only part where you might have problems is when one script creates a new scene and you want the functions of that scene changed to work like a different script - that requires reprogramming both scripts. This can be easy in some cases and difficult with other scripts.
So basically, the answer to your question depends on what those scripts are, it can't be answered generally for any script.
Give us the names of those two scripts, and tell us what you want combined, and then we can give you an answer. -
Ok so...I want to call a method from the Game_Interpreter class into the Window_MenuStatus class. Can I do that?
-
Tsukihime wrote a script to enable script interpretion inside menu scenes - check her blog, I don't have the link ready.
But you still didn't say which scripts you're planning to use - not even if you're talking about default script parts or added functions into those classes, because that's what a lot of scripts do: modify or add functions from existing classes.
You didn't even tell what method you want to call where in the MenuStatus class - you can't expect answers if you don't tell us what exactly you want to do, because in programming, too much has the answer "depends", and a command solution given for one specific request will NOT work for something else. -
Ok I think I got it. Thanks :D
-
To put this briefly: The game engine knows absolutely nothing about "scripts".
All the engine sees are classes and methods (and modules). It doesn't matter where they came from or how they got there. So the short answer to your question is yes, you can use the classes from one "script" in another script or in the core scripts or even in some new script.
You may have to do a bit of forward declaration or rearranging of the order of the scripts, and it's up to you to make sure there are no conflicts for variables and scope.
Without specifics, no one can really answer more than that.