Dear forum users! In compliance with the new European GDPR regulations, we'd just like to inform you that if you have an account, your email address is stored in our database. We do not share your information with third parties, and your email address and password are encrypted for security reasons.

New to the forum? Say hello in this topic! Also make sure to read the rules.

Access script methods throug other script

Here you can find answered ScriptAPI topics.
Forum rules
By using the forum you agree to the following rules.
Post Reply
User avatar
Mr Argon
Fighter
Fighter
Posts: 56
Joined: Sat Mar 09, 2019 2:22 am
SFD Account: Argón (steam)
SFD Alias: Mr. Argon
Started SFD: Pre-Alpha 1.8.2c
Location: Argentina
Gender:
Age: 21

Access script methods throug other script

Post by Mr Argon » Tue Feb 25, 2020 4:31 pm

It is possible to access the methods of a script through other script? I mean, I have a custom script that changes some game mechanics, and it's all controlled by an object named GameController (public static class GameController).

I want to create an extension script that makes the previous script compatible with other game modes rather than versus.

Can I, for example, access GameController.SayLine() (custom method inside custom class) through another script?
1 x
I'м д Liттlэ оdd... sтill саи livе шiтн тнат.

User avatar
JakSparro98
Superfighter
Superfighter
Posts: 530
Joined: Fri Jul 15, 2016 7:56 pm
Started SFD: PreAlpha 1.0.5
Location: Rome, Italy
Gender:
Age: 26

Post by JakSparro98 » Tue Feb 25, 2020 8:17 pm

Extension scripts live in their own ecosystem, they can access common data zones like game session and local storage but methods, declared types and variables are exclusive of the script that implemented it.
0 x

User avatar
Mr Argon
Fighter
Fighter
Posts: 56
Joined: Sat Mar 09, 2019 2:22 am
SFD Account: Argón (steam)
SFD Alias: Mr. Argon
Started SFD: Pre-Alpha 1.8.2c
Location: Argentina
Gender:
Age: 21

Post by Mr Argon » Tue Feb 25, 2020 9:05 pm

Maybe using localstorage I can access, because I don't want to make my script much longer, it actually has around 700 lines. Using another script for compatibility could be really useful
0 x
I'м д Liттlэ оdd... sтill саи livе шiтн тнат.

User avatar
Gurt
Lead Programmer
Lead Programmer
Posts: 1885
Joined: Sun Feb 28, 2016 3:22 pm
Title: Lead programmer
Started SFD: Made it!
Location: Sweden
Gender:
Age: 34

Post by Gurt » Mon Mar 02, 2020 7:34 pm

You may use IGame.GetSharedStorage("someuniqueidentifier") to send values between scripts.
1 x
Gurt

User avatar
Mr Argon
Fighter
Fighter
Posts: 56
Joined: Sat Mar 09, 2019 2:22 am
SFD Account: Argón (steam)
SFD Alias: Mr. Argon
Started SFD: Pre-Alpha 1.8.2c
Location: Argentina
Gender:
Age: 21

Post by Mr Argon » Mon Mar 02, 2020 7:54 pm

That's a good idea, I'll try that out. Thanks
1 x
I'м д Liттlэ оdd... sтill саи livе шiтн тнат.

Post Reply