Using a script in another scrpt

Joined
Feb 1, 2013
Messages
62
Reaction score
12
Primarily Uses
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?
 

TheoAllen

Self-proclaimed jack of all trades
Veteran
Joined
Mar 16, 2012
Messages
5,592
Reaction score
6,522
First Language
Indonesian
Primarily Uses
RMVXA
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?
 
Last edited by a moderator:
Joined
Feb 1, 2013
Messages
62
Reaction score
12
Primarily Uses
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.
 

TheoAllen

Self-proclaimed jack of all trades
Veteran
Joined
Mar 16, 2012
Messages
5,592
Reaction score
6,522
First Language
Indonesian
Primarily Uses
RMVXA
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
 
Joined
Feb 1, 2013
Messages
62
Reaction score
12
Primarily Uses
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.
 

Andar

Veteran
Veteran
Joined
Mar 5, 2013
Messages
31,367
Reaction score
7,676
First Language
German
Primarily Uses
RMMV
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.
 
Joined
Feb 1, 2013
Messages
62
Reaction score
12
Primarily Uses
Ok so...I want to call a method from the Game_Interpreter class into the Window_MenuStatus class. Can I do that?
 

Andar

Veteran
Veteran
Joined
Mar 5, 2013
Messages
31,367
Reaction score
7,676
First Language
German
Primarily Uses
RMMV
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.
 

Mouser

Veteran
Veteran
Joined
Aug 19, 2012
Messages
1,245
Reaction score
264
First Language
English
Primarily Uses
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.
 

Users Who Are Viewing This Thread (Users: 0, Guests: 1)

Latest Threads

Latest Profile Posts

People3_5 and People3_8 added!

so hopefully tomorrow i get to go home from the hospital i've been here for 5 days already and it's driving me mad. I miss my family like crazy but at least I get to use my own toiletries and my own clothes. My mom is coming to visit soon i can't wait to see her cause i miss her the most. :kaojoy:
Couple hours of work. Might use in my game as a secret find or something. Not sure. Fancy though no? :D
Holy stink, where have I been? Well, I started my temporary job this week. So less time to spend on game design... :(
Cartoonier cloud cover that better fits the art style, as well as (slightly) improved blending/fading... fading clouds when there are larger patterns is still somewhat abrupt for some reason.

Forum statistics

Threads
105,868
Messages
1,017,083
Members
137,583
Latest member
write2dgray
Top